Specifications
BASIC Stamp II
Page 298 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
RCtime
RCTIME
pin, state, resultVariable
Count time while pin remains in state—usually to measure the charge/
discharge time of resistor/capacitor (RC) circuit.
•
Pin
is a variable/constant (0–15) that specifies the I/O pin to use.
This pin will be placed into input mode and left in that state when
the instruction finishes.
•
State
is a variable or constant (1 or 0) that will end the RCtime
period.
•
ResultVariable
is a variable in which the time measurement (0 to
65535 in 2µs units) will be stored.
Explanation
RCtime can be used to measure the charge or discharge time of a resis-
tor/capacitor circuit. This allows you to measure resistance or capaci-
tance; use R or C sensors (such as thermistors or capacitive humidity
sensors); or respond to user input through a potentiometer. In a broader
sense, RCtime can also serve as a fast, precise stopwatch for events of
very short duration (less than 0.131 seconds).
When RCtime executes, it starts a counter that increments every 2µs. It
stops this counter as soon as the specified pin is no longer in state (0 or
1). If pin is not in state when the instruction executes, RCtime will re-
turn 1 in resultVariable, since the instruction requires one timing cycle
to discover this fact. If pin remains in state longer than 65535 timing
cycles of 2µs each (0.131 seconds), RCtime returns 0.
Figure I-14 shows suitable RC circuits for use with RCtime. The circuit
in I-14a is preferred, because the BS2’s logic threshold is approximately
1.5 volts. This means that the voltage seen by the pin will start at 5V
then fall to 1.5V (a span of 3.5V) before RCtime stops. With the circuit
of I-14b, the voltage will start at 0V and rise to 1.5V (spanning only
1.5V) before RCtime stops. For the same combination of R and C, the
circuit shown in I-14a will yield a higher count, and therefore more
resolution than I-14b.










