■ FIGURE 5. Parallax Neon Sign.
rate parameters for use with the RC- 4 network.
Now we can use DEBUG to see what we get from the
RCTIME circuit on the extreme ends of the potentiometer.
On my system, I got 18 on the low end, and 1,124 on
the high end. What we would like to do is rescale this
range to 50 to 1,000 milliseconds for our step delay. Here’s
The span of our raw input is 1,106 (1,124 minus 18).
We divide this span into our desired output span of 950
(1,000 minus 50) and end up with 0.858. You’ll remember
that we’ve used the ** operator in the past to multiply by
fractional values of less that one, so that’s what we’ll
do here. To convert 0.858 for use with **, we multiply the
fraction by 65,536. The last part is to compensate for the
low end of the output range (the “b” in the mx + b
equation). After the multiplication, we add 35. Where did this
come from? Since the low-end raw input is 18 and gets
multiplied by 0.858, it will be reduced to 15. Our minimum
new output value of 50 minus 15 is 35. DEBUG can be used
to confirm our new range is very close to 50 to 1,000.
Knowing how we worked through the process, you can now
readjust the program to create any minimum-to-maximum
speed delay that you like.
An important lesson here is that there will be times
when we have to work through a program empirically to get
to the final result. Here’s what we end up with:
when we use
Okay, now how
will you use
this project to
light up your ■ FIGURE 4. Tower of Power.
And just to show that we at Parallax actually put all
this stuff to use, have a look at Figures 4 through 6. Figure
4 is Ryan Clarke’s (Parallax Tech Support) RC- 4 “Tower of
Power” that he used to control a lighting sequence for his
Christmas tree (it was a pretty fancy tree!). Figures 5 and 6
show a custom neon sign that my boss, Ken Gracey, and I
RCTIME Speed, 1, delay
delay = delay */ Adjust
delay = delay ** $DBE4 + 35
Getting back to the main code we’re left with pointing
to the next program step. Again, LOOKUP is used to
determine which sequence is selected and assign the value
of pgmMax (length of sequence in bytes). The next
requirement is to add two to pgmStep — we have to do
this because we’re using Word-sized step values. The
modulus operator takes care of wrapping the sequence
back to its beginning.
And there we have it: a simple lighting control program
that can send its output to a network of RC- 4 relay boards
or to Opto- 22 SSRs using the Stamp CI board. I think this
demonstrates the extraordinary flexibility of PBASIC2,
February 2006 87