This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LM358 strange Output

Other Parts Discussed in Thread: LM358, LM317, OPA2137, TL032, TL082, TL052, TL072

I am using LM358 as a difference amplifier with gain 10 and then the second one also as a difference op amp with gain 10. Vcc is 22.5V and Vee is 0v. Bypass caps = 0.1uF.

Circuit is wired on breadboard.

The difference amplifier is connected across a 0.1 ohm current sense resistor. The voltage across the sense resistor is 15mV, but the output of the difference amplifier is 830mV.

The resistors are 1% metal film. I don't understand why it's 830mV instead of 15mv*10=150mV.

Even if I consider 6mV offset voltage, the max output will be (15+6)*10 = 210mV.

I don't understand why I am getting 830mV?

Just to make sure the op amp isn't broke, I shorted the 2 input terminal to ground. The output was 0.2mV.

pdf of ckt attached.4382.Circuit5a opamp.pdf

  •  Hello Hithesh,

    The load current should be about 1 amp. 15mV on the sense resistor is too low.
    I am concerned that the feedback loop is not stable. Are any of the nodes oscillating?

    Try disconnecting the second op amp from the base of Q2 to open the feedback loop.
    Do the amplifier outputs work correctly with this modification?

    As a second future concern; If V_IN is lowered, the common mode range of the first op-amp may be violated.

    Regards,
    Ron M.

     

  • Ron, why should current be 1A. When the current is actually 1A, the first opamp output is around 1024mV. This is when the load(battery charger) is attached. When there is no load or when the charging is done, the drop across 0.1 ohm resistor is 15mV. That's 150mA.

    I did check for oscillations, didn't find any.

    I also tried disconnecting the second opamp. No change.

    The smallest V_IN observed so far was 18V.

  • The emitter of Q1 should be over 21V if Q2 is off or unconnected.
    That puts over 21V across 20.1 ohms. That is about 1 amp.

     

     

  • Ron M. said:

    The emitter of Q1 should be over 21V if Q2 is off or unconnected.
    That puts over 21V across 20.1 ohms. That is about 1 amp.

     

     

    That's correct. I should have mentioned, the load is not always 20 ohms.

    I made it 20 ohms to see if the second opamp kicks in when the current limit(1A) is reached.

  • Hithesh,

    Would you be interested in this circuit (see attachment).
    As drawn it charges at 1 Amp up to 13.5V
    The charge current is set by the 1.25 ohm resistor and the two resistors on the right set the maximum output voltage.

    Regards,
    Ron  M.

     

  • Ron, thanks for the circuit. My first prototype was with a LM317

    I discarded it because of the power dissipation across it.  Also, I would need 20V at 1A

    Instead of LM317 I am using a SMPS with current limiter ckt at the output.

  • Hi Hithesh,

    Wit this circuit (supediode) you will have good linearity at  low input voltage . I suggested you  TSV358    because  low minimum output voltage (about 180mV@2k) and small differential voltage (+/-1mV).  Increasing gain, current sense resistor become less value and less power. Circuit is stable up to A=50.

    Dragan

    Dragan

     

  • Hello Hitesh,

    The problem is not the amplifier but the accuracy of the divide-down resistors.  Although 1% accuracy sounds pretty good, it is simply not good enough.

    This is a common problem when trying to measure a small difference between two high values (a pitfall into which I once fell, to my chagrin). 

    Ideally, the 10k/11k divider ratio is 0.9091, which for a 20V input should result in18.182V (say at the op-amp + input).  But even a +1% skew high on the 10k gives you 0.90991*20V = 18.198V instead.  A similar, but negative skew (-1%) would produce 0.90826*20V = 18.165V.  The difference is only 33mV, but if these voltages were applied to the + and - inputs of the op-amp (neglect input offset), the >10,000 gain of the amp would ideally produce >330V on its output!    

    Of course, the op-amp circuit works to make the + and - inputs virtually equal.  Since the differential input voltage at Rs is 15mV and we know that V+ and V- are within mV of each other, only an unbalance in the divider ratios can account for an output voltage of 830mV.   Simply assuming the R2/R6 divider was a perfect 10k/11k ratio, and assuming V- = V+ = 18.182V, then for (20-0.015)V - 0.830V, the R4/R5 divider ratio calculates to be 0.90587, which is only about -0.35% down from ideal. 

    So the resistors can be well within their specified tolerances (accuracy) yet still result in significant error in the output.  Consider that a divider using 1% resistors can have a nominal "worst-case" variation of +/-2% (neglecting temp-co, aging, and other complicating factors, etc.) and you can see that any attempt to resolve 15mV signals on a 20V common mode level will be subject to extreme error.  Presumably, resorting to 0.1% resistors should reduce the error by a factor of 10 at which point the "other complicating factors" could start to become significant relative to the divider error.  There is probably some convenient formula to relate the output error contribution to the resistor accuracy, but I don't know what it is and don't have the time to derive it.  I hope the concept is clear, though.

    If you are really interested in the accuracy of 1A flowing through Rs, then the error will be somewhat less because the current signal is almost 7x larger.  A detailed analysis of all the error-contributing factors (%R, Vos, Ios, drift, temp-co, etc.) should be done to find which factor dominates, and work to minimize that one first, then iterate to the next highest contributor.  If a 1% variation in some factor (divider ratio, for instance) results in a voltage variation of comparable magnitude to the differential signal being measured, then it's obvious where to start making improvements.  If the improvements necessary become too complex and/or costly, then a new approach to the original problem (sensing the current) must be considered.  (That's beyond the scope of this reply.)  

    Good Luck and Regards,

    Uli

  • Uli, I doubted the resistor tolerance and tested the circuit by hooking up the opamp inputs to ground instead of connecting them across the sense resistor, I got about 0.3mV output.

    With a tolerance of 1%, the gain can vary from 9.8 to 10.2

    The reason I put R6 was not to for voltage division purpose. But to equalize the bias current going into +ve and -ve opamp terminals. It's a diff amp. Basically, to minimize offset.

    Can it be thought of as a voltage divider too?

    I went thru the opamp datasheet again and found out the LM358 max input has to be Vcc-1.5v. This was not always the case in my circuit. The drop across TIP31 was 0.8v when the current was low(~100mA) and 3v when current was 0.8A. In both cases the opamp1 output was around 900mV.

    Another strange thing - the second opamp output is 315mV when its -ve input voltage is higher. This is also true in simulation(Multisim).

    I replaced the LM358 with OPA2137, which includes Vcc as input. But then again, the output of OPA2137 was 30mV. No progress there!

     

     

  • Hello Hitesh,

    R2/R6 is definitely a voltage divider and R4/R5 can be thought of as one, too.   Although you added R6 to equalize bias-current offsets, this resistor is actually required to configure the op-amp into a differential amplifier.  If you leave R6 out and change R2 into 909ohm, you get the same bias current equalization, but the output of the op-amp will be considerably different as the op-amp will try to make -ve = +ve.  Essentially, the output of U1A will always rise to above +ve.   It is no longer a diff-amp, but an inverting amplifier with a gain of 10 and a reference of around 20V.

    With a 15mV input at a 20V common mode level, Vout was +830mV which indicates that +ve was slightly higher than -ve.  This suggests that the R4/R5 divider is a slightly lower ratio than the R2/R6 divider.  When you GND both R2 and R4 inputs, +ve = 0V, but Vout cannot get any closer to zero than 0.3mV, so -ve sees about 0.03mV.  So -ve has a higher voltage on it than +ve, and Vout is forced as low as it can get, but it can't get any lower than 0.3mV above GND.  If you are able to temporarily power the op-amp with a negative voltage on pin4 (say -5V or something, for experimental purposes) I think you would see Vout would be a little negative when R2 & R4 are GNDed.

    Another temporary experiment you could try is to power only U1-pin8 from a higher voltage than V_IN, or power the TIP31C from a lower voltage than V_IN to avoid the problem of +ve and -ve being too close to Vcc.  With only 15mV across Rs on a 15~18V common mode level, I think U1A Vout will still be near 800mV.    

    I did not look at the operation of the second op-amp U1B.  The same tolerance analysis can be made, but the resulting effect will be much smaller because the differential input signal (U1AVout - Vcmp) is much larger than 15mV, and the common mode level is only about 1V.  Any output error due to divider-ratio differences will be much smaller.  I'm not sure what you mean by "the second opamp output is 315mV when its -ve input voltage is higher".   What is -ve higher than, and by how much? 

    Anyway, I didn't look at U1B because the original post was about U1A's strange output voltage, and it resembled a problem I had a few years ago.  Frankly, I think this problem should be solved first, since it doesn't matter if U1B stage doesn't seem to work if U1A output is wrong.  Once that is working, the solution to the U1A problem might lend insight into the U1B operation and how to optimize it.  I suggest disconnecting the feedback to R8 and working on the U1A stage in an open-loop manner.  And later, the same with U1B (which really is just another diff-amp).

    By the way, if you can run simulations, try a simple diff-amp circuit with an ideal op-amp, 20V source, adjust R_load to get 15mV across Rs, and first run R2, R4 = 1.000K and R5, R6 = 10.00K and note the results. Then run it again with R2 = 995, R6=10.05k, R4 = 1005, R5 = 9950 and compare the results.  Mix up the values a little within their tolerance ratings ans see what happens.  Then compare non-ideal vs. ideal when the differential voltage is adjusted to 150mV or 1.5V and see how the output's error from non-ideal vs. ideal diminishes.   Then try 0.1% values and see if the error gets closer to being acceptable.

    Regards, Uli  

     

  • Ulrich Goerke said:

    Another temporary experiment you could try is to power only U1-pin8 from a higher voltage than V_IN, or power the TIP31C from a lower voltage than V_IN to avoid the problem of +ve and -ve being too close to Vcc.  With only 15mV across Rs on a 15~18V common mode level, I think U1A Vout will still be near 800mV.    

    By the way, if you can run simulations, try a simple diff-amp circuit with an ideal op-amp, 20V source, adjust R_load to get 15mV across Rs, and first run R2, R4 = 1.000K and R5, R6 = 10.00K and note the results. Then run it again with R2 = 995, R6=10.05k, R4 = 1005, R5 = 9950 and compare the results.  Mix up the values a little within their tolerance ratings ans see what happens.  Then compare non-ideal vs. ideal when the differential voltage is adjusted to 150mV or 1.5V and see how the output's error from non-ideal vs. ideal diminishes.   Then try 0.1% values and see if the error gets closer to being acceptable.

    Regards, Uli  

    In simulation, I powered the opamp with 25VDC source (higher than 22.5V that powers TIP31). No difference.I went back to 22.5V

    Just for kicks, I added a -ve power supply(-5VDC) to pin 4. Now the output is closer to ideal opamp.

    Voltage across the input terminals is 11.23mV, output is 113mV(A=10). With the -ve supply connected, output is good even when input is Vcc-0.8.

    Ulrich Goerke said:

    I did not look at the operation of the second op-amp U1B.  The same tolerance analysis can be made, but the resulting effect will be much smaller because the differential input signal (U1AVout - Vcmp) is much larger than 15mV, and the common mode level is only about 1V.  Any output error due to divider-ratio differences will be much smaller.  I'm not sure what you mean by "the second opamp output is 315mV when its -ve input voltage is higher".   What is -ve higher than, and by how much? 

    I meant the Voltage input at the inverting terminal is higher than the non-inverting terminal. The output is 315mV, until the +ve input is higher than the -ve input.

    For example, if -Vin is 1V, output of U1B will be 315mV until +Vin crosses 1V.

  • Hello again, Hitesh,

    I don't think I can add much more to this discussion.  Most of my points are in the first and second postings.  The non-ideal characteristics of the real op-amp tend to obscure the main principle of the tolerance of the resistors as being the biggest contributor to output voltage error.  That is why I recommended running the simulations with an IDEAL op-amp, (no Vos, no Zo, no VCC or Vee limitations, no Vsat, infinite gain, etc.), not something "closer to ideal".  If such a model is not directly available from the simulator software, you can make one from a voltage-controlled voltage source with a gain of 1,000,000.  But I don't want to digress into simulation techniques or side issues.

    Focus on the main problem: one cannot accurately amplify a 15mV differential signal riding on a 20V (20000mV) common-mode level using divider resistors each with 1% accuracy (200mV error for each %).  Not in mass production, anyway.  Each unit will have a different output.  You can hand-trim ONE unit to work perfectly, for a while, until it drifts with temperature or aging; then you have to trim it again.   The use of the simulator, using truly IDEAL components, is intended to help you easily visualize the magnitude of the error due only to the deviations of the resistors from their own ideal values.    Once that is clear, you can start throwing in some of the op-amp limitations (Vos, etc.) one at a time, not all at once, to see how each additional non-ideal characteristic can effect the output.   It's faster and easier than mucking around with the breadboard. 

    Once all the effects make sense, the "strange output" won't be strange at all, and you can return to the breadboard and modify the design as required to meet your objectives.  Thank you for the discussion.  As I mentioned, I really don't have anything more to add.

    Good luck and Regards,

    Uli

  •  UPDATE:

    I added a Negative supply of 2.5v. Now the output is as expected. Vcc is 24V and Vee is -2.5V.

    I don't think just the variation in resistor tolerance can give voltage of 0.8V, when the expected is 0.1V.

     

    When there is no load on the output, the LM358 output is less than a millivolt.

     

    Is there a similar costing op amp which includes input range upto +Vcc ?

    By similar, I mean single supply operation up to 24V and 1K price under 0.50$.

     

     

  • Hithesh,

    The JFET input opamps, like the TL032, TL052, TL072, TL082 have a common mode range up to VCC+.  Each one has a different ICC and speed. They are also inexpensive.

    Regards,
    Ron M.

     

  • But these are not single supply opamps.

    I already tried TL072. The output is 0.9V when expected is 0.1V

  • Uli, you are absolutely correct-- the common mode error of a home-built differential amplifier has been the pitfall that almost all of us have fallen into at some point in our career. There are some old BB/TI technical seminars that covered why a handful of 1% resistors was going to lead to grief. The moral of this story is that you CANNOT build your own diff amp.

    Manufacturers of IC diff amps spend a lot of effort to trin their on-chip thin-film resistors to between 0.01% and 0.001% to get the performance in those data sheets. See this:

     http://artikel-software.com/file/instrumentation%20amplifier%20handbook.pdf 

    and look in the chapter titled "Amplifier Topologies" - "Difference Amplifiers". This was a draft of a handbook that was never published but it may help understand this problem. I hope this helps.

    Regards, Neil P. Albaugh  ex-Burr-Brown