# Schmitt Trigger not reaching full saturation

I'm trying to develop a sensor based on the optoelectronic device CNY70. I want to filter the signal in order to be read by a microprocessor, where the threshold to change between logic levels could be adjusted manually using a potentiometer. Then, thinking of an ideal operational amplifier, I came with something like this:

simulate this circuit – Schematic created using CircuitLab

With this single supply construction for the op amp, I would have to get a hysteresis band for the logic level switching of approximately 150mV, centered around the voltage given by the potentiometer on the inverting gate.

I built the real prototype using the op amp L2904N and made some measurements with a voltmeter and an Arduino. The hysteresis band for the Schmitt Trigger configuration works almost perfectly for switching the logic levels, however, those logic levels does not correspond with the supply of the op amp... Ideally, I should get 0V - 5V logic levels, but I'm getting 0V - 3V levels.

So what's the non-ideal thing that is causing this problem? I think it could be related with any maximum output current the op amp can drive, but the datasheet actually does not give any information about output current. What do you think?

• not sure about the answer, but I have recently experimented with an op-amp schmitt trigger. the results were similar, at high output I measured 3.9 volts, but my microcontroller accepted 4V min as high... Not the best solution, but check if your microcontroller has TTL inputs instead of schmitt trigger ones. TTL inputs accept above 2V as high. Good luck – C K Aug 10 '18 at 16:30
• or try removing the LED from circuit, does it work now? – C K Aug 10 '18 at 16:34

Output voltage drop vs current sourcing. Source: LM2904 datasheet.

The best you're going to get out of that op-amp is > 1 V less than the positive supply. As you try to pull more current the voltage droops and collapses completely at > 30 mA. With your 220 Ω resistor you're probably hoping for 10 mA. I've marked on the graph that you can expect about 1.5 V drop in output voltage.

So what's the non-ideal thing that is causing this problem?

Output doesn't reach V+.

I think it could be related with any maximum output current the op amp can drive, ...

There are both voltage and current limitations.

... but the datasheet actually does not give any information about output current.

Experience is knowing where to look. You're wiser now!

Update - a possible workaround.

simulate this circuit – Schematic created using CircuitLab

Figure 2. Addition of a pull-up resistor and diode will give the GPIO a further +0.7 V on both high and low conditions.

You need to work out if this would solve the problem.

• @Jamie: See if the update is of any use. Thank you for accepting my answer. – Transistor Aug 10 '18 at 18:17

When the LM2904 drives it output high, the current must go through two transistors and a resistor:

So it will not be able to go up to the positive supply, especially with all the current for the LED.

To get a proper digital signal, replace the opamp with a comparator.

• This is most of what I was about to post. One thing I'd add: If you want an op-amp that can drive its output close to the positive rail, you need to specifically look for one that is advertised to have "rail-to-rail outputs". – The Photon Aug 10 '18 at 16:46

The issue is on LM2904 output voltage range, which doesn't get too close to positive supply (see VOH in data sheet: typically VCC - 1.5V with a 10 kOhm load, so around 3.5V). A quick solution is another part that gets closer to positive supply, with rail to rail output (RRO), such as an LMV358.

Another improvement can be putting a pull-up resistor on op-amp output, but that would require also removing the LED load, increasing its series resistor, or inverting its behavior (connected toward +5V, instead of GND).

Anyway, as already answered, chances are your MPU/MCU accepts the 3-3.5V level as '1' level, even if powered at 5V. You can verify that in its data sheet, among the electrical characteristics of I/O ports.