Reading a photodiode output into a window comparator.

Thread Starter

twosacrowd

Joined Jul 3, 2009
11
002.jpg

Hi, I wonder if anyone could help me with this. I am wishing to indicate three different voltage levels using the attached circuit. I am looking for LED's to indicate a Low, Medium and High condition, so I only ever want one LED on at a time. I thought this circuit would do this for me, but I have conditions where I can have a Low and Medium LED on, or a Medium and High LED on. Am I doing something wrong or have I made a mistake in the design? If anyone can suggest improvements or other designs I would be very grateful thanks.
John
 

bertus

Joined Apr 5, 2008
22,278
Hello,

I have taken your image rotated it (I do not want to turn my monitor to see it), changed white balance (the image was hardly visible) and scaled it down:

twosacrowd_002_corrected.jpg

Bertus
 

Alec_t

Joined Sep 17, 2013
14,337
The LEDs should have sereies resistors to limit their current.
Try connecting pin 11 to 2.5V (using a voltage divider between the power rails) instead of to the pot wiper.
 

Thread Starter

twosacrowd

Joined Jul 3, 2009
11
The LEDs should have sereies resistors to limit their current.
Try connecting pin 11 to 2.5V (using a voltage divider between the power rails) instead of to the pot wiper.
Thanks for your reply. And appreciate your editing of the document. I am using the 33 ohm as my LED current limit. I need the option of varying the thresholds and that is why I am tying pin 11 to the wiper. I need a variable window to illuminate the centre LED; but I get the condition of a certain times middle and upper or middle and lower LED's are on. I must be doing something wrong but don't see what it is. Any further assistance greatly appreciated ?
 

Alec_t

Joined Sep 17, 2013
14,337
I need a variable window to illuminate the centre LED
You need only the two adjustable threshold voltages you already have in order to define the variable window: the low and the high thresholds established with the two pots. That is why I suggested 2.5V as the reference for the third opamp. Try it, and see if it cures the problem.

Edit: You could also try adding a resistor (~100k) from pin 10 to ground, to provide a fixed path for the opamp bias current. 33 Ohm seems rather low for the limit resistor. What is the LED current rating?
 
Last edited:

schmitt trigger

Joined Jul 12, 2010
907
33 ohm is way too low for LEDs supplied from 5 volt.
With such a low value, the opamp will attemp to sink 90 mA. which of course it can't. The end result is that it will current-limit and the output voltage will not drop enough (close to zero) to allow your diode-OR to operate correctly.

Use 330 ohm.
 

Thread Starter

twosacrowd

Joined Jul 3, 2009
11
You need only the two adjustable threshold voltages you already have in order to define the variable window: the low and the high thresholds established with the two pots. That is why I suggested 2.5V as the reference for the third opamp. Try it, and see if it cures the problem.

Edit: You could also try adding a resistor (~100k) from pin 10 to ground, to provide a fixed path for the opamp bias current. 33 Ohm seems rather low for the limit resistor. What is the LED current rating?
Thanks so much, your suggestions, seem to work very well now. I don't know what I was thinking about with the 33 ohms, obviously not thinking :)
 

Thread Starter

twosacrowd

Joined Jul 3, 2009
11
33 ohm is way too low for LEDs supplied from 5 volt.
With such a low value, the opamp will attemp to sink 90 mA. which of course it can't. The end result is that it will current-limit and the output voltage will not drop enough (close to zero) to allow your diode-OR to operate correctly.

Use 330 ohm.
Sorted it out, thanks for your input :)
 

Thread Starter

twosacrowd

Joined Jul 3, 2009
11
You need only the two adjustable threshold voltages you already have in order to define the variable window: the low and the high thresholds established with the two pots. That is why I suggested 2.5V as the reference for the third opamp. Try it, and see if it cures the problem.

Edit: You could also try adding a resistor (~100k) from pin 10 to ground, to provide a fixed path for the opamp bias current. 33 Ohm seems rather low for the limit resistor. What is the LED current rating?

Hi Alec,
Still not working properly I'm afraid. At times I get the condition of the Red and Green LED being on together momentarily. Sometimes the threshold on the Lower voltage pot can be above 2.5 Volts, and the Higher threshold can be around 4 Volts depending on the photodiode amp output. Can you suggest a more refined solution, and without using microcontrollers. I am looking for three clearly defined states of a Led indicating Upper , Lower, and Inside these values; but only ever one on at any given time. Thanks so much for your assistance guys.
 

Alec_t

Joined Sep 17, 2013
14,337
Post a schematic of the whole circuit, including the photo-sensor, that you currently have. What comparator IC are you using?

Edit:
Here's a mod of your circuit which should work. Note that the reference for U1c is now taken from a potential divider, R1/2, between the two pot wipers.
Tri-LED-Comparator.PNG
 
Last edited:

dl324

Joined Mar 30, 2015
16,943
Can you suggest a more refined solution, and without using microcontrollers. I am looking for three clearly defined states of a Led indicating Upper , Lower, and Inside these values; but only ever one on at any given time.
I think this circuit makes the intent more obvious, but it's less power efficient.
upload_2017-1-11_11-25-12.png
R1-R4 form a voltage divider that lets you set the trip voltages for the comparators. When the input exceeds V1, IC1A will turn on and provide a path to ground for D1; D4 blocks current so D2 won't turn on. When the voltage exceeds V2, IC1B will turn on, giving D2 a path to ground and shorting D1 (assuming the LED won’t conduct at 0.7V).

If you remove D4 and D5, you get a bar graph instead of moving dot.
 
Last edited:

GopherT

Joined Nov 23, 2012
8,009
Or you could use one A/D converter and digital logic that are not microcontrollers to pick out the thresholds you want.

If you are looking at very narrow ranges / small differences, or, slow moving signals that stay close to the threshold transition point, you will run into issues switch the bias current and input offset voltage, temperature drift and all the other joys of analog. It will exist in digital too but digital can easily be forced to be on or off.
 

Thread Starter

twosacrowd

Joined Jul 3, 2009
11
Post a schematic of the whole circuit, including the photo-sensor, that you currently have. What comparator IC are you using?

Edit:
Here's a mod of your circuit which should work. Note that the reference for U1c is now taken from a potential divider, R1/2, between the two pot wipers.
View attachment 118464
Post a schematic of the whole circuit, including the photo-sensor, that you currently have. What comparator IC are you using?

Edit:
Here's a mod of your circuit which should work. Note that the reference for U1c is now taken from a potential divider, R1/2, between the two pot wipers.
View attachment 118464
 

Thread Starter

twosacrowd

Joined Jul 3, 2009
11
Sorry, our scanner has packed in and I can't post the full circuit. The IR emitter is an SFH4235 and the photodiode with built in amplifier is an OPT101 and we are using the internal 1M feedback resistor. The circuit is now as suggested in your earlier post with the changes such as 2.5V potential divider on Pin 11 and a100k from Pin 10 to ground for any biasing issues.
Basically we are placing small vials of various blood samples between the emitter and sensor to determine different ratios of blood haematocrit as a voltage representation. I am using the LM 339 comparator
 

Thread Starter

twosacrowd

Joined Jul 3, 2009
11
I think this circuit makes the intent more obvious, but it's less power efficient.
View attachment 118471
R1-R4 form a voltage divider that lets you set the trip voltages for the comparators. When the input exceeds V1, IC1A will turn on and provide a path to ground for D1; D4 blocks current so D2 won't turn on. When the voltage exceeds V2, IC1B will turn on, giving D2 a path to ground and shorting D1 (assuming the LED won’t conduct at 0.7V).

If you remove D4 and D5, you get a bar graph instead of moving dot.
Sorry, but won't D1 still illuminate as it still has a path to Ground in the same way that D2 does?
 

dl324

Joined Mar 30, 2015
16,943
Sorry, but won't D1 still illuminate as it still has a path to Ground in the same way that D2 does?
No. I said:
dl324 said:
When the voltage exceeds V2, IC1B will turn on, giving D2 a path to ground and shorting D1
When D2 is turned on by IC1B, that will short D1 by D4.

I just breadboarded that part of the circuit and, as expected, the LED can't conduct sufficient current to light with a diode across it.
 

dl324

Joined Mar 30, 2015
16,943
One thing to note is that you need to consider the LM393's sink capabilities:
upload_2017-1-12_9-39-34.png
upload_2017-1-12_9-39-54.png

For the circuit to function, the saturation voltage of an output that's connected to D4 or D5 needs to stay below 300-400mV. If it rises too high, the voltage across the LED that the diode is shunting will conduct. Those outputs will also be sinking current that would otherwise go through the shunted LED; which will increase current and saturation voltage.

I tried the circuit with about 3mA per LED and the circuit worked because the minimum sink current was sufficient. At 15mA, it didn't because the saturation voltage was too high.
 
Top