BASIC stamp manual v2.2
RCTIME – BASIC Stamp Command Reference
Page 364 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
Figure 5.33 shows suitable RC circuits for use with RCTIME. The circuit in
Figure 5.33a is preferred, because the BASIC Stamp's logic threshold is
approximately 1.4 volts. This means that the voltage seen by the pin will
start at 5V then fall to 1.4V (a span of 3.6V) before RCTIME stops. With
the circuit of Figure 5.33b, the voltage will start at 0V and rise to 1.4V
(spanning only 1.4V) before RCTIME stops. For the same combination of
R and C, the circuit shown in Figure 5.33a will yield a higher count, and
therefore more resolution than Figure 5.33b.
a. b.
Figure 5.33: Example RC Circuits.
Use a (left) with State = 1. Use b
(right) with State = 0.
Before RCTIME executes, the capacitor must be put into the state specified
in the RCTIME instruction. For example, with Figure 5.33a, the capacitor
must be charged until the top plate is at 5V, then a State value of 1 will be
used to monitor the discharge of the capacitor through the variable
resistance.
Here’s a typical sequence of instructions for Figure 5.33a (assuming I/O
pin 7 is used):
result VAR Word
HIGH 7 ' charge the cap
PAUSE 1 ' for 1 ms
RCTIME 7, 1, result ' measure RC discharge time
DEBUG DEC ? result ' display result
Using RCTIME is very straightforward, except for one detail: For a given R
and C, what value will RCTIME return? It’s easy to figure, based on a
value called the RC time constant, or tau (τ) for short. Tau represents the
time required for a given RC combination to charge or discharge by 63
SUITABLE RCTIME CIRCUITS.
D
ON'T FORGET TO DISCHARGE THE
CAPACITOR BEFORE EXECUTING
RCTIME.
P
REDICTING THE RETURNED VALUE.