Laser Range Finder MkII
2008-11-17 04:07
This is my second attempt at a homemade laser range finder now with video. I nearly gave up after hearing about the Sharp IR sensors but I think this has potential as it focuses on an area the size of a laser pointer spot. The other sensors work on a much larger area. After a lot of frustration I've finally got all the circuitry working properly and hope to have a video posted as soon as I work out one last difficulty. Click on the photo for a full sized image. This is a work in progress, not a finished product. I hope that by posting this blog I'll encourage you to experiment with the idea and hopefully you can suggest ways for me to improve it. I've now atached the subroutine used to test the scanner. It assumes only one object in scanning range and averages results.
This is the PCB which is 47mmx72mm (1 and 7/8" x 2 and 7/8"). I've attached the latest schematic for anyone interested. You will see I've crammed a lot into this little board.
Originally I designed this with a Picaxe 08M but have upgraded to a 14M. The increased ability to work 4 servo's makes it a small robot in it's own right and well worth the small increase in price.
This circuit could be made smaller and easier to program and build if you use a servo to aim the laser. You can then eliminate the hall effect sensor, it's amplifier and the laser scan motor control circuit. The down side is your resolution is limited by the servopos command to a range of about 100. This might still be a good place to start and I've included this version of the schematic as well.
I've opted to effectively make my own servo using a hall effect sensor for positional feedback. With its output amplified to give me almost 0V-5V output over the entire range of movement of the laser I effectively get 10x the resolution using the readadc10 command.
Word of warning to anyone making either version, a regulated 5V supply is critical for the phototransistor amplifier. I spent many hours trying to workout why the amplifier worked in the begining but not after I sorted out a few other problems with unrelated parts of the board. My batteries were getting flat and at that stage I was not using a regulator. The 4.7V was fine for the picaxe and all the other circuits but the biasing voltage on the amplifier transistors had dropped enough so that only the strongest signals registered. I recomend using a LM2940CT low dropout regulator, they are more expensive but will give a steady 5V even when your batteries are down to about 5.5V.
While on the subject of the phototransistor amplifier, I should mention that it needs a pulsating laser to register due to the coupling capacitors linking the stages. For this reason I have the laser fired by the same PWM output that drives the scan motor with a frequency of 4KHz. I found this was about as low as the picaxe would go and made it easier in the code to change dutycycle. with the period se to 249, the dutycycle in the code was 10x higher, e.g. 50% was 500.
Because PWM and servo commands use the same timer, you have to turn off the servos while the laser operates and turn the PWM off when operating the servos. Please feel free to suggest any improvements / changes. since the frequency and dutycycle aren't critical for the laser, it just needs to pulse at around 10%-50% duty cycle. I feel there is room for improvement.
This the sensor head for the MkII and my one remaining problem. I've tried to keep this as small as possible. I'm using a turret gearbox and motor from a tabletop remote control tank. I'm using a hall effect sensor (see the component section) and a small magnet (3mm dia. 2mm long) to monitor the angle of the laser.
My current problem is that the laser moves too quickly and when I drop the pwm dutycycle enough to slow it down, the motor stalls.
I'm presently trying to fit a more powerful motor from a toy helicopter so I can keep the small gearbox
For those of you who want to attempt the more complicated version of this, I suggest trying a mini servo such as the Hextronik HXT900 which are quite cheap and have a more powerfull motor.
Convert it to continuous rotation, remove the control circuit so you just have a small motor/gearbox and then mount the laser and hall effect sensor.
No matter what gearbox you use, you need to be able to scan the laser through about 45-60 degrees slow enough for the picaxe to register all 1000+ positions that your ADC/sensor setup is capable of producing. For example, if you are rotating your laser over 60 degrees then 30rpm would still be three scans a second considering you can scan just as well clockwise as anti-clockwise. If your using a faster processor or programming a pic in it's native risc language then you can probably scan a lot quicker.

This is my upgraded gearbox, the new motor should hopefully handle lower RPM without stalling. This huge monster is all of 16mm long compared to the 12mm of the previous motor and a whopping 1mm wider than the 6mm of the old motor. Hmm... that was exciting :(
Good news, the bigger motor can run at about half the speed of the original. Still started with a dutycycle of 8% with the laser mounted. This might work yet.
Make certain your phototransistor is aligned with your laser or your rangefinder will be short sighted. This is how it should look side on.

I think this was a problem I had with the first model and was made worse to some extent when I added a lense because I then had more optical components to align.
Updated 18/11/08
Was doing some test and rediscovered / confirmed that background light improves the sensitivity of the photodiode. I have tried previously to use the base pin on the phototransistor to bias it so as to improve sensitivity but with no success. I'm now looking at using an IR led to boost sensitivity.
I also discovered that a glossy object at the point of most sensitivity caused the oscilloscope waveform to vibrate in response to the slightest sound/vibration. This must be how those spy systems work where they shine a laser onto a window and listen in on conversations. I would have videoed this but my video quality isn't good enough to show the results on the oscilloscope.
I've uploaded two videos, still haven't got them to display properly so I've added the links below and a forum asking for help with the video. This is the first time I've made/posted videos so please be patient.
The first shows the signal from the sensor/amplifier that is feed to the digital input of the picaxe.
The second video shows the laser scaning and an object being detected.
Updated 19-11-08
I'm not getting the range or resolution hoped for. I think range is an alignment issue so I'm going to build a more precise sensor head with the ability to calibrate the alignment. As for the resolution, some of this is just a matter of calibrating the hall effect sensor amplifier.
20-11-08
I've recently added the datasheet for my phototransistor but I've realised that they are not easy to find and other phototransistors may not work with this circuit. This is where I got my phototransistors from, I believe they do ship internationally although that might be expensive.
Although I'm quite happy with my phototransistor / amplifier my biggest problem is mechanical. Optical alignment is very important but also precision movement / position sensing is critical for accurate range finding with good resolution.
I think the MkII has gotten as far as is worth pursueing but has been very educational.
Thanks to previous work done my Mintvelt on object tracking and BOA's comments on potential flaws in this design I now have a MkIII design to start building which should be able to track an object as well as determine range. Poor Junior and BoozeBot will never get finished at this rate.
Keep an eye out for the MkIII.
- OddBot's blog
- Login or register to post comments

Nice!
I can;t wait to see the final result.
Did you have any diffuculties alligning the laser and the transistor? I don't know what range you have in mind, but I can imagine that if you're aiming for a range of 60 to 100cm you need to align it pretty precise.
Alignment and range
I'll be happy with a meter range but with perfect alignment you should get more.
I'm still thinking about your idea for object tracking. That was brilliant. I can't afford those sharp sensors, they're expensive over here but I might be able to get a version going using my IR version of Fritz's LDR. I hope to post some videos soon but all my projects are suffering setbacks.
In your schematic, did you
Batteries
AA is the size of the battery I'm using and NiMh (Nickle Metal Hydride) is the cemistry of the rechargable battery as opposed to NiCd (Nickle Cadnium). In the schematic I'm showing the battery used by Junior.
Overall it doesn't matter greatly what batteries you use.
What moves?
Is it still the case (as per the mark I) that the laser moves relative to the photosensor? This principle, I understand.
In the photo, it looks like the laser and teh sensor both pan. No. That can't be right. Surely the photo sensor is fixed, yes?The whole head is then mounted on a scanning servo?
Thinking too deeply
I think more consistent results might be achieved by moving the laser and the detector by equally sized opposite amounts.
...but it's late at night and my imagination it becoming fatigued...!
Movement and reflection
The laser rotates while the sensor is stationary.
If you setup a laserpointer and point it at a chair for example, you can see that dot from a wide range of angles because the chair scatters the beam in all directions.
A mirror or a glass on the otherhand may be a problem as they will tend to redirect the beam rather than break it up and scatter it.
So far this has worked with me moving the laser by hand, my only difficulty now is scanning the laser through about 50 degrees slowly enough for the picaxe to take advantage of the high resolution feedback of the hall effect sensor.
I should have some video in the next 24hrs if all goes well.
Gave it some more thought
Indeedy
Can you post a video of this
I'm trying, it's uploaded but...
Having technical difficulties. When I pasted my video details into this post I got some weird stuff, including the trailer of the Pink Panther and an old dude in his underwear speaking in spanish?
P.S. if you look at the picture of the sensor head the laser is the one in the brass fitting, this is mounted on the gearbox so that the laser rotates. The fist video has the scan motor disabled so you'll have to wait for the second video.
Hmmm... think I broke this blog, it won't respond to my attempts to attach video. It'll have to wait till tomorrow.
do you have a sample code
Still working on it
At this stage problems with alignment and scan motor speed are my biggest problem and are making it difficult to write good code. This is not a finished product as I mentioned at the start.
I'll attach my subroutine for the test scan. Since the laser may be detected in more than one position it averages out the results assuming a single test object. Because of this the readings will be erratic if it detects more than one object.
I hope you haven't gone to too much trouble with the PCB as the design may change yet and the schematic has changed so that when the motor gets a 10% dutycycle the laser gets 90%.
Since you say you have made the PCB already I'll post a schematic showing a shortcut to save you changing your board.
I modified it to use a
I modified it to use a ATMega8 instead, as I was using this as my main board, and I tested it with some basic "send" "recieve" commands, I also used an onboard H-Bridge as I didnt use servos either (I never like voiding warranties to make continuous rotation servos), I also took out the hall effect sensor socket with the 3130 chip, as I felt that was unecessary. And I added UART compatability, so overall your schematic helped me a bunch. The code as well was very useful, I dont use PIC, and I integrated this onto my board. But ATMega8 has only 8kbits Flash and .5EEPROM, I think the Picaxe 14m is higher, but I'm not sure. Once I finish incorporating this into my new project I will post of a picture or two.
I've learned loads from you though mate
The phototransistor amps are giving me problems... :/
No problem mate
At anyrate I've update the schematics. The modified version shows what to do if your PCB was made based on my old schematics where the motor and laser had the same dutycycle.
If your phototransistor amp is playing up, a couple of questions?
1. is it the same phototransistor?
2. are you getting aprox. 0.6V between the base and emitter of both NPN and PNP transistors. This "bias" is set with the 150K and 1M resistors. I used metal film resistors for greater accuracy. You may need to replace the 150K resistor with a 120K and a 50K pot to fine tune this.
3. do you have a stable 5V supply to the amp as this will affect the transistor bias. Even 0.2 deviation could affect the bias voltage of the transistors.
4. are the transistors in the right way? I nearly put the PNP in back to front.
5. what laser are you using, it's wavelength must be within the phototransistors range of sensitivity.
the laser is 5mw 650nm and
the laser is 5mw 650nm and the phototransistor needs a supply of .4v and rise and fall is both 15u, thats all the information I could find on them, I got it here
I tested everything on my multimeter and the supplied voltages are correct
EDIT: Ahh I did not have a seperate power supply for the amp, that is what your saying, no?
Directly on my board I am giving regulated 4.8v (/w 5v regulator), I will replace the supply later and see if the result varies, thanks again mate
You should try using EagleCAD to make some of your schematics, you can convert it into a board file, and then make one at home or order one for less than 10 dollars, saves alot of time
Transistors
I've heard about eagleCAD, will have to look into it.
As for your troubles, I couldn't find the datasheet for that phototransistor. If it has a base lead, make sure it's disconnected. I've attached the datasheet for the phototransistor I used. I chose this one specifically for its spectrum of sensitivity as well as overall sensitivity.
The amp does need a stable power supply so that the transistor bias is stable. 4.8V is ok if your getting 0.6-0.65V at the transistor base. The idea is that the transistors are just on so that the slightest signal from the phototransistor is amplified. I've made this circuit 3 times now, once on a bread board and the supply was the only thing to cause me trouble.
The laser sounds perfect, its slightly longer wavelength should help as most photo transistors are sensitive to IR. 5mW is probably the ideal power, it gives you better range without being too dangerous, just don't shine it into anyones eyes.
Keep experimenting, at worst you may have to get another phototransistor. Send me a schematic if you need more help.
Thanks for a great
Thanks for a great bolg-entry. Amazing amounts of documentation! Enjoyed the videos as well :)
I don't have any building-time at the moment, but I am looking forward to pick this up - not as advanced, but it will be good knowing from whom I can get to know it all when stuck ;)
I have been trying to make a
1n004 is a power diode 1A 400V
Different component numbers
Thank you for that correction
What is the red squared
What is the red squared thing in the schematic above?
Sorry, forgot to label that
See laser range finder made
this may be asking much, but
http://i99.photobucket.com/albums/l303/_Corrupt_/laser-2.png
Oh and I dont know much about hall effect sensors, but does the placement of these affect the rangefinder's performance,
same thing with the phototransistor amps, should I just scatter them? Or place them randomly?
Looked at your scematic
It looks ok except that you show 3 leds in series with the laser instead of 3 diodes (1N004). These are just to drop the 5V down to about 3V for the laser as each one has about 0.6V drop across it. I'd probably keep the phototransistor amplifier components as close together as possible and away from anything like servos that draw a lot of power and generate noise.
Have you had this working on a breadboard yet? I wouldn't make a board yet unless you have. The results you get from this setup depend largely on the mechanical construction of the sensor head. Range depends on the alignment of optical components as well as power of the laser. Resolution depends on how accurately you can measure the angle of the laser. As I mentioned before a pot (1K-5K) could be used instead of the hall effect sensor and negate the need for an amplifier. I've decided not to go any further until I can make a better sensor head which will possibly require some machined parts.
I'd like to see a photo of your sensor head or at least the parts you intend to use.
Oh I think I made a mistake,
Oh I think I made a mistake, I searched 1n004 everywhere, and could not find anything, so I thought they were something else.
Because I made the things near the motor unit diodes, what are they actually?
Robologist was right
Hmmm, then why are they the
Hmmm, then why are they the pointed up arrow, instead of the downwards one? And in your picture of the actual board, I only see 3 diodes?
EDIT: Here is the Board file
http://i99.photobucket.com/albums/l303/_Corrupt_/LaserRangefinder.png
I am still trying to figure out how to make all wires take the fastest possible route, so it looks less sloppy.