C
ALCULATING CHARGE AND
.
DISCHARGE TIME
T
RC T
.
HE
IME EQUATION
D
ETERMINING HOW LONG TO CHARGE
OR DISCHARGE THE CAPACITOR
RCTIME.
BEFORE EXECUTING
5: BASIC Stamp Command Reference – RCTIME
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
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
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
The RC time constant is 1 x 10
required for this RC circuit to go from 5V to 1.5V (as in Figure 5.29a):
-3
Time = -1 x 10
* ( ln(5.0v / 1.5v) ) = 1.204 x 10
On the BS2, the unit of time is 2µs (See Table 5.66), that time (1.204 x 10
works out to 602 units. With a 10 k resistor and 0.1 µF cap, RCTIME would
return a value of approximately 600. Since V
we can use a simplified rule of thumb to estimate RCTIME results for
circuits like 5.29a:
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 commands. A given RC
charges or discharges 98 percent of the way in 4 time constants (4 x R x C).
In Figure 5.29, 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:
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 257
/ V
) )
final
initial
-6
-3
) = 1 x 10
-3
or 1 millisecond. Now calculate the time
-3
and V
doesn't change,
initial
final
-3
)
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?