Homemade Laser Rangefinder
October 28, 2008
My laser range finder got a lot of interest so I thought I'd try to explain it in more detail.
It's not finished yet as it still needs to be mounted on it's stepper motor with a home position switch.
The sensor side has been tested on an oscilliscope. When I moved my hand in front of it, the pulse width varied to match. Below is a diagram showing how the sensor works.
On the underside of the cpu fan is a small piece of a blank cd glued to the centre of the fan. This spinning mirror directs the laser (5mW red) around the room. The small black tube at the upper right is a phototransistor with a piece of heatshrink on it so it only detects light from in front of it. This signal is amplified by a couple of transistors and mixed with the tacho output from the fan to give me a pulse with a width that represents the angle of the mirror when the phototransistor was hit by the beam. The chip at the top is a "D" type flip flop that is used to mix the tacho signal and the pulse from the amplifier.
As you can see, the closer the object, the sharper the angle of the laser. This isn't how the commercial units work, I couldn't find anything on how they worked. because of the way this works the output is logarithmic.
This means that close up, the resolution might be a couple of mm's but further away it will be in cm's.
Resolution can be improved by increasing the distance between the spinning mirror and the phototransistor but may reduce the overall range. I'm not certain why the range is so limited, I was expecting to pick up objects up to 4 or 5 meters away (about 15 feet). I noticed that commercial units have a fairly big lens at the front so I suspect it needs glasses (it's short sighted like it's creator ha ha).
Despite it's range limitations (at the moment) it has the advantage of being able to detect chair / table legs more accurately. These have always been the nemisis of robots using sonar and infra red.
For those using picaxe basic this is easy to use with the pulsin command doing all the hard work. Higher proccesor clock speeds will also increase resolution.
At the moment I'm using a BPV11 phototransistor from Dick Smith Electronics as the beam detector. It's very sensitive to red and infrared light. It just has a piece of black heatshrink on it at the moment so that it can only dectect light directly in front but later I will mount it in a seperate case if I can find a suitable lens to increase it's range.
LASER RANGE FINDER MADE EASY!
For anyone interested in making they're own laser rangefinder I've stripped down the original schematic to make it easier to understand and to adapt to your own robot. You can use any processor, laser and spinning mirror you want. See the attachment for a full sized schematic.
The power supply with +3V for a laser is optional, you may already have a suitable supply and/or a laser that needs a different voltage.
The Amplifier with sensor is the really important bit, I've simplified it a bit from the original. If you can't get the exact components, don't panic! The transistors are just general purpose NPN and PNP transistors with a hfe of about 400. This amplifier just boost the pulse from the sensor into a sharp on/off pulse, nothing fancy. I did try a third stage originally but found I was getting too much noise. If you end up using a different phototransistor than the BPV11 you may have to change the 10K resistor in series with it.
The Mixer, I've shown two different variations of the mixer because the tacho on my fan gave out 2 pulses per revolution. The flip-flop in option (a) divides this down to 1 pulse per revolution with the output of the amplifier cutting the pulse short in response to detection of the beam. Option (b) is for spinning mirrors of your own design that would probably only give one pulse, from positive to ground and back to positive again.
The Output to the processor is a pulse of variable width, picaxe basic users can just use the pulsin command to do the hard work.
You'll notice that I have a 12V cpu fan running on 5V, this isn't just to make power supply issues easier, it's to slow the fan down. The slower your mirror spins, the wider the pulse, the more resolution you get. Between 20 and 60 revolutions a second (120-360rpm) is ideal as long as the mirror spins at a constant speed. Some motors may get a bit jerky at slow speeds in which case you should use a gearbox for low rpm.
If you are making your own spinning mirror then make sure your mirror is a high grade, toy mirrors are crap, the easiest solution is to cut out a piece of a blank CD/DVD about 10mm square. You can go bigger but the heavier it gets, the more it will vibrate if it's out of balance (and another reason that slow speed is good speed).
I used a stepper motor to rotate my whole assembly around for scanning because it was cheap and didn't require a constant signal from the processor to maintain position however a servo works just as well or you might just scan forward and rotate the robot on the spot (easy to do with skid steer).
Hope this helps :)
I did a few experiments which I briefly covered in boozebot's update. This was the first time I was using a picaxe and not just the oscilloscope to measure the mixers output. I've been trying to improve the range of the laser rangefinder.
The oscilloscope is measuring the output of the amplifier. I was using debug in the picaxe basic editor to monitor the distance of my hand but the white sceen in the background was messing with the camera.
As you can see, I'm extreemly jealous of Rik's new setup. The rangefinder with it's new monacle is balanced precariously on the front of the keyboard tray while the keyboard is hanging on for dear life at the back!
The picture that you can't make out is Leela from futurama drawn Tomb Raider style!
Anyway, enough of my jealousy and perverted taste, back to the laser rangefinder!
As you can see, I've got a 60mm magnifying glass taped to the front of a cardboard tube and mounted the phototransistor at the focal point. This does work better but I have to work on aligning all the optical components. I need to get the phototransistor / lens in line with the laser. At the moment moving the PCB up and down or tweaking the laser up and down affects the distance it can detect. I did get it to pick up a white object at about 2 meters but with some adjustments to both the optical alignment and the amplifier I think I can increase the range to a useful 3 or 4 meters.
The optical setup I've got here is probably bigger than I need but it was what I had laying about.
During this test (aside from things falling off) I noticed that turning off the lights reduced the range. With the oscilloscope on the first stage of the amplifier the signal from the phototransistor dropped off dramatically. I realised this was because with the base pin cut off of the phototransistor the only energy turning on the transistor was the photons hitting it. I tried biasing another phototransistor that didn't have thebase lead cut off but rather than boosting the signal it swamped it. Even with resistors in the megaohm range it did more harm than good plus all this high impedance circuitry connected to the base was picking up electrical interferance.
The upshot of all this sofar is that I'm going to mount some high intensity red leds inside the cardboard tube where they won't block the light coming in but will ensure a minimum amount of light hits the phototransistor. The reason for the red LED's is that the phototransistor is only sensitive to red and infrared light. By adjusting the intensity of these LED's I should be able to achieve optimum sensitivity in any light condition and my robot will have a glowing red eye just like the terminator. I suppose the scanning laser is the other eye (like the borg). Hmmm will Boozebot (a) get me a beer, (b) steal my clothes and bike or (c) assimilate me. Only time will tell.