Reflective IR, wheel encoders, cliff sensors and other applications.
rwgast_logicdesign
Posts: 1,464
[FONT=arial, sans-serif]So the other day I printed out some encoder wheels on my laser printer, and gathered up a few items that worked as transmissive wheels i.e. the kind of wheel used with a slot interrupt I then wired up three different sensors from Vishay to a scope, two reflective style, a CNY70, a TCRT5000, and a slot interrupt TCST1103, with 1mm aperture. [/FONT]
[FONT=arial, sans-serif].[/FONT]
[FONT=arial, sans-serif]I basically wired each one up so the emitter LED drew 40mA, which is a bit under the max forward current for each sensor, then I tested both 5v and 3.3v to the photo-transistors input, on its output I connected a 10k pull down and .1uf decoupling (this helped the noise quite a bit). So I found that all the sensors work much better at 5v than 3.3v and I also found the faster the encoder wheel spins the closer the signal is to a square wave. I tested all the sensors with the scope set at 10ms and 500ms. It also seems that the transmissive interrupter gives a much nicer signal than the two reflective sensors. [/FONT]
[FONT=arial, sans-serif]Although the the interrupts work best I have decided on using the CNY70 reflective sensors for my encoders. I made this decision because the CNY70 not only seems to give a cleaner signal than the TCRT5000 reflective sensor but also has a shorter range allowing me to use the TCRT5000 for other applications. I did not want to use the interrupters because mounting a transmissive wheel would be much more work.[/FONT]
[FONT=arial, sans-serif]Testing the reflective sensors did raise a few issues though, mostly things I was not expecting, this is where I am hoping some one can enlighten me.[/FONT]
[FONT=arial, sans-serif]Issue #1 is ambient light, and ways of dealing with it. This probably goes hand and hand with cleaning up the signal at slow RPM. These sensors all claim to filter out ambient light, but originally my low logic was showing up at 2v, I had these sensors on a breadboard on my bench, over head is a 20W incandescent light. When the sensor was suppose to be low the scope was showing a sine wave looking signal with a peak to peak of 2v and 1.5v, not even a steady 2v. When I flipped the lamp off the problem was solved. So what I'm thinking about is either using a physical shield to help block light, or doing it in software. I figured I could hook the photo transistor up to an ADC/RC Time and use that to set the logic thresh holds, I'm not sure if that is a good idea though due to speed. I am trying to read 1,860 transitions per second, per channel. So the ADC and the code would have to keep up with this. The final way to do this may be to use a comparator but I don't know much about this nor do I have comparators on hand but do have LM358s that can act as a comparator The other issue I have with a comparator solution is I am trying to keep the hardware minimal.[/FONT]
[FONT=arial, sans-serif]The next issue with these reflective sensors is there range. I had ordered 20 TCRT5000 planning to use them for line following, cliff/edge detection, and.hopefully object detection. At the time of ordering I did not realize these sensors had a 3mm range . I have seen a lot of "line following modules" using these sensors on line, so I figured they would work fine. I would be happy to get about an inch out of them if that is possible.. 3mm is not enough clearance under a robot. The BOE Bot book says that it's IR LED/Modulated IR receiver can detect objects up to a few CM away, Is this due to the fact it is using bigger separate LEDs/Receivers or is it because of the 38khz modulation? Basically I'm just trying to figure out the best set up for longer range IR having plenty of sensors, LEDs, Receivers and photo transistors.
Here is an example of the sensor set up, and ambient light that was causing problems:
[/FONT]
Also, oddly these original encoder wheels did not work, they kept the sensor hi the whole time. I drew them with a sharpie, I was under the impression sharpie ink would absorb IR?
Here are the data sheets for the three sensors I used:
CNY70 .5mm Peak detection, will be used for encoders
TCRT5000 2.5mm Peak detection
TCST1103 Interupt
[FONT=arial, sans-serif].[/FONT]
[FONT=arial, sans-serif]I basically wired each one up so the emitter LED drew 40mA, which is a bit under the max forward current for each sensor, then I tested both 5v and 3.3v to the photo-transistors input, on its output I connected a 10k pull down and .1uf decoupling (this helped the noise quite a bit). So I found that all the sensors work much better at 5v than 3.3v and I also found the faster the encoder wheel spins the closer the signal is to a square wave. I tested all the sensors with the scope set at 10ms and 500ms. It also seems that the transmissive interrupter gives a much nicer signal than the two reflective sensors. [/FONT]
[FONT=arial, sans-serif]Although the the interrupts work best I have decided on using the CNY70 reflective sensors for my encoders. I made this decision because the CNY70 not only seems to give a cleaner signal than the TCRT5000 reflective sensor but also has a shorter range allowing me to use the TCRT5000 for other applications. I did not want to use the interrupters because mounting a transmissive wheel would be much more work.[/FONT]
[FONT=arial, sans-serif]Testing the reflective sensors did raise a few issues though, mostly things I was not expecting, this is where I am hoping some one can enlighten me.[/FONT]
[FONT=arial, sans-serif]Issue #1 is ambient light, and ways of dealing with it. This probably goes hand and hand with cleaning up the signal at slow RPM. These sensors all claim to filter out ambient light, but originally my low logic was showing up at 2v, I had these sensors on a breadboard on my bench, over head is a 20W incandescent light. When the sensor was suppose to be low the scope was showing a sine wave looking signal with a peak to peak of 2v and 1.5v, not even a steady 2v. When I flipped the lamp off the problem was solved. So what I'm thinking about is either using a physical shield to help block light, or doing it in software. I figured I could hook the photo transistor up to an ADC/RC Time and use that to set the logic thresh holds, I'm not sure if that is a good idea though due to speed. I am trying to read 1,860 transitions per second, per channel. So the ADC and the code would have to keep up with this. The final way to do this may be to use a comparator but I don't know much about this nor do I have comparators on hand but do have LM358s that can act as a comparator The other issue I have with a comparator solution is I am trying to keep the hardware minimal.[/FONT]
[FONT=arial, sans-serif]The next issue with these reflective sensors is there range. I had ordered 20 TCRT5000 planning to use them for line following, cliff/edge detection, and.hopefully object detection. At the time of ordering I did not realize these sensors had a 3mm range . I have seen a lot of "line following modules" using these sensors on line, so I figured they would work fine. I would be happy to get about an inch out of them if that is possible.. 3mm is not enough clearance under a robot. The BOE Bot book says that it's IR LED/Modulated IR receiver can detect objects up to a few CM away, Is this due to the fact it is using bigger separate LEDs/Receivers or is it because of the 38khz modulation? Basically I'm just trying to figure out the best set up for longer range IR having plenty of sensors, LEDs, Receivers and photo transistors.
Here is an example of the sensor set up, and ambient light that was causing problems:
[/FONT]
Also, oddly these original encoder wheels did not work, they kept the sensor hi the whole time. I drew them with a sharpie, I was under the impression sharpie ink would absorb IR?
Here are the data sheets for the three sensors I used:
CNY70 .5mm Peak detection, will be used for encoders
TCRT5000 2.5mm Peak detection
TCST1103 Interupt
Comments
It just so happens that I've been playing with opto stuff trying to do some white line following.
I started with a uv reflective device with a specified range of only a couple of mm. In the end I gave up. I could get them to work under IDEAL conditions but in the real world keeping the system a couple of mm off the ground was toooo problematic. I was able to get a full logic swing, and even tried adding another transistor as an amplifier, and also a darlington arrangement, but whatever I tried it was millimeter sensitive. I think in a 'precision' setup in say a printer then they will work fine. Yes background light does effect them. Now my application is not to monitor a rotating disc painted white and black, but I think if the 'white' was reflective metal the results would be better, ie start with a shiny mirror like disk (polished plated metal) and then paint matt black segments, and shade from surrounding light and you would get best results.
For my white line following I just happened to come across http://learn.parallax.com/node/261 !
Well I just had to try this! A phototransistor, resistor and capacitor and it works like magic. MUCH easier to get reliable results.
Now I was a bit frustrated because I had NO phototransistors - and you know how it is - you just HAVE to try it and NOW!
Then I remembered having some old BC107/8 in a box somewhere - they happen to be made in metal cans not the plastic packages we see these days. Found them, sawed the tops off and vwalla! worked beautifully
(Put some cellotape over the open end.)
It takes about a millisecond or two to get a result- you can adjust this to your needs by changing the capacitor - or leaving it off altogether!!
Not quick enough though for your disc segment counting I dont think.
Dave
[FONT=arial, sans-serif]As for line following, edge detection, I wont even waste my time trying to make them work, now that you have told me this! Guess ill have to figure out what to do with a pile of reflective sensors. I would have been fairly annoyed if I purchased a line following module with 5 or 6 of these sensors only to realize they needed to be mm's from the ground! I looked up the specs on these pre-made modules using TCTR5000s and none of them listed the range!! So you are using unmodulated IR for line following, by cutting the top of a transistor? How well does this work, as far as range? I know most of the Parallax tutorials on this use a 38Khz receiver in order to filter ambient light, I am surprised to see that article is using a plain old photo transistor.[/FONT]
The CNY70 not only can be bought, it comes in a version that does NOT require surface mount. So until you really find a need to upgrade, it is a good one.
Well, actually I'n NOT using IR any more just a white led for each sensor as light source, with a phototransistor. The led is driven with only abot 10ma and it works beautifully. As for range, well I replaced the IR version with the new version and so the distance I changed to about 1/4 inch off the ground. I KNOW I could make it work up to an inch easily but then other things come in to play. For instance the transistor would need to be shielded to stop it 'seeing' too wide a field; even sitting in its metal shell the transistor has quite a wide angle of view; at one inch I would put a sleeve around it to limit this. Also the capacitor will take longer to discharge, so a brighter led or perhaps a lens? It is quite capable of measuring tiny amounts of light, but time to discharge is the limiting factor.
Also this system is time wasting in as much as you have to measure the time it takes before the voltage drops to the threshold value for the port pin, so its needs continual monitoring. It would be much more convenient to just read an a/d value.
At the moment I am stepping at 4ms per step. At this rate it will start and stop without using acceleration and not missing a step. Each motor is only on or off, forward or backward, nothing sophisticated. In between each step I read three line followers all counting at the same time. It does this easily in 4ms, ie if the capacitor has not discharged to threshold in 3ms then I deem there is no line, otherwise there is a line. Any simple 'thinking (decisions)' has do be done within this loop. Cleverer stuff will require it stops to cogitate.
At 4ms a step and with a 3 inch wheel its rather slow- and this is at 10v. Still, its not entering any competitions - just giving me hours of fun
This is my first stab at a small robot, but I will make the next one smaller.
I quite like the idea of tiny robots carrying out tasks, working on a matrix of lines for navigation, co-operating and avoiding each other. Say like a small industrial scenario robots, busily going about their business, resting, recharging and informing the master controller with cheap bluetooth or 24L01 radio.
I also have this idea to solve mazes. The robot has a 3.5 inch colour display on its top showing the route its picked up as it goes along. The radios and display all works it just a matter of finding the time.
I have to say this message-board is a wonderful place to pick up ideas - the display and motors came from here. What next I wonder?
Dave
Learned that a transistor does not mean digital. I just did not know this at the time.
Built the Schmidt trigger just to say I did it.
http://www.play-hookey.com/digital_experiments/multivibrators/rtl_schmitt.html
Then built a simple comparator like the LM339 with hysteresis. I learned a lot during this process.
Learned that IR stuff is USELESS out doors. In the sun in the house behind glass is NOT the same as in the sun on the deck.
Threw the whole mess in a drawer to teach my kids someday and went with the Melexis Hall Effect sensor and never looked back.
Well as far as I recall, a schmidt trigger is rather like a comparator, but, it switches to the input signal at a different level, depending on whether the input signal is going from low to hi, or high to low; that is once it has already switched in one direction the input signal will have to make a significant change, to change the output back. This effect is called hysteresis. For example it could be adjusted in a 5v systen to switch at 3 v going low to high but at 2v going from hi to low. This if you think of it makes it less sensitive to any noise that might be on the signal. It does this with a touch of positive feedback. Some ttl chips have schmidt inputs; buffers if I recall like 244/245. So if you hade a noisey ac signal going in you get a nice clean square wave coming out. (in theory)
Dave