3
\$\begingroup\$

I have a problem when using LM358 in compare mode.

I'm trying supply LM358 with 5V (V+ = 5V, V- = GND).
The non-inverting input is 0.6V and the inverting input is 0V and 1.2V, respectively. When the inverting input is 0V the output is around 4.2V (this is okay) but when it is 1.2V the output is between 0.75V and 0.9V.

Is there any way to decrease the output to nearly 0V (in the datasheet they said the negative rail is about 100mV when I_out is around 10uA)? Or do I just change to other rail-to-rail opamps?

https://www.ti.com/lit/gpn/lm2904ba

This is my circuit: enter image description here

TRIP_1 is a wire connected to STM32

\$\endgroup\$
5
  • \$\begingroup\$ What do you have as the output load and how much current it draws? Or have you got no load at all? \$\endgroup\$
    – Justme
    Commented Feb 5 at 5:24
  • \$\begingroup\$ I just connected it to STM32 only, no pull_down resister. \$\endgroup\$
    – Nhat Micls
    Commented Feb 5 at 5:35
  • \$\begingroup\$ You might edit in that it was not only connected to MCU input, but there was some level shifter circuit in between that also might have affected the result, especially if the level shifter had any pull-ups. \$\endgroup\$
    – Justme
    Commented Feb 5 at 6:55
  • \$\begingroup\$ Why not use the LM393, a true comparator from the same technology as the 358? \$\endgroup\$
    – John Doty
    Commented Feb 5 at 22:05
  • \$\begingroup\$ @JohnDoty I will take a look with it, thanks \$\endgroup\$
    – Nhat Micls
    Commented Feb 6 at 7:02

5 Answers 5

3
\$\begingroup\$

Lm358 is not rail to rail. It has Q13 pnp follower on low side so 0.7V drop is quite normal. (Except very low output current).

enter image description here

Source: ti.com

To remove this drop you can connect a npn to its output. But it will rapidly slow down the output high to low transition. Also it add next 0.7V drop during output high. So rather use another op-amp if possible.

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ Thanks, I will try it, I thought about it a long time ago but didn't try this solution. \$\endgroup\$
    – Nhat Micls
    Commented Feb 5 at 6:19
  • \$\begingroup\$ @NhatMicls This won't help if you have a level shifter as the load between LM358 and STM32 which pulls the lines towards supply. \$\endgroup\$
    – Justme
    Commented Feb 5 at 6:34
  • \$\begingroup\$ @Justme I will remove it when I use this solution. \$\endgroup\$
    – Nhat Micls
    Commented Feb 5 at 6:39
  • \$\begingroup\$ @NhatMicls Yes but if you remove your current level shifter, you simply need a resistor (or two). \$\endgroup\$
    – Justme
    Commented Feb 5 at 6:40
  • \$\begingroup\$ It´s also possible to connect npn as “common emitter” to op-amp output and just swap inverting and noninverting inputs of op-amp. \$\endgroup\$ Commented Feb 5 at 6:44
1
\$\begingroup\$

Check if you are not loading output by "higher" currents (above 0.1mA). Then you can simply "help" your opamps output to reach lower voltage by pulldown resistor. See last line of table you are posted (output voltage can go in range ov mV if loaded by resistance lower then 10k to V-).

\$\endgroup\$
1
\$\begingroup\$

You have no load.

Datasheet says you can achieve 5mV to 20mV if you have a 10k load to ground.

EDIT: You said you have no load but in reality the pull-ups on the level shifter you have works agains the low-going output so it is higher than what you expect and much lower output is achieved with a pull-down on output.

For the MCU connection, you can use a voltage divider if you don't have free 5V tolerant inputs on the STM32 or need to read it with an ADC, but you can also connect it to a 5V tolerant input directly.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I just recognized have a translator in the middle for 5V -> 3.3V, maybe that is reason put it to 0.7V, I will check datasheet to confirm it. \$\endgroup\$
    – Nhat Micls
    Commented Feb 5 at 6:23
  • \$\begingroup\$ @NhatMicls So the circuit is not described correctly. We don't know what circuitry you have there but I suspect a FET level shifter with pull-ups, so it obviously causes a problem because you need load to ground to bring output close to ground. You can simply use a resistor divider as load to limit voltage to MCU input, or use a 5V tolerant input on STM32. \$\endgroup\$
    – Justme
    Commented Feb 5 at 6:30
  • \$\begingroup\$ I will try this too, it seems easy to test it, thanks \$\endgroup\$
    – Nhat Micls
    Commented Feb 5 at 6:40
1
\$\begingroup\$

Is there any way to decrease the output to nearly 0V

Yes. R8 should be a pull-down resistor, not a pull-up resistor. Of course the output won't go close to 5V then. So it's your choice where the voltage is close to rail, but it won't be close to both rails, since the output stage of an LM358 is not designed for that.

You might have been confused by open-collector-output comparators, such as LM393, LM2903. Those need a pull-up on the output. But you're not using one of those chips. Instead, you're using an op-amp with a class-B output stage that needs different biasing.

To get nice, clean output, you'll need to use a Schmitt trigger gate (say 74HC14 or 40106) to convert the output to logic levels.

\$\endgroup\$
0
\$\begingroup\$

Insert a resistor with a value of 10kohms on the inverting input and then connect signal to the 10kohms resistor.

Also, since the output stage of LM358 has a double high and low side driver, I don't think you need to pull up R8 resistor.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.