Issue
93 April 1998
Picaro:
A Stamp-like Interpreted Controller
by
Tom Napier
For
years, Toms been itching to control the instruction
sets of processors. Using a PIC, some memory, and
an interpreter, he bypasses the processor hurdle
and writes his own language. He shows you how to
do it, too.
The
core technique at work in the PLU is to take the record
for the same day of the previous week and use it to
predict the occupancy for the current day. Its
well worth keeping a weeks worth of records since
human habits center around a weekly pattern.
The
process of putting the data to work is straightforward.
Once every hour, at the same moment when the current
occupancy state is recorded in todays record,
the record for that same day in the previous week is
evaluated.
At
this moment of truth, the algorithm looks ahead in the
record to see if there is any expected occupancy. It
only needs to see a couple of bits in the data from
the previous weekthe ones that indicated the occupancy
state in the next 2-h slots.
These
bits tell us if the area was occupied a week earlier
during the upcoming couple hours. If so, then its
likely to happen again. If the system senses an unoccupied
state, then it need only check for either of the upcoming
two hours to indicate an expected occupancy, and voiląwe
have anticipation.
Note
that, using this method, there is a resolution of 1
h, which means that accuracy is ± 1 h. Thats why
the anticipator looks at the next 2 h of last weeks
record. If it only looks 1 h ahead, it could err on
the minus side all the way down to (almost) zero anticipation.
Using 2 h gives it a performance range of 13 h
of anticipation.
The
range could easily be decreased by using a higher resolution
system-wide. For example, records could indicate half-hour
increments instead, which double the RAM usage but be
otherwise identical in function, yielding an anticipation
range from 30 to 90 min. The beauty of this method is
that any resolution can be used and the implementation
remains pretty much the same.