Parallax BASIC Stamp 2e Programming Manual page 258

Table of Contents

Advertisement

RCTIME - BASIC Stamp Command Reference
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.
to I/O pin
220
a
use with state = 1 (preferred - see text)
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
HIGH 7
PAUSE 1
RCTIME 7,1,Result
DEBUG ? Result
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
Page 256 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
Vdd
C
to I/O pin
R
Vss
' Word variable to hold result.
' Discharge the cap
' for 1 ms.
' Measure RC charge time.
' Show value on screen.
Vdd
R
220
C
Vss
b
use with state = 0
S
RCT
UITABLE
IME CIRCUITS
Figure 5.29: Example RC Circuits.
Use A (left) with State = 1. Use B
(right) with State = 0.
D
'
ON
T FORGET TO DISCHARGE THE
CAPACITOR BEFORE EXECUTING
RCTIME.
P
REDICTING THE RETURNED VALUE
.
.

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

Table of Contents