Specifications

BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 301
2
with R = 10k pot and C = 0.1µf. Connect the circuit to pin 7 and run the
program. Adjust the pot and watch the value shown on the Debug
screen change.
result var word' Word variable to hold result.
again:
high 7 ' Discharge the cap
pause 1 ' for 1 ms.
RCTIME 7,1,result ' Measure RC charge time.
debug cls,dec result ' Show value on screen.
goto again
Demo Program 2
This program illustrates the use of RCtime as a sort of fast stopwatch.
The program energizes a relay coil, then has RCtime measures how
long it takes for the relay contacts to close. Figure I-15 shows the hookup.
In a test run of the program with a storage oscilloscope independently
timing the relay coil and contacts, we got the following results: RCtime
result = 28 units (56µs); Oscilloscope measurement: 270µs. The 214µs
difference is the time required for RCtime to set up and begin its mea-
surement cycle. Bear this in mind—that RCtime doesn’t start timing
instantly—when designing critical applications.
result var word
again:
low 6 ' Energize relay coil.
RCTIME 7,1,result ' Measure time to contact closure.
debug "Time to close: ", dec result,cr
high 6 ' Release the relay.
pause 1000 ' Wait a second.
goto again ' Do it again.
+5V
pin 6
relay
contacts
pin 7
+5V
relay coil
10k
Relay: 5Vdc reed
relay with 20mA
coil, e.g., Radio
Shack 275-232
Figure I-15