27220 Parallax Inc, 27220 Datasheet - Page 54

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
If we decide to replace the BS2 with a faster microcontroller, for example a BS2p,
the only thing we need to do is read the pot and enter the low and high readings
from it. After we make those changes the Scale constant will be updated on the
next compilation and the program will run just as it did on the BS2.
You may be wondering why the LoScale value is something greater than 0. If you
look at the schematic, there is a 220-ohm resistor between the pot’s wiper and the
center connection. The purpose of this resistor is to protect the BASIC Stamp when
the pot is turned all the way to Vss and the P15 is made an output and high; it also
causes a bit of delay in the capacitor discharge, hence the minimum value that is
greater than zero.
With grafVal scaled to a byte we can move on to creating the bar or dot graph
with the LEDs. The program uses the DCD operator to determine highest lighted bit
value from grafVal. With eight LEDs in the graph, grafVal is divided by 32,
forcing the result of DCD to output values from %00000001 (DCD 0) to %10000000
(DCD 7).
In Dot mode, this is all that’s required and a single LED that represents the scale of
the pot input is lit. In Bar Mode, however, the lower LEDs must be filled in. This is
accomplished in a simple loop. The control value for the loop is the variable, hiBit,
which is also calculated using DCD. In this loop, hiBit will be tested for zero to exit,
so each iteration through the loop will decrement (decrease) this value.
If hiBit is greater than zero, the bar graph workspace variable, newBar, is shifted
left and its bit 0 is set. For example, if DCD returned %1000 in hiBit, here’s how
hiBit and newBar would be affected through the loop:
The purpose for the variable, newBar, is to prevent the LEDs from flashing with each
update. This allows the program to start with an “empty” graph and build to the
hiBit newBar
1000
0100
0010
0001
0000
0001
0011
0111
1111
(done - exit loop and display value)

Related parts for 27220