I want to signal condition a phototransistor line sensor output to a digital input.
Although I am using the PIC16F8680 chip, the answer should be valid for most PIC chips. If not, please let me know.
I have designed, built and tested a bank of 8 IR Transmitter/ Phototransistor pairs.
They all return 1.2 to 4.2 volts at 3/8ths inch depending on a light or dark surface below the sensors.
I ultimately want an 8-bit digital pattern where the sensors might react like this when travelling over a black line.
00011000
00001000
00001100
00000100
meaning the robot is drifting off center.
Seems like I have several options:
Lets say I use Port B as an input port.
1. If I just run the sensor inputs to the port, it would seem that I would get what I want; zeros or ones.
2. Could I send the 1.2-4.2 volt signal through some kind of chip like an inverter to "clean up" the signal and only produce 0 or 1? I know an opamp could do this, but that seems like overkill.
3. How about an LED/resistor voltage divider to drop the 1.2 down to 0.7 to make sure I get a zero into the chip at low voltage??
4. I could use ADC, but it seems inefficient to convert the voltage into an 8 bit number just to turn it back into a one or zero.
So what would you do???
Robot Line Sensor Question
-
- Posts: 458
- Joined: Thu Feb 05, 2004 1:01 am
- Location: Minneapolis, MN
- Contact:
If you have 8 ADC inputs available, just use them. Forget about "inefficiency:" the function is free and you haven't indicated that there is any other reason to not do this.
If you don't then use a comparator or an opamp to give reliable 0/1 from your 1.2 - 4V signal.
Beware premature optimization: first get it working, then worry about getting it working well or fast
If you don't then use a comparator or an opamp to give reliable 0/1 from your 1.2 - 4V signal.
Beware premature optimization: first get it working, then worry about getting it working well or fast
Hi there Richard,
If time permits (PIC ADC is fast enough) i would probably use
that. Why? Because the ADC will give you better resolution
on the direction. The reason for this is because the ADC can detect
if one of the sensors is slightly off of the black line rather than
just the two states 'on' and 'off'.
For example, lets say you have 2v out for a black line, and 4v out
for a white line. Well, when the sensor is just over top of the border
between black and white the output might be 3v, so already we have
three states instead of 2 and we havent even gotten to the fact that
the AD has 1024 distinct states! Even if we use only 8 of those bits
(the upper 8 bits) we still get 256 states.
What's the big difference? The main idea is to get as high a resolution
as possible so the vehicle stays on course without jerking back and
forth, and the higher resolution makes this possible. In other words,
it makes for finer tuning of the movements.
Of course you have to have the time to do all the AD converts, which
may take too much time, but i dont know your instruction clock period
or what other tasks your program has to perform or how fast the
thing is traveling.
If you dont have the time for all this then you probably have to resort to
comparators or else use multiple uC's with one master uC.
If time permits (PIC ADC is fast enough) i would probably use
that. Why? Because the ADC will give you better resolution
on the direction. The reason for this is because the ADC can detect
if one of the sensors is slightly off of the black line rather than
just the two states 'on' and 'off'.
For example, lets say you have 2v out for a black line, and 4v out
for a white line. Well, when the sensor is just over top of the border
between black and white the output might be 3v, so already we have
three states instead of 2 and we havent even gotten to the fact that
the AD has 1024 distinct states! Even if we use only 8 of those bits
(the upper 8 bits) we still get 256 states.
What's the big difference? The main idea is to get as high a resolution
as possible so the vehicle stays on course without jerking back and
forth, and the higher resolution makes this possible. In other words,
it makes for finer tuning of the movements.
Of course you have to have the time to do all the AD converts, which
may take too much time, but i dont know your instruction clock period
or what other tasks your program has to perform or how fast the
thing is traveling.
If you dont have the time for all this then you probably have to resort to
comparators or else use multiple uC's with one master uC.
LEDs vs Bulbs, LEDs are winning.
-
- Posts: 3
- Joined: Fri Jun 06, 2008 3:21 pm
- Contact:
Robot Line Sensor Question
Use a bar graph display IC from National Semiconductor. These are generally used for audio volume display.
You might consider some processing before sending the signal to the microcontroller.
One method would be to use two weighted resistor networks, one biased to the left and one biased to the right. The conductance of the resistors (reciprocal of resistance) would be proportional to their position. For example, the left sensor might have a 10 K resistor to the left output. The next sensor would have an 11.7 K resistor to the left output and an 70K resistor to the right output,. The third sensor would have a 14 K resistor to the left output and a 35 K resistor to the right output. The fourth sensor would have a 17.5 K resistor to the left and a 23.3 K resistor to the right. The fifth sensor would have a left resistor of 23.3 K to the right and a 17.5 K resistor to the left. The sixth sensor would be weighted with 35 K to the right and 14 K to the left. The seventh sensor would be weighted with 70 K to the left and 11.7 K to the right. The eighth sensor would be weighted wi 10 K to the right.
Subtract the two outputs. When the line is in the center, the two outputs will be equal, and the overall output will be zero. If the difference is not zero, the polarity will indicate which direction the line is off center and the magnitude will indicate the amount of error.
If two A/D inputs are available, the outputs of the two networks could be digitized separately and subtracted digitally in the processor.
Alternately, an op amp could be used to do the subtraction and the result fed to a single A/D input.
One method would be to use two weighted resistor networks, one biased to the left and one biased to the right. The conductance of the resistors (reciprocal of resistance) would be proportional to their position. For example, the left sensor might have a 10 K resistor to the left output. The next sensor would have an 11.7 K resistor to the left output and an 70K resistor to the right output,. The third sensor would have a 14 K resistor to the left output and a 35 K resistor to the right output. The fourth sensor would have a 17.5 K resistor to the left and a 23.3 K resistor to the right. The fifth sensor would have a left resistor of 23.3 K to the right and a 17.5 K resistor to the left. The sixth sensor would be weighted with 35 K to the right and 14 K to the left. The seventh sensor would be weighted with 70 K to the left and 11.7 K to the right. The eighth sensor would be weighted wi 10 K to the right.
Subtract the two outputs. When the line is in the center, the two outputs will be equal, and the overall output will be zero. If the difference is not zero, the polarity will indicate which direction the line is off center and the magnitude will indicate the amount of error.
If two A/D inputs are available, the outputs of the two networks could be digitized separately and subtracted digitally in the processor.
Alternately, an op amp could be used to do the subtraction and the result fed to a single A/D input.
Who is online
Users browsing this forum: No registered users and 7 guests