BASIC stamp manual v2.2
RCTIME – BASIC Stamp Command Reference
Page 366 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
So it takes only 110 µs for the cap to charge/discharge, meaning that the 1
ms charge/discharge time of the example is plenty.
A final note about Figure 5.33: You may be wondering why the 220 Ω
resistor is necessary at all. Consider what would happen if resistor R in
Figure 5.33a were a pot, and were adjusted to 0 Ω. When the I/O pin went
high to charge the cap, it would see a short direct to ground. The 220 Ω
series resistor would limit the short circuit current to 5V/220 Ω = 23 mA
and protect the BASIC Stamp from damage. (Actual current would be
quite a bit less due to internal resistance of the pin’s output driver, but you
get the idea.)
Demo Program (RCTIME1.bs2)
' RCTIME1.BS2
' This program shows the standard use of the RCTIME instruction measuring
' an RC charge/discharge time. Use the circuit in the RCTIME description
' (in the manual) with R = 10K pot and C = 0.1 uF. Connect the circuit to
' pin 7 and run the program. Adjust the pot and watch the value shown on
' the Debug screen change.
' {$STAMP BS2}
' {$PBASIC 2.5}
RC PIN 7
result VAR Word
Main:
DO
HIGH RC ' charge the cap
PAUSE 1 ' for 1 ms
RCTIME RC, 1, result ' measure RC discharge time
DEBUG HOME, DEC result ' display value
PAUSE 50
LOOP
END
NOTES ABOUT 220 Ω RESISTOR IN THE RC
CIRCUITS
.
All
2
NOTE: This example program can be
used with all BS2 models by changing
the $STAMP directive accordingly.