RCTIME - BASIC Stamp Command Reference
Page 256
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
Figure 5.29 shows suitable RC circuits for use with RCTIME. The circuit in
5.29a is preferred, because the BASIC Stamp'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 5.29b, 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 5.29a will yield a higher count, and therefore more
resolution than 5.29b.
Before RCTIME executes, the capacitor must be put into the state specified
in the RCTIME instruction. For example, with figure 5.29a, the capacitor
must be discharged until both plates (sides of the capacitor) are at 5V. It
may seem counterintuitive that discharging the capacitor makes the input
high, but remember that a capacitor is charged when there is a voltage
difference between its plates. When both sides are at +5V, the cap is
considered discharged.
Here’s a typical sequence of instructions for 5.29a (assuming I/O pin 7 is
used):
Result VAR WORD ' Word variable to hold result.
HIGH 7 ' Discharge the cap
PAUSE 1 ' for 1 ms.
RCTIME 7,1,Result ' Measure RC charge time.
DEBUG ? Result ' Show value on screen.
Using RCTIME is very straightforward, except for one detail: For a given R
and C, what value will RCTIME return? It’s easy to figure, based on a
a
b
R
C
use with state = 0
use with state = 1 (preferred - see text)
Vdd
Vss
to I/O pin
220
Ω
R
C
Vdd
Vss
to I/O pin
220
Ω
Figure 5.29: Example RC Circuits.
Use A (left) with State = 1. Use B
(right) with State = 0.
S
UITABLE
RCT
IME CIRCUITS
.
P
REDICTING THE RETURNED VALUE
.
D
ON
'
T FORGET TO DISCHARGE THE
CAPACITOR BEFORE EXECUTING
RCTIME.
Summary of Contents for BASIC Stamp 2e
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...