View Full Version : Simple Photodiode On/Off circuit
bodgetts
- 4th August 2011, 05:22
I have a photodiode that I will be hitting with a laser diode, and I need to be able to determine when I have hit the 'target'.
What is the simplest way to do this with a PIC? ie. Can I hook it up with just a pull-up resistor in a similar fashion to a simple button input? I only need to know when it is on and off.
Thanks
sayzer
- 4th August 2011, 07:36
I have a photodiode that I will be hitting with a laser diode, and I need to be able to determine when I have hit the 'target'.
What is the simplest way to do this with a PIC? ie. Can I hook it up with just a pull-up resistor in a similar fashion to a simple button input? I only need to know when it is on and off.
Thanks
Yes, as you said, it would be one of the simplest ways to do it.
Instead of a pulll up or pulll down resistor, use a trimmer pot to adjust the voltage level on the PIC pin when there is light on LDR.
And for the code, use a delay routine to avoid false readings from ambient light(s) or sudden flashes.
readitaloud
- 4th August 2011, 09:02
Bodgetts
There are a lot of ambient noise sources these days. TV remotes use a modulation frequency of around 53 KHz to modulate their controllers light source. An "on" signal is actually modulated light. Very long code sequences of the mfg's choosing are used for differentiating button functions. The code sequence is unnecessary for your application. You may want to modulate the laser on/off at some carrier frequency. Use some form of limiting after the detector. Feed the output of the limiter A/C coupled into one of the PIC timers to correlate correct modulation frequency. If you come up with the correct count after integrating over a period of time then you can say you have hit the target.
- Martin
bodgetts
- 5th August 2011, 06:33
Ok, the photodiode that I have is tuned for the wavelength of the laser (or close enough).
When I hook the diode up to a multi-meter, the resistance is sitting about 2-2.4 M Ohms. If flash a regular light on it, it doesn't really change. As soon as I flash it with my laser, it jumps up to 4.5-5.2 M Ohms.
Should I be able to make this trigger the PIC input if I use say a 3M Ohm resistor? I have tried this with 3 x 1 M Ohm resistors in series, and I can't seem to get the PIC to recognise the change.
bodgetts
- 6th August 2011, 00:42
If I use a standard LDR, I can use a 1k resistor and detect the difference between light ( < 1k Ohm) and dark, which is in the 10 M Ohm range. I understand that this works because when 5v comes in through a 1k resistor, it will go to the PIC because the 10 M Ohm of the LDR is much higher.
However, the photodiode that I am using has a range of 2 M Ohm for dark/no laser, and about 4-5 M Ohm when the laser strikes it. If I use 3 M Ohm, the voltage that does get through to the PIC is way too low to trigger an input. Any ideas here?
cncmachineguy
- 6th August 2011, 01:50
maybe set it up as a voltage divider, but use the comparater or A/D to decide if it's on or off?
aratti
- 6th August 2011, 02:35
You can use the pic comparator as an amplifier and solve the high impedence problem. See Microchips comparator tips & tricks @ page 31.
Cheers
Al.
http://www.google.it/url?sa=t&source=web&cd=1&ved=0CCgQFjAA&url=http%3A%2F%2Fww1.microchip.com%2Fdownloads%2Fe n%2FDeviceDoc%2F41215c.pdf&rct=j&q=using%20%20pic%20comparator%20as%20amplifier&ei=oJg8TtrBOIiSswbT5uzGBQ&usg=AFQjCNEmw2rXtNAl-HViTP7z0_z8fDfPxA
bodgetts
- 6th August 2011, 08:31
Thanks for the suggestions guys. The problem is that I am going to have 8 targets. If these were all just LDRs, then it wouldn't be an issue and I could hook them up with 1k pull ups and it would be fine.
Because I need so many, I can't really use the comparators, etc of the PIC. Is there a simpler way where I can use these photodiodes on the general I/O pins?
I am also hunting around for some diodes that maybe have a narrow frequency range, so as to only respond to the laser. Then when there is no laser it would be a lot closer to 0 instead of 2 MOhms, etc.
bodgetts
- 7th August 2011, 04:54
Maybe there is another way?
If I measure the voltage coming through the photodiode, it is 4.6v normally, and drops to 4.4v when the laser is directly on it. How could I detect such a small voltage change?
Jumper
- 7th August 2011, 05:36
If you have 8 A/D channels avaliable on your pic you can easily detect a 0.2V change. It should give a difference for aprox 30-40 steps in the reading if you power your pic from 5V.
Disadvantage? YES several - slow and needs you to scan the A/D frequently to detect if the laser is on or not.
External comparators - Cheap, easy to use and fast. Use a potentiometer to set the reference level on one input. Use the other input for the LDR (4.6 to 4.4V signal) and have one comparator for each LDR.
Connect each comparator to a digital pin and then you can read the port to get all 8 values at the same time. You could also try to connect the 8 outputs from the comparators to pins that have interupt function and then you can wait for an interupt to fire and then you know you have a hit on a target.
It all depends what you are trying to make, ambient light can be a problem and there could be better ways to solve your design.
8 LDR targets ... and a laser.. my guess is Laser Tag system or maybe some kind of Laser fence
Any one else up for some guessing?
bodgetts
- 7th August 2011, 08:20
Thanks for the help. I will try your idea with the comparators, as it sounds like the easiest to implement. Can you recommend the best chip for this particular job?
I am making a shooting target game, so when they pull the trigger I will turn on the laser and see if it has hit any of the targets. I will pulse the laser at a slightly different rate each time to stop people cheating.
Jumper
- 7th August 2011, 12:41
LM393 or similar low cost comparator would work. You can also try using a normal OP-amp as a comparator. National have tons of comparators and OPs that will do the job.
What do you mean by "I will pulse the laser at a slightly different rate each time to stop people cheating". Will you have more than one gun fireing at the 8 targets at the same time or??
Jumper
- 7th August 2011, 15:44
Read this: http://www.national.com/an/AN/AN-31.pdf (useful ways to connect an OP-amp)
They have 3 suggested circuits for photodiodes and I suggest you look at them and figure out if you can use them. There is a reason why these circuits are made :-)
bodgetts
- 8th August 2011, 01:36
If I just accepted that when the laser hits the diode that the target has been hit, there is nothing stopping people just using a standard laser pointer and triggering the targets. If they use the proper 'gun', it will pulse say 5-10 times in quick succession, or some other pattern that I can recognize, I don't think people will be able to flash their laser pointer that fast. I also will probably use a slightly different pattern each time.
cncmachineguy
- 8th August 2011, 01:54
If you use different patterns for each gun, you can easily keep score for each player
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.