LM311 - Voltage Comparator Help

Discussion in 'The Projects Forum' started by rueffy, Sep 2, 2013.

  1. rueffy

    Thread Starter Member

    Jun 29, 2013
    39
    3
    Hi All,

    I'm trying to run a voltage comparator in the following configuration.

    [​IMG]

    I am wanting to compare a photodiode which varies between about 200mV (ambient light) and 500mV (laser light). I've set my threshold at around 350mV using a simple voltage divider (22k / 1k) and 9V battery.

    The comparison seems to be working fine as the output of the comparator is 0 when below 350mV, however when above 350mV I get a tiny AC waveform out. Not the flat-line DC positive voltage I was expecting.

    [​IMG]

    Is there something wrong with my circuit/configuration?

    Thanks,
    Rueffy.
     
  2. daviddeakin

    Active Member

    Aug 6, 2009
    207
    27
    The LM311 has an open collector output, so it needs a pull-up resistor on the output. Try 20k from pin 7 to +5V.
    This always catches people out!
     
    rueffy likes this.
  3. rueffy

    Thread Starter Member

    Jun 29, 2013
    39
    3
    You Sir, are a bloody legend! Thanks for your help :)
     
  4. cornishlad

    Member

    Jul 31, 2013
    196
    25
    rueffy...as one new member to another could I point out that it's good to thank someone for a helpful reply, as you have done, but also note he "thanks" button at the bottom right of all posts. It took me a while to catch on to that useful feature...
     
    rueffy likes this.
  5. MrChips

    Moderator

    Oct 2, 2009
    12,452
    3,371
    LM311 comparator and similar comparators have open collector output.
    The output needs a pull-up resistor.

    This needs to be a sticky somewhere. Too many newbies trip up on this one.
     
    rueffy likes this.
  6. Papabravo

    Expert

    Feb 24, 2006
    10,179
    1,800
    LM311 also have a tendency to oscillate without bypass capacitors on the the power supply pins, and read the datasheet carefully to understand the parameter labeled "common mode range".

    Also, given that the anode of the diode is at ground won the cathode be below ground when it is passing current?
     
    rueffy likes this.
  7. rueffy

    Thread Starter Member

    Jun 29, 2013
    39
    3
    Thank you to all those that helped contribute to the development of my circuit. The project is now fully functional and I've made a video as part of my presentation to a class, the video shows the system in operation with a full description of signal flow etc.

    http://www.youtube.com/watch?v=CCAkpJ-jG6A

    rueffy.
     
    Last edited: Nov 25, 2013
    apqo1, bance and wayneh like this.
  8. bance

    Member

    Aug 11, 2012
    315
    34
    Neat little project, and a very nice presentation. Well done!

    Steve.
     
  9. apqo1

    Well-Known Member

    Oct 5, 2008
    50
    3
    Clever project, well explained. Thanks for sharing!
     
  10. alexfreed

    Member

    Oct 8, 2012
    72
    10
    While the problem has been solved, I think it is worthwhile to mention the *reason* for the AC on the output. From the 50 Hz frequency it's obvious that we observe interference from the power line (in the Old World. Would be 60 Hz here). Good idea to probe the +5 volts to see if the ripple voltage comes from there. In this case it won't be a problem. Touch the top of the scope probe with a screwdriver while it is also connected to the circuit. The AC will increase. So it means that we see the "hum" on high impedance input. When the comparator is "on", it shorts the scope's input to ground but when it's "off", it acts as open (high-Z) circuit. And the wire acts as an antenna.
     
Loading...