# LM358 differential voltage and amplifier circuit

I designed a circuit that's rather common:

simulate this circuit – Schematic created using CircuitLab

And I have a problem. I have got few LM358s, some from ST, some from other companies. (I tested LMV358 also - it puts ~5 V as V_OUT_FINAL). I made a designed circuit and already put every one of those LM358s in it and none works the way I want them to do. I always get a constant error of 1-3 V as V_OUT_FINAL. I also get wrong result as V_OUT_1 (because it's around 0,5-1 V). I don't know what's wrong. The values in my real project are wrong in terms to the designed and simulated. I simulated it on many tools already and all give me results like those from attached circuit.

V_IN_1 = 12 V, V_IN_2 ~ 12 V (little less than 12V). V_OUT_1 = few mV. V_OUT_FINAL ~ 3 V.

• What are you actually trying to achieve with this circuit? Nov 29 '17 at 9:09
• The input voltage (12V) far exceeds the rail voltage (5V), it makes sense is not gonna work. The OA1 output and OA2 input are directly connected. Nov 29 '17 at 9:10
• First I want to get a differential voltage, which will be a difference of V_IN_1 and V_IN_2. Second, I want to amplify this value so I can measure it with ADC. Nov 29 '17 at 9:11
• @MarkoBuršič I know it exceeds, but the values going into OA1 are within range of 0-5 V (it's ~4 V actually). I tested the circuit with 5 V of voltage on Sense_Res and it neither worked. Nov 29 '17 at 9:15
• Can you not use a proper high side current amplifier or use a low side shunt R.? Is the load regulated from the high side or the low side? It is impossible to design anything without these kind of specs Jan 10 '19 at 3:36

1. First disconnect second stage input from first stage output.

2. Biasing (DC) of Pin 2 and Pin 3. Pin3 is held at approximately 1.4 volt and Pin 2 at about 12 volts. Your inputs at those Pins have to be of level which would not require any amplifier circuit. A resistor from Pin2 to ground is required to bias the pin properly. Else connect it to input through a series resistance of 10K. Use coupling capacitors to avoid disruption of dc condition of pins.

3. Feed back. Pin 2 is fed back through 100K (R4). The present configuration gives stage gain of (R4/R2 = 0.25). R2 value (input impedance) should be (for example) 10K for gain of 10.

4. Preferably use Variable Resistor (one for a pair) for setting DC conditions of Pins. Later on, you can use fixed value resistance.

5. After fixing stage 1 check stage 2 dc conditions, connect stage 1 output to stage 2 through a coupling capacitor and check.

OA1 is a differential amplifier. It outputs the voltage difference across the sense resistor (multiplied with any gain). This voltage is very small, close to zero. So the output is close to zero. The LM358 output can come close to zero (5mV typical, 20mV max), but will show an error in this application where the voltage across the sense resistor is too small (30mV, which becomes 7.5mV with an opamp gain set at 0.25).

So, either have a dual supply for the OA1, or feed a positive offset voltage at R3, instead of connecting it to ground. [An offset will make things rather complicated for OA2 and the ADC in this application.] Once V_out_1 can approach 0V, the V_out_final will hopefully also fall into range.

The OA1 gain needs to be set at 0.25, due to the 12V supply of the load and the 5V supply of OA1. This brings the signal into range for OA1. If you can supply OA1 with ±12V, you can potentially set a gain of 1. The output of OA1 will then go to 30mV. The gain on OA2 can then be reduced a bit. Remember that due to input offset errors (5mV max), the LM358 may not be a good opamp in this application. One can try increasing the value of the sense resistor, if possible, to work around this. In this circuit (5 m ohm sense resistor), an OP07 would be a better choice for OA1 (which requires a dual supply anyway).

Remember to use 5V for OA2, so that the ADC voltage is not accidentally exceeded. Or, have input voltage protection for the ADC.

An entirely different approach would be to have the ±5V sitting on the +12V (just after the sense resistor, so that becomes ground for the opamps and ADC) and run everything there. The output of the ADC can be taken out with an optocoupler if there is additional circuitry. One will then not even require a differential amplifier, just one opamp in normal configuration will suffice and then feed it to ADC. This way, there will not even be any limitation of the 12V (any voltage, even much higher can be used).

An alternate approach:

simulate this circuit – Schematic created using CircuitLab