![]() |
|||
Measuring RPM via Photo reflector
Computer
Interface
|
A rough block diagram is shown here. The diode is the IR transmitter and the receiver is the phototransistor. I only show one here for clarity. The microcontroller takes input from sensor array, and drives the servo motors in response. The output of the phototransistor looks like this. The plot here shows the voltage response over time as the sensor travels from black to white (as the robot loses the line). The output voltage drops from about 3.5V on average to about 0.2V in 18 ms. The Atmel Botboard I use on this project has 2 A/D channels via an A/D chip. The data from this A/D chip is read by the Atmel 90S2313 by a serial interface. I use the 2 A/D channels for the left and right sensor. The center sensor I run to the 2313's onboard comparator.
I retrieve the data from the A/D channels as a 12 bit digital value that represents the Voltage. 2^12 is 4095, so if I had 5V input, the A/D would report a value of 4094 (decimal). 0V would be a value of 0. 2.5 V would be halfway at 2047. I read the value, and then compare it to a threshold value of about 2050 or so (a little over 2.5V). If the output of either of the A/D channels goes below 2050 then I call that a "white" value and I call that a 0 output. Above that threshold is black, which is a 1. The center sensor goes to the 2313's onboard comparator. I set the compare or reference voltage with a divider circuit to get 2.5V as a threshold. Then with software I invert the output of the comparator so that a Voltage above 2.5V is an output of 0 (white). Below the ref is a 1 (black). I take a sample every 20 ms or so since that is the fastest the data can change, and make a decision based on a state table of the possible states of the three sensors. This table is shown to the right. State Table L C R Meaning Action
|
||