LM311 - Voltage Comparator Help

Thread Starter


Joined Jun 29, 2013
Hi All,

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

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.

Is there something wrong with my circuit/configuration?



Joined Jul 31, 2013
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...


Joined Oct 2, 2009
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.


Joined Feb 24, 2006
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?


Joined Oct 8, 2012
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.