multiple photodiode circuit with a single output

Thread Starter

davidhoff

Joined Sep 19, 2008
66
I'm trying to build a circuit that will output a high or low voltage based on the state of 4 photodiodes. The photodiodes have a light shining on them most of the time. I would like the output voltage to change only when all of the photodiodes are blocked at the same time. So if only 1, 2, or 3 were blocked, nothing would change, but when all 4 are blocked, the output voltage would change. I built the circuit below thinking it would work, but the output changes when any of the photodiodes are blocked instead of only when all are blocked. I don't quite understand why this is. I think I might be oversimplifying things in my mind, but I was thinking of the photodiodes as switches that are closed when there is light shining on them, and open when dark. I thought one option would be to use a separate circuit for each photodiode and combine the results with an and gate, but would like some other opinions before I order more pieces I may not need. If anyone can explain why this doesn't work, or suggest something that will work, I would very much like to hear. Thanks for your help!

 

Audioguru

Joined Dec 20, 2007
11,248
A 741 opamp is 43 years old. Its performance is very poor today. It is designed to use a 30V power supply but some work from only 10V. Maybe none will work from only 5V.

If you use a better opamp that has less input bias current and works from a supply as low as only 5V then the circuit will do what you want.
 

Thread Starter

davidhoff

Joined Sep 19, 2008
66
Thanks for the reply. Do you have any suggestions as to what a better opamp might be for this application? There are so many different types that I'm not sure what to look for.
 

wayneh

Joined Sep 9, 2010
17,498
Consider using the LM339 quad comparator instead of any op-amp. It's easy to "OR" the outputs, so that light on any one of the diodes would hold the output low, but dark on all of them would let the output be pulled high.
 

Thread Starter

davidhoff

Joined Sep 19, 2008
66
Are you suggesting that I use one photodiode with each comparator on the chip and then OR the 4 outputs together? If so, how would I OR the outputs? Thanks for the responses, guys.
 

wayneh

Joined Sep 9, 2010
17,498
Are you suggesting that I use one photodiode with each comparator on the chip and then OR the 4 outputs together? If so, how would I OR the outputs? Thanks for the responses, guys.
Yes exactly. To OR the outputs, all you have to do is connect them all together and pull them all up with a single 3.3k resistor. If any one of them goes low, it'll pull them all down. But if they all go high (open), the resistor takes the voltage high. The key is that the comparator output itself never really goes high, it just goes "off". That's why you always need a pull-up resistor. When it goes low, it opens a path to ground.
 

Kerim

Joined Mar 3, 2011
35
In other words, each comparator in LM339 has an open collector output (actually of an npn transistor).
So the output can sink a current to ground but cannot source one.
In case you will need both (sink and source) for some other applications, a quad-opamp IC as LM324 could be used. It is also good for 5V supply.
 

Ron H

Joined Apr 14, 2005
7,063
In other words, each comparator in LM339 has an open collector output (actually of an npn transistor).
So the output can sink a current to ground but cannot source one.
In case you will need both (sink and source) for some other applications, a quad-opamp IC as LM324 could be used. It is also good for 5V supply.
The LM339 pullup resistor can source current. You can't wire OR the LM324 outputs.
 

Kerim

Joined Mar 3, 2011
35
The LM339 pullup resistor can source current. You can't wire OR the LM324 outputs.

You are right, Ron. I forgot to add that when all collectors are not sinking any current, the pull-up resistor lets their common output be raised to a high voltage. And yes, a 3K3 resistor tied to 5V can ‘source’ a current of about 1mA to drive an input port of Vih=1.6V.

On the other hand, I am sorry for adding an off topic statement when I said in my previous post:
"In case you will need both (sink and source) for some OTHER applications... etc"
For instance, the words “sink and source” are meant here for a voltage output of a relatively small internal resistance in both directions.

Kerim
 

Thread Starter

davidhoff

Joined Sep 19, 2008
66

http://img94.imageshack.us/i/photodiodecircuit.png/
Above is the current version of this circuit. It works, but only partly. I get 0 volts when all the sensors are unobstructed, and 5v when they are all blocked. That's the good part. The bad part is that I get 1.2-4 volts (approx) when some are blocked and some aren't. I need it to be a clean jump from 0-5 volts only when all of the sensors are blocked. As far as I understand, this circuit should work, so I guess my understanding is incomplete (what a shock...). Can anybody offer some suggestions about how I could make it do what I want, or explain why it's doing what it's doing now? Thanks for your help.
 

wayneh

Joined Sep 9, 2010
17,498
First of all, you're right - the circuit "ought to" work. So I'm just guessing at some possible problems.

What's the load on the output? That 10k pullup resistor is a bit high in resistance, but that alone doesn't explain the problem.

Do you have a bypass cap across the power pins of the comparator? What's the power source like?

You may be having a problem with chatter, or poor switching, when the inputs are near the setpoint. A little hysteresis (feedback of the output to the input) can help clean that up, but I'm not so sure how to do that when you're ORing the outputs this way.

BTW, you can post your image here.
photodiodecircuit.png
 

Thread Starter

davidhoff

Joined Sep 19, 2008
66
The load is just a volt meter right now. Eventually, it will be an input pin on a micro controller. I don't have any bypass cap. Not sure exactly what a bypass cap is for. Power source is a 12v 1A adapter running through a 7805 5v regulator. The end goal of this setup is that there will be two of these circuits, one at each end of a tube. When a projectile goes down the tube and blocks all 4 sensors at once, it starts the micro controller counting. Then when it passes the second set, it stops it and figures the speed. The sensors are arranged in a grid so the projectile has to be centered in the tube to trip them all, so you only get readings for straight shots to eliminate any difference that would come from the projectile going by at an angle. The reason the application matters is that it needs to trigger very quickly. I had a working setup with photo transistors, but it was too slow to pick up the projectile going about 300 fps.
 

wayneh

Joined Sep 9, 2010
17,498
The load is just a volt meter right now. Eventually, it will be an input pin on a micro controller. I don't have any bypass cap. Not sure exactly what a bypass cap is for. Power source is a 12v 1A adapter running through a 7805 5v regulator.
The bypass cap is a local power source/filter to remove noise from the power pins. It can help with calming many ICs but I certainly don't claim it'll fix this one. But it's easy to try and a generally good idea. Use a 0.1µF ceramic cap as close to the 339 as possible.

Any chance you could put your comparator output on an oscilliscope? I'm not too sure what's going on, but a picture can be ... illuminating.

Wow, 300fps? That's awfully fast, almost bullet fast. Without doing the calcs I'm not sure the 339 can respond that quickly, or even the photo diodes for that matter.
 

Audioguru

Joined Dec 20, 2007
11,248
It might take a very bright light (sunlight) for a photo-diode to conduct (actually it leaks a small current) into a load resistor as low as 10k. Try 100k ohms for each photo-diode.
 

Thread Starter

davidhoff

Joined Sep 19, 2008
66
I tried increasing the resistors hooked up to the photo-diodes to 100k. It seems to have done the trick! I also changed out the 10k pullup for a 4.7k and had to fiddle around with the pot to get it in the perfect spot.
Thanks for all your help!
 

wayneh

Joined Sep 9, 2010
17,498
Hmmm... That's odd. It suggests you might want to try setting the reference voltage of each comparator individually, at least until you can figure out what's going on. Or swap out different sensors until they all behave the same.
 

Ron H

Joined Apr 14, 2005
7,063
I tried increasing the resistors hooked up to the photo-diodes to 100k. It seems to have done the trick! I also changed out the 10k pullup for a 4.7k and had to fiddle around with the pot to get it in the perfect spot.
Thanks for all your help!
I could have sworn I saw a post that said that the 100k resistors did not work, nor did the bypass caps. Did you edit this post?
 
Top