BASIC stamp manual v2.2
5: BASIC Stamp Command Reference – RCTIME
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 363
RCTIME
BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px
(See POT)
RCTIME Pin, State, Variable
Function
Measure time while Pin remains in State; usually to measure the
charge/discharge time of resistor/capacitor (RC) circuit.
• Pin is a variable/constant/expression (0 – 15) that specifies the I/O
pin to use. This pin will be placed into input mode.
• State is a variable/constant/expression (0 - 1) that specifies the
desired state to measure. Once Pin is not in State, the command
ends and stores the result in Variable.
• Variable is a variable (usually a word) in which the time
measurement will be stored. The unit of time for Variable is
described in Table 5.87.
Quick Facts
Table 5.87: RCTIME Quick Facts.
BS2 BS2e BS2sx BS2p BS2pe BS2px
Units in
Variable
2 µs 2 µs 0.8 µs 0.75 µs 2 µs 0.75 µs
Maximum
Pulse Width
131.07 ms 131.07 ms 52.428 ms 49.151 ms 131.07 ms 49.151 ms
Explanation
RCTIME can be used to measure the charge or discharge time of a
resistor/capacitor circuit. This allows you to measure resistance or
capacitance; 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.
When RCTIME executes, it makes Pin an input, then starts a counter
(who's unit of time is shown in Table 5.87). 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 return 1 in Variable, since the
instruction requires one timing cycle to discover this fact. If pin remains in
State longer than 65535 timing cycles RCTIME returns 0.
HOW RCTIME'S TIMER WORKS.
1
All
2