POT - BASIC Stamp Command Reference
Page 240
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
variable resistor affects the time it takes to discharge the capacitor from 5
volts to approximately 1.4 volts.
The 16-bit reading is multiplied by (Scale/256), so a scale value of 128
would reduce the range by approximately 50%, a scale of 64 would reduce
to 25%, and so on. The amount by which the internal value must be scaled
varies with the size of the resistor being used.
Finding the best Scale value:
1. Build the circuit shown in Figure 5.25 and plug the BS1 into the
PC.
2. In the DOS editor (stamp.exe) press ALT-P. A special calibration
window appears, allowing you to find the best value.
3. The window asks for the number of the I/O pin to which the
variable resistor is connected. Select the appropriate pin (0-7).
4. The editor downloads a short program to the BS1 (this overwrites
any program already stored in the BS1).
5. Another window appears, showing two numbers: scale and value.
Adjust the resistor until the smallest number is shown for scale
(assuming you can adjust the resistor, as with a potentiometer).
6. Once you’ve found the smallest number for scale, you’re done.
This number should be used for the Scale in the POT command.
7. Optionally, you can verify the scale number found above by
pressing the spacebar. This locks the scale and causes the BS1 to
read the resistor continuously. The window displays the value. If
the scale is good, you should be able to adjust the resistor,
achieving a 0–255 reading for the value (or as close as possible). To
change the scale value and repeat this step, just press the spacebar.
Continue this process until you find the best scale.
Demo Program (POT.bas)
' This program demonstrates the PAUSE command's time delays. Once a second, the
' program will put the message, "paused" on the screen.
'{$STAMP BS1} 'STAMP directive (specifies a BS1)
Loop:
POT 0, 100, B2 ' Read potentiometer on pin 0.
SEROUT 1, N300, (B2) ' Send potentiometer reading
' over serial output.
GOTO Loop
1
S
TEPS TO FIND THE BEST SCALE
VALUE
.
Summary of Contents for BASIC Stamp 1
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...