28125 Parallax Inc, 28125 Datasheet - Page 223

TEXT ROBOTICS

28125

Manufacturer Part Number
28125
Description
TEXT ROBOTICS
Manufacturer
Parallax Inc
Datasheet

Specifications of 28125

Title
Robotics with the Boe-Bot
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
RCTIME
the one in Figure 6-10. Here is the syntax for the
The
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:
These next three lines of code charge the capacitor, measure the RC decay time and then
store it in the
To get the measurement, the code implements these three steps:
Example Program: TestP6Photoresistor.bs2
1. Start charging the capacitor by connecting the circuit to 5 V (using the
2. Use
3. Execute the
Pin
. The
RCTIME Pin, State, Duration
timeLeft
command).
RC circuit.
decay time (from almost 5 V to 1.4 V), and stores it in the
Reconnect power to your board.
Enter, save, and run TestP6Photoresistor.bs2.
argument is the number of the I/O pin that you want to measure. For example, if
HIGH 6
PAUSE 3
RCTIME 6,1,timeLeft
PAUSE
timeLeft
RCTIME
to give the
RCTIME
command is designed to measure RC decay time on a circuit like
VAR
variable.
Pin
command, which sets the I/O pin to input, measures the
HIGH
Word
argument should be 6. The
command enough time to charge the capacitor in the
State
RCTIME
argument should be 1. The
command:
State
timeLeft
argument can either
variable.
Duration
HIGH

Related parts for 28125