5: BASIC Stamp Command Reference – RCTIME
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 255
RCTIME
BS1 BS2 BS2e BS2sx BS2p
(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.66.
Quick Facts
BS2 BS2e BS2sx BS2p
Units in Variable
2 µs 2 µs 0.8 µs 0.9 µs
Maximum pulse
width
131.07 ms 131.07 ms 52.428 ms 58.982 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 starts a counter (who's unit of time is shown in
Table 5.66). 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.
2
2
2
Table 5.66: RCTIME Quick Facts.
HOW RCTIME
S TIMER WORKS.