Reading a photodiode output into a window comparator.

Discussion in 'Analog & Mixed-Signal Design' started by twosacrowd, Aug 26, 2016.

  1. twosacrowd

    Thread Starter Member

    Jul 3, 2009
    11
    0
    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
     
  2. bertus

    Administrator

    Apr 5, 2008
    15,805
    2,389
    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
     
  3. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,977
    1,136
    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.
     
  4. twosacrowd

    Thread Starter Member

    Jul 3, 2009
    11
    0
    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 ?
     
  5. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,977
    1,136
    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: Sep 29, 2016
  6. schmitt trigger

    Active Member

    Jul 12, 2010
    46
    8
    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.
     
    twosacrowd likes this.
  7. AlbertHall

    Well-Known Member

    Jun 4, 2014
    2,275
    449
    Yep, agree, 330Ω for the LEDs and 2.5V on pin 11.
     
    twosacrowd likes this.
  8. twosacrowd

    Thread Starter Member

    Jul 3, 2009
    11
    0
    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 :)
     
  9. twosacrowd

    Thread Starter Member

    Jul 3, 2009
    11
    0
    Sorted it out, thanks for your input :)
     
  10. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,977
    1,136
    Good to know it's sorted.
     
  11. twosacrowd

    Thread Starter Member

    Jul 3, 2009
    11
    0

    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.
     
  12. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,977
    1,136
    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: Jan 11, 2017
  13. dl324

    Distinguished Member

    Mar 30, 2015
    3,379
    651
    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: Jan 11, 2017
  14. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,240
    414
    Or you could try an LM3914N dot- bar generator.
     
  15. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,315
    4,040
    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.
     
  16. twosacrowd

    Thread Starter Member

    Jul 3, 2009
    11
    0
     
  17. twosacrowd

    Thread Starter Member

    Jul 3, 2009
    11
    0
    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
     
  18. twosacrowd

    Thread Starter Member

    Jul 3, 2009
    11
    0
    Sorry, but won't D1 still illuminate as it still has a path to Ground in the same way that D2 does?
     
  19. dl324

    Distinguished Member

    Mar 30, 2015
    3,379
    651
    No. I said:
    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.
     
  20. dl324

    Distinguished Member

    Mar 30, 2015
    3,379
    651
    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.
     
Loading...