BASIC stamp manual v2.2
POT – BASIC Stamp Command Reference
Page 340 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.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.27 and plug the BS1 into the PC.
2. In the BASIC Stamp editor select Pot Scaling from the Run menu. 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) from the drop-
down.
4. The editor downloads a short program to the BS1 (this overwrites any
program already stored in the BS1).
5. The window will now show the Scale Factor. 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 selecting
the POT Value checkbox (so it's checked). 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, deselect the
POT Value checkbox. Continue this process until you find the best
scale.
Demo Program (POT.bs1)
' POT.bs1
' This program demonstrates the use of the POT command. Connect one side
' of a 5-50K potentiometer to P0. To the other side of the potentiometer
' connect a 0.1 uF capacitor, and then connect the other side of the
' capacitor to Vss (ground). Before running demo program,
' use the Run | POT Scaling dialog to determine the best Scale factor.
1