Table of Contents

Advertisement

RCTIME

Measure an RC charge/discharge time.
usage:
RCTIME pin,state,variable
Pin will be placed in input mode and time will be measured in 2µs
units while pin is in state. The result will be written into variable. If an
overflow occurs (>131ms), 0 will be written.
This is useful for measuring resistor-capacitor charge/discharge times.
Since the logic threshold of a pin is ~1.4 volts, it is best to have the RC
voltage go from the 5V supply towards ground, yielding a span of ~3.6
volts. For example, to convert a potentiometer setting to a number:
Connect the pot as shown below. Make the pin high for 1 ms, then
do RCTIME. The resistor-cap junction will start at 5V and fall to-
wards ground. When ~1.4 is reached, the counting will terminate
and the result will be returned to variable. Adjusting the pot causes
the returned value to go up or down.
Note: the 10-ohm resistor may be necessary to avoid
a possible short between ground and the high I/O pin.
Sample Program:
Pot
var
Loop: HIGH 0
PAUSE 1
RCTIME 0,1,Pot
DEBUG ?Pot
GOTO loop
BASIC Stamp II Manual 0.94 • Parallax, Inc. • (916) 624-8333 • Page 51
BASIC Stamp II
word
'Discharge capacitor
'Allow time for discharge
'Measure chrage time
'Show result on PC
'Repeat the process

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BASIC Stamp II and is the answer not in the manual?

Table of Contents