Parallax Boe-Bot Student Manual page 223

Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

. The
command is designed to measure RC decay time on a circuit like
RCTIME
RCTIME
the one in Figure 6-10. Here is the syntax for the
RCTIME Pin, State, Duration
The
argument is the number of the I/O pin that you want to measure. For example, if
Pin
you want to measure P6, the
be 1 or 0. It should be 1 if the voltage across the capacitor starts above 1.4 V and decays
downward. It should be 0 if the voltage across the capacitor starts below 1.4 V and
grows upward. For the circuit in Figure 6-10, the voltage across the capacitor will start
close to 5 V and decay to 1.4 V, so the
argument has to be a variable that stores the time measurement, which is in 2 µs units. In
this next example program, we'll measure the RC decay time on the photoresistor circuit
connected to P6, which is the photoresistor on the Boe-Bot's left.
To measure RC decay, the first thing you have to do is make sure you have declared a
variable that will store the time measurement:
timeLeft
VAR
These next three lines of code charge the capacitor, measure the RC decay time and then
store it in the
timeLeft
HIGH 6
PAUSE 3
RCTIME 6,1,timeLeft
To get the measurement, the code implements these three steps:
1. Start charging the capacitor by connecting the circuit to 5 V (using the
command).
2. Use
to give the
PAUSE
RC circuit.
3. Execute the
RCTIME
decay time (from almost 5 V to 1.4 V), and stores it in the
Example Program: TestP6Photoresistor.bs2
Reconnect power to your board.
Enter, save, and run TestP6Photoresistor.bs2.
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 209
argument should be 6. The
Pin
State
Word
variable.
command enough time to charge the capacitor in the
HIGH
command, which sets the I/O pin to input, measures the
command:
RCTIME
argument can either
State
argument should be 1. The
timeLeft
Duration
HIGH
variable.

Advertisement

Table of Contents
loading

Table of Contents