Arduino Forum

Using Arduino => General Electronics => Topic started by: Yoram on Jun 30, 2017, 01:38 pm

Title: LM358 saturates the output
Post by: Yoram on Jun 30, 2017, 01:38 pm
Trying to sum two audio signals using LM358 (see attached drawing).

The problem is that the output gives only the lower part of the sine wave (see sketch in the drawing). This happens even if the input signal is very very low.

There is also a D.C voltage of about 3 volts. Can anyone suggest why this should happen. I tried adding a pull-up of 1K and it fixed the issue. But overall I am not happy to design something that I do not understand.

Any help is appreciated
Title: Re: LM358 saturates the output
Post by: Southpark on Jun 30, 2017, 02:05 pm
Try a 33 K resistor instead of the 150 K ..... and reduce the AC input voltage levels..... ie. make AC waveforms at the input  smaller.

Or.... if you don't want to make the input AC signals smaller.... then make the 75K resistor smaller.

Circuit theory for ideal op-amps working in negative feedback mode - automatic equalisation of the voltages on its input + and - terminals. If you deliberately make the + terminal equal to roughly half the supply voltage... aka 7.5/2 .... or about 3.75 Volt, then that will lead to a DC level at the output. The basic op-amp tutorials usually teach this.

So if you then have any AC voltage at the output, then that AC will basically ride on the DC level. This means ... 3.75V DC will translate to the 'zero' Volt level of the AC signal. The AC signal will change above and below this 3.75V DC level. If you have the power supply limits... of 0V and 7.5V .... then 'ideal' case output would allow you to reach as high as 7.5V DC, and go as low as 0V DC. But...... for real op-amps, with component voltage drops and things like that inside the op-amp..... you might not be able to go as high as 7.5 V. Instead, you might be able to go as high as 6.5 V ... maybe. Depends on the op-amp.

In your case.....  you made the DC level at the + terminal equal to 2V. Should change your system to make it around 3.75 Volt.
Title: Re: LM358 saturates the output
Post by: Wawa on Jun 30, 2017, 02:07 pm
Output voltage swing of the LM358 is limited to about 1.5volt below VCC.
So the positive part of the wave is clipping if you try to output more than 3.5volt peak/peak on a 5volt supply.
Only an opamp with rail2rail outputs is able to swing too (almost) VCC and (almost) ground.

DC offset on the output should be about 2volt with that 100k:150k divider at the +input of the opamp.

I assume the output is connected to an analogue Arduino input (not driving something else).
Leo..
Title: Re: LM358 saturates the output
Post by: Yoram on Jun 30, 2017, 02:37 pm
@Leo

Thanks for the note about the 1.5 gap from the positive rail... I think however, that the saturation starts a lot earlier.

The output is not connected yet to anything. With those resistors,  I tried balancing the DC resistance on both inputs so that the DC differential voltage is close to zero considering the leakage current.
Still the output DC voltage at zero input is not zero and can be something like 2-3V.  ???.
Title: Re: LM358 saturates the output
Post by: Yoram on Jun 30, 2017, 02:44 pm
@Wawa

Thanks for the heads-up on the output DC level.

Regarding the input DC level, in reality I changed the divider on the plus signal so that I get a VCC/2. Basically it should have been two 150K but I had to change the resistors to get this mid point as appears on the sketch///
Title: Re: LM358 saturates the output
Post by: Southpark on Jun 30, 2017, 02:45 pm
Correct. The DC voltage on the output is not meant to be zero.

That's why you have to put a DC blocking capacitor on the output of the op-amp. Look up 'DC blocking capacitor output of op amp'..... in google.
Title: Re: LM358 saturates the output
Post by: Southpark on Jun 30, 2017, 02:52 pm
Regarding the input DC level, in reality I changed the divider on the plus signal so that I get a VCC/2. Basically it should have been two 150K but I had to change the resistors to get this mid point as appears on the sketch///
Your diagram has 5V. So it should be something like 33K between 5V and + terminal, followed by 100K between + terminal to ground. Or, alternatively.....  150K between 5V and + terminal, followed by 450K between + terminal to ground.
Title: Re: LM358 saturates the output
Post by: Yoram on Jun 30, 2017, 03:27 pm
I am not worried about the output dc voltage, I know I can remove it with a cap. The problem is that I am not able to locate this dc level consistently at say vcc/2 (or (vcc-1.5)/2) so that I can get the max swing without saturation...

Title: Re: LM358 saturates the output
Post by: TomGeorge on Jun 30, 2017, 03:34 pm
Hi,
This may help;

http://www.twovolt.com/2017/02/02/two-channel-audio-signal-mixer-using-lm358-op-amp/ (http://www.twovolt.com/2017/02/02/two-channel-audio-signal-mixer-using-lm358-op-amp/)

Tom... :)
Title: Re: LM358 saturates the output
Post by: Southpark on Jun 30, 2017, 03:43 pm
I am not worried about the output dc voltage, I know I can remove it with a cap. The problem is that I am not able to locate this dc level consistently at say vcc/2 (or (vcc-1.5)/2) so that I can get the max swing without saturation...
That's ok. I was just responding to your comment you made below, where it appears that you assumed that the output DC level should be zero.

Still the output DC voltage at zero input is not zero and can be something like 2-3V.  ???.
To get the output DC voltage roughly to be at Vcc/2 ..... you could :

option a) use the 7.5 V source, and use two of the same resistors eg ... 10K and 10K to make a voltage divider.... which will be used to set the + terminal to 3.75V

option b) use the 5 V source, and use an appropriate voltage divider to set the + terminal to around 3.75 V.... such as a 33K resistor and a 100K resistor divider.

Your diagram has a 7.5 V source, which will be Vcc. And your diagram also has a 5 V source, which is where you could use the 33K and 100K divider.

And, finally, you won't get saturation if you decrease the gain of amplifier (by, for example, by replacing the 75K resistor with a smaller one)..... or if you use smaller AC input values.
Title: Re: LM358 saturates the output
Post by: MarkT on Jun 30, 2017, 08:05 pm
Your circuit has a common-mode gain of 3x (well, -3x strictly), no wonder it saturates.  Make the
feedback resistor 22k or so to limit the output excursions, unless the input amplitudes are small.

Normally a virtual ground would be decoupled to ground to reduce noise (ie capacitor from the
non-inverting input to ground).
Title: Re: LM358 saturates the output
Post by: polymorph on Jun 30, 2017, 11:10 pm
What are you doing with the 2nd Op Amp? You cannot just leave it floating. It can go deep into saturation and cause strange effects across the substrate to the other Op Amp section, or go into oscillation. Either can cause the IC to draw excessive amounts of current.

You really need to give us voltages on everything, or we cannot help you.
Title: Re: LM358 saturates the output
Post by: polymorph on Jun 30, 2017, 11:11 pm
http://www.electronicproducts.com/Analog_Mixed_Signal_ICs/Amplifiers/Properly_terminating_an_unused_op_amp.aspx (http://www.electronicproducts.com/Analog_Mixed_Signal_ICs/Amplifiers/Properly_terminating_an_unused_op_amp.aspx)

(http://www.electronicproducts.com/images2/facn_TI3_nov2012.gif)
Title: Re: LM358 saturates the output
Post by: Yoram on Jul 01, 2017, 12:01 am
@Polymorph.

I forgot about the second half of the opamp, this could be the culprit. I will look into terminating it properly and post back.

@MarkT
Even if I am using a single input, where in this case the gain is only x1.5, it saturates way before the output signal reaches the rails boundaries.

Title: Re: LM358 saturates the output
Post by: Southpark on Jul 01, 2017, 01:42 am
Even if I am using a single input, where in this case the gain is only x1.5, it saturates way before the output signal reaches the rails boundaries.
Show your input signal measurements. And show your output signal measurements. This is to make things clear for everybody.

Eg. Set both AC inputs to be zero to begin with. Then increase the amplitude of 1 of the AC signals...... gradually, and slowly. And then, for the case where the output just begins to show onset of clipping --- indicate : what is the peak input AC voltage level (at the node between the 10 microFarad capacitor and the 50K resistor)? And also indicate the output clipping level.
Title: Re: LM358 saturates the output
Post by: TomGeorge on Jul 01, 2017, 03:16 am
Hi,
Did you look at the link I posted in #8?

Look at the magnitude of the resistors being used.
To obtain 1/2 Vcc  use two 10K, not 100K ?

The amp has some level of input impedance that influences the external input components.
The series input resistors make 4K7 or 10K, not 50K.

Thanks..  Tom... :)
Title: Re: LM358 saturates the output
Post by: Wawa on Jul 01, 2017, 03:41 am
Output clipping points of the LM358 are not ground and VCC, but (almost) ground and VCC-1.5volt.
An LM358 should NOT be biased at 1/2VCC because of that.
To get max output swing, replace the two bias resistors with a trimpot.
Adjust untill a ~4volt output signal clips symetrically.
Leo..
Title: Re: LM358 saturates the output
Post by: Yoram on Jul 01, 2017, 11:07 am
DC offset on the output should be about 2volt with that 100k:150k divider at the +input of the opamp.

Leo..
The real problem is that the output DC level is not at the same level as the +Vin...
The +Vin it se with the 100K and 150K divider  at Vcc*100/150=0.4Vcc, but the Vout DC is not consistent.

So when I test and change VCC I get the following readings:

VCC     +Vin      VoDC
5          2          2
6          2.4       2.85
9          3.6       5.65
12        4.8       8.00

We can see that as I use higher VCC the Vout DC tends to climb toward the upper rail. It starts when Vcc=5v at 2V which is 0.4Vcc and ends at when Vcc=12V at 8V which is 0.75VCC...

Any logic explanation for this?
Title: Re: LM358 saturates the output
Post by: Yoram on Jul 01, 2017, 11:20 am
@TomGeorge
I will take a second look at the +vin input, but as far as I remember they were consisted with the expected voltage divider.

@Wawa
To get max output swing, replace the two bias resistors with a trimpot. Adjust untill a ~4volt output signal clips symetrically.
Leo..
This is a good practical procedure, but this tuning is exactly what I want to avoid. Couldn't it be designed such that the output Dc level follows the design? see the measurements I posted above..
Title: Re: LM358 saturates the output
Post by: Wawa on Jul 01, 2017, 11:25 am
Can be explained if there is someting wrong with the input caps on the pots.
If there is a DC short/leak to ground there, then the opamp tries to compensate by increasing it's output.
Did you connect the 10uF caps with negative to pot and positive to 50k resistor.
Post a picture of the setup.
Leo..
Title: Re: LM358 saturates the output
Post by: TomGeorge on Jul 01, 2017, 03:02 pm
Hi,
Can you change the values I have highlighted, and recalculate the 75K to give the gain you need with 4K7 or 10K input resistors.
(https://forum.arduino.cc/index.php?action=dlattach;topic=486697.0;attach=217287)
Place a 1uF cap from the junction of the two 10K providing the 1/2 Vcc, to gnd.
10uF is too high for the high values of resistors you are using.

Tom... :)
Title: Re: LM358 saturates the output
Post by: Yoram on Jul 01, 2017, 06:16 pm
Can be explained if there is someting wrong with the input caps on the pots.
If there is a DC short/leak to ground there, then the opamp tries to compensate by increasing it's output.
Did you connect the 10uF caps with negative to pot and positive to 50k resistor.
Post a picture of the setup.
Leo..
Hi Leo,

You were right the input capacitors were assembled the wrong way. Now the Output DC voltage follows the one of +Vi :-)  Thanks...

I changed the voltage divider to 2x100k and the output signal is centered at Vcc/2. and I can get a max peak to peak voltage  that depends on VCC as follows:

VCC        MaxVPP
5             3
16           6

So while at 5V the output can swing up to 1.5v close to each rail, at 16V it can only swing up to 5V close to each rail. Any idea why there is a bigger gap as I use higher Vccs, and why most of the voltage is not translated into higher output amplitude.
Title: Re: LM358 saturates the output
Post by: Yoram on Jul 01, 2017, 06:24 pm
Hi,
Can you change the values I have highlighted, and recalculate the 75K to give the gain you need with 4K7 or 10K input resistors.
(https://forum.arduino.cc/index.php?action=dlattach;topic=486697.0;attach=217287)
Place a 1uF cap from the junction of the two 10K providing the 1/2 Vcc, to gnd.
10uF is too high for the high values of resistors you are using.

Tom... :)
Hi Tom
At this point I have a BW of 1-20KHz which is kind of important. Will this not change if I change the caps into 1UF?

Also If I change the 50K into 10K each will it not adversely affect the channel separation?

Thanks
Title: Re: LM358 saturates the output
Post by: MarkT on Jul 01, 2017, 06:44 pm
Quote
Also If I change the 50K into 10K each will it not adversely affect the channel separation?
No, the virtual ground at the opamp input takes care of that.

However as the pots are 50k you certain do not want to load them with 10k or 4k7, ideally they
would not be loaded at all.  With 10k you'd severely distort the linearity (or logarithmic response if
the pot is log law).  It would actually be better to use 100k for that reason, although
high impedances have issues with pickup and noise.  The existing 50k seems like a not unreasonable
compromise.

A better approach overall is to buffer pot wiper voltage with a unity gain buffer, then the summing
junction resistors can be a nice low (ie low noise) 1k or whatever.  For a low noise microphone preamp
you'd have to pay close attention to such issues, but that's not the case here of course.
Title: Re: LM358 saturates the output
Post by: Southpark on Jul 01, 2017, 11:19 pm
Good pickup by TG.

OP.... make sure to always include polarity symbols for polarised capacitors in circuit diagrams.

The Vac drawing (from the original diagram) isn't really AC is such..... but is a combination of dc and ac.

Also..... make sure to write the voltage levels in waveform diagrams for making things clear. DC level.... clipping level etc
Title: Re: LM358 saturates the output
Post by: TomGeorge on Jul 02, 2017, 12:36 am
Hi,
Example maximum channel separation.
Have you measured the BW?

Tom..... :)
Title: Re: LM358 saturates the output
Post by: Yoram on Jul 02, 2017, 08:52 am
It would actually be better to use 100k for that reason, although
high impedances have issues with pickup and noise.  The existing 50k seems like a not unreasonable
compromise.

A better approach overall is to buffer pot wiper voltage with a unity gain buffer, then the summing
junction resistors can be a nice low (ie low noise) 1k or whatever.  For a low noise microphone preamp
you'd have to pay close attention to such issues, but that's not the case here of course.
Thanks for this recap.

In fact there are 3 inputs and one of those inputs is actually coming from a mic x10 preamp (transistor based). So I don't think it should not make a difference.
Title: Re: LM358 saturates the output
Post by: Yoram on Jul 02, 2017, 09:04 am
Have you measured the BW?

Tom..... :)
Hi Tom,

Measured the BW ad it goes 1-25Khz
Title: Re: LM358 saturates the output
Post by: Yoram on Jul 02, 2017, 12:27 pm
Thanks all, with all the help and comments I have this circuit (see attached). It works fine but there is two points that I do not understand.

1.  At 5V VCC it has a nice clean 3vpp output (centered at VCC/2) before it gets into saturation. However if I raise VCC to 15V it can only output 5Vpp before it gets into saturation. Why the higher VCC increase the output voltage amplitude in a very small proportion?

2. Once it get into saturation the output signal, is not immediately clipped, but changes form sine wave into triangle ??

Anyone with an idea why this happens?

Thanks