Specifications
BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 299
2
Before RCtime executes, the capacitor must be put into the state speci-
fied in the RCtime instruction. For example, with figure I-14a, the ca-
pacitor must be discharged until both plates (sides of the capacitor) are
at 5V. It may seem counterintuitive that discharging the capacitor makes
the input high, but remember that a capacitor is charged when there is
a voltage difference between its plates. When both sides are at +5V, the
cap is considered discharged.
Here’s a typical sequence of instructions for I-14a (assuming I/O pin 7
is used):
result var word ' Word variable to hold result.
high 7 ' Discharge the cap
pause 1 ' for 1 ms.
RCTIME 7,1,result ' Measure RC charge time.
debug ? result ' Show value on screen.
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 (t) for short. Tau represents
the time required for a given RC combination to charge or discharge
by 63 percent of the total change in voltage that they will undergo.
More importantly, the value t is used in the generalized RC timing
calculation. Tau’s formula is just R multiplied by C:
t = R x C
The general RC timing formula uses t to tell us the time required for an
RC circuit to change from one voltage to another:
ab
use with state = 0use with state = 1 (preferred—see text)
+5V
R
I/O pin
220Ω
C
+5V
R
220Ω
C
I/O pin
Figure I-14










