# LM358 (as comparator) output voltage less than supply voltage

I've setup a simple circuit with an LM358 configured as a comparator (the ground rail and supply connections are off screen).

Schematic:

Breadboard: (in case I wired something wrong)

Measured values:

V+ = 4.97V (expected) GND = 0V (expected) In(-) = 2.47V (expected, via voltage divider) In(+) = 4.97V (expected) Output = 3.63V (???) 

Here's the pin mapping for your convenience:

Since 4.97V is greater than 2.47V I was expecting the output to be 4.97V. Why is it 3.63V? Is this normal for this particular op-amp or am I doing something wrong?

I've tried looking through the datasheet but I'm new to this stuff so I'm not sure what to look for.

• Delete that horrible protoboard photo and show a proper electronics schematic. All proper electronics starts with a proper schematic. – Michael Karas May 23 '16 at 1:02
• And reading the datasheet. Don't forget reading the datasheet. – Ignacio Vazquez-Abrams May 23 '16 at 1:06
• LM358 is not a comparator, it's an older generation general-purpose op amp. – MarkU May 23 '16 at 1:06
• @MichaelKaras I've updated with a schematic. I included the (horrible) breadboard pic just in case there was something wrong with the way I wired it. – nebs May 23 '16 at 1:15
• Most high-performance op-amps should not be used as comparators. But older general-purpose ones like LM358 often can. The LM358 datasheet shows a few application circuits and test circuits where negative feedback doesn't maintain equal voltages on the inputs, so you should be okay. – The Photon May 23 '16 at 1:53

LM358 is not a rail-to-rail output op-amp, so you should not expect it to produce an output near the positive supply voltage.

Unfortunately, the datasheet doesn't go out of its way to make this obvious. The main clues are:

• Nowhere on the front page does it claim to have rail-to-rail outputs.

• Figure 10 on page 10:

This shows that if only modest currents are sourced from the output, the maximum output voltage is about 1 V below the upper supply voltage.

Edit: You might also have some issues from not hooking up the second op-amp. It could potentially oscillate and affect the behavior of the op-amp you are using. The typical way to deal with this is simply hook it up as a follower with nothing connected to its output.

• Ah I see, that makes sense now. I will make sure to look out for these kinds of graphs in the future. Thanks. – nebs May 23 '16 at 1:27
• Usually there is a line in the specs about output voltage range. The LM358 has it, but only for V+ = 30 V, so not especially helpful for your case. – The Photon May 23 '16 at 1:48
• i think that with $V_\Delta$<1.4 v and $V^+$=5 v and with the comparator gain of 110 dB and with a bottom clipping voltage at least 0 volts, we know that the comparator output levels are good enough for TTL or CMOS or whatever logic is in vogue of the day. it seems to me that the output is about what should be expected. – robert bristow-johnson May 23 '16 at 6:01