Specifications
BASIC Stamp II
Page 300 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
In this formula ln is the natural logarithm; it’s a key on most scientific
calculators. Let’s do some math. Assume we’re interested in a 10k re-
sistor and 0.1µF cap. Calculate t:
t = (10 x 10
3
) x (0.1 x 10
-6
) = 1 x 10
-3
The RC time constant is 1 x 10
-3
or 1 millisecond. Now calculate the time
required for this RC circuit to go from 5V to 1.5V (as in figure I-14a):
In RCtime units of 2µs, that time (1.204 x 10
-3
) works out to 602 units.
With a 10k resistor and 0.1µF cap, RCtime would return a value of ap-
proximately 600. Since Vinitial and Vfinal don’t change, we can use a
simplified rule of thumb to estimate RCtime results for circuits like I-14a:
RCtime units = 600 x R (in kΩ) x C (in µF)
Another handy rule of thumb can help you calculate how long to
charge/discharge the capacitor before RCtime. In the example above
that’s the purpose of the High and Pause instructions. A given RC
charges or discharges 98 percent of the way in 4 time constants (4 x R x
C). In figure I-14a/b, the charge/discharge current passes through the
220Ω series resistor and the capacitor. So if the capacitor were 0.1µF,
the minimum charge/discharge time should be:
Charge time = 4 x 220 x (0.1 x 10
-6
) = 88 x 10
-6
So it takes only 88µ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 I-14: You may be wondering why the 220Ω
resistor is necessary at all. Consider what would happen if resistor R in
I-14a were a pot, and were adjusted to 0Ω. When the I/O pin went
high to discharge the cap, it would see a short direct to ground. The
220Ω series resistor would limit the short circuit current to 5V/220Ω =
23 milliamperes (mA) and protect the BS2 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 1
This program shows the standard use of the RCtime instruction—mea-
suring an RC charge/discharge time. Use the circuit of figure I-14a,










