BASIC stamp manual v2.2
5: BASIC Stamp Command Reference – RCTIME
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 365
percent of the total change in voltage that they will undergo. More
importantly, the value τ is used in the generalized RC timing calculation.
Tau’s formula is just R multiplied by C:
τ = R x C
The general RC timing formula uses τ to tell us the time required for an
RC circuit to change from one voltage to another:
time = -τ * ( ln (V
final
/ V
initial
) )
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 10 k
resistor and 0.1 µF cap. Calculate τ:
τ = (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.4V (as in Figure 5.33a):
time = -1 x 10
-3
x (ln(1.4v / 5.0v)) = 1.273 x 10
-3
On the BS2, the unit of time is 2µs (See Table 5.87), that time (1.273 x 10
-3
)
works out to 636 units. With a 10 kΩ resistor and 0.1 µF cap, RCTIME
would return a value of approximately 635. Since V
initial
and V
final
doesn't
change, we can use a simplified rule of thumb to estimate RCTIME results
for circuits like Figure 5.33a:
RCTIME units = 635 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 commands. A given RC
charges or discharges 98 percent of the way in 5 time constants (5 x R x C).
In Figure 5.33, 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 = 5 x 220 x (0.1 x 10
-6
) = 110 x 10
-6
CALCULATING CHARGE AND DISCHARGE
TIME
.
T
HE RC TIME EQUATION.
D
ETERMINING HOW LONG TO CHARGE OR
DISCHARGE THE CAPACITOR BEFORE
EXECUTING
RCTIME.