What is wrong with my OP amp  - Page 1
Forum section: electronics / beginners

author: BeBuLamar
author_rank: Super Contributor
timestamp: June 02, 2023, 11:28:39 pm
content: I build and OP Amp with the LM358N chip as a 2 stage OP amp. They are configure as 2 stage both inverting so the final is noninverting. The first stage has input and feedback resistors both 10KOhms. The second stage has input resistor of 1KOhms and feedback resistor of 10KOhms to get 10x gain.It works OK but the output waveform has a some annomaly on the positive side of the sine waveformI attach 2 images from the scope.First one is the output aloneSecond one has the input and output superimposed.

author: BeBuLamar
author_rank: Super Contributor
timestamp: June 02, 2023, 11:51:25 pm
content: I tried several LM385N and same problem. Tried a CA1458E and it's fine. Strange.

author: Manul
author_rank: Super Contributor
timestamp: June 02, 2023, 11:51:49 pm
content: There is nothing wrong. It's LM358. That's how they work, the output stage has high distortion. It's crossover distortion, just not at the middle point. More pronounced when signal frequency is higher. Long story short, if you want low distortion, choose something else.

author: BeBuLamar
author_rank: Super Contributor
timestamp: June 03, 2023, 12:17:03 am
content: Yes you're right! The distortion is about the 1.9V level. If I reduce the input so that the output doesn't reach 1.9V then it's OK. In the pictures the frequency is 1KHz. When I changed the frequency to 10KHz it looked very bad.

author: srb1954
author_rank: Super Contributor
timestamp: June 03, 2023, 01:06:52 am
content: Quote from: BeBuLamar on June 02, 2023, 11:28:39 pmIt is crossover distortion, which the LM358 is well known for in audio applications. It is caused by a discontinuity in the transfer of the signal between the upper and lower halves of the class B output stage. Normally, the LM358 has enough gain that the feedback smooths out this discontinuity but at higher audio frequencies the limited internal bandwidth and reducing loop gain of the LM358 means that the feedback is insufficient to eliminate this discontinuity. Op amps intended for audio purposes usually have better designed output stages to minimise this crossover distortion.If you still want to continue using the LM358 you can sometimes alleviate this by adding a extra resistor of a few kto ground, assuming you are operating with a single supply voltage. This resistor loads down the O/P so that only the upper stage is active all the time, effectively operating in class A mode. This trick is only useful if you have a limited signal swing on the output such that the lower half of the class B stage never becomes active.

author: barshatriplee
author_rank: Regular Contributor
timestamp: June 03, 2023, 07:49:56 am
content: For your convenience, I am attaching the datasheet too:https://www.ti.com/lit/ds/symlink/lm358.pdfSee if you are experiencing more distortion than what is mentioned in the datasheet.

author: BeBuLamar
author_rank: Super Contributor
timestamp: June 03, 2023, 01:40:22 pm
content: Thank you all for pointing out the problem with the LM358N. It's OK I changed to the AC1458E and it's fine. I just have these IC laying around so if the LM358N isn't good that's OK. I just don't use it.

author: macboy
author_rank: Super Contributor
timestamp: June 03, 2023, 09:57:23 pm
content: To eliminate the crossover distortion, you can put a resistor from output to V-. This ensures that the output stage is always sourcing current and never needs to switch back and forth between sourcing and sinking. The value of the resistor must be smaller than the load resistance (current must be greater than load current).

author: MrAl
author_rank: Super Contributor
timestamp: June 04, 2023, 10:00:11 am
content: Quote from: BeBuLamar on June 02, 2023, 11:28:39 pmHi,As others have pointed out, it is most likely crossover distortion. The output stage of the LM358 has two transistors, one to pull the output high when needed, and another to pull the output low when needed. That is so that the output can both source and sink current.The problem comes in when the signal output has to source current, then sink current, then source current again, then sink current again, etc., which is usually the case with a sine wave, depending on what it is feeding. To stop that the well-known trick is to connect a resistor from the output to the most negative supply of the op amp. That means that when the output has to sink current it will do it using the resistor rather than the other transistor, so the other transistor never turns on and the sourcing transistor never turns completely off. That provides a signal that is free from cross over distortion, provided the load does ok with the resistor value chosen.Some people hate the LM358 but it's because they don't understand how to use it.One other thing you should know about though and this would be with any op amp.When using it for sine wave amplification (audio is one) the slew rate also affects the output distortion. The slew rate can change the sine wave into a semi-triangular wave if the slew rate is exceeded by the signal rate of change. This can happen with larger output levels but can go away with lower output levels. That means that the distortion free limit in frequency is not dependent on the gain-bandwidth of the op amp alone, but also on the slew rate. You can tell this is happening by testing with an input signal that is the highest frequency you intend to use it with and the highest amplitude of the output that will be needed. If you see a pure sine wave start to have straighter sides than a typical sine wave then you know the slew rate limit is kicking in. You can either go to a different op amp or just keep the signal level lower. It's interesting too that if you use a second stage after you limit the first stage amplitude, it probably wont help because then the second stage slew rate will cause the same problem as the output goes higher.

author: BeBuLamar
author_rank: Super Contributor
timestamp: June 04, 2023, 01:02:45 pm
content: Thank you! I knew that. With the CA1458E it could do up to 10KHz at 8V peak. But above that I could see the triangle shape of the waveform. I am looking for other OP amp chip to be able to get to 20KHz as I intend to use it for audio application.

author: TimFox
author_rank: Super Contributor
timestamp: June 04, 2023, 04:52:56 pm
content: Gross slew-rate limiting is obvious on the output, where the expected curved section is replaced by a straight line (from the limit value of dV/dtin V/us).Subtler slew-rate limiting can happen because of what determines the maximum slew rate in a "normal" op amp (741 and following):The input differential amplifier has a current output into an inverting amplifier with a feedback capacitor (which determines open-loop bandwidth).The slew rate limit comes from the maximum output current of the input amp flowing into that feedback capacitor.As the operation approaches the slew-rate limit, the input amplifier is approaching its maximum output current, and you can expect non-linear (large-signal) behavior of that amplifier compared to when the output current is small compared to the maximum value.See section 4.6 of Clarke and HessCommunication Circuits: Analysis and Design, pp 114-119 for a detailed description of the linear and non-linear behavior of the BJT differential amplifier (with constant current at the emitters)https://data.kemt.fei.tuke.sk/STS-Satelitne/comunication_circuits.pdf

author: magic
author_rank: Super Contributor
timestamp: June 04, 2023, 05:21:54 pm
content: LM358 would suffer similar slew limiting as 1458 or 741 types.Out of old junk, 4558/4559 type opamps are 2~4 times faster. A better old junk would be TL072 or some JRC/NJM opamps and better still - NE5532.Beware that most opamps sold on auction sites and even by some "hobby grade" suppliers are fake. Internally they are 4558 if you are lucky or 358 if you are not.

author: BeBuLamar
author_rank: Super Contributor
timestamp: June 04, 2023, 07:47:16 pm
content: My OP amp are parts from a electronic manufacturers so they are not faked. I had them for more than 20 years already.

author: TimFox
author_rank: Super Contributor
timestamp: June 04, 2023, 07:58:59 pm
content: An 8 V pk (16 V pk-pk) sine wave at 10 kHz has a maximum slew rate of 0.5 V/us (at zero-crossing).The ONSemi (formerly Motorola) data sheet does not specify slew rate, but figure 3 hints at approximately that as the slew-rate limit.With 15 V total voltage, figure 6 of that data sheet shows a maximum of 9.5 V pk-pk (4.8 V peak) at 10 kHz.https://www.onsemi.com/pdf/datasheet/lm358-d.pdfAn old rule-of-thumb to avoid what I called "subtle" slew-rate problems in audio (up to 20 kHz) is that the slew rate (in V/us) should be at least 0.5x or 1x the peak output voltage required.From that rule, for 8 V pk = 16 V pk-pk, you want maybe 5 V/us minimum. The TL071 is (typ) 13 V/us, and the 5532 is (typ) 9 V/us.

author: MrAl
author_rank: Super Contributor
timestamp: June 05, 2023, 09:30:09 am
content: Hello again,Mathematically a sine wave with no phase shift can be represented as:V(t)=A*sin(w*t)The rate of change of this is:dv/dt=w*A*cos(w*t)and one place where the rate of change is maximum is at t=0 so we end up with:dv/dt=w*ASince w=2*pi*f we have:dv/dt=2*pi*f*Aand this means that the max dv/dt with an op amp is when:2*pi*f*A=srwhere sr is the slew rate in volts per second.Since the slew rate is usually given in volts per microsecond we can change this to:2*pi*f*A=sr*1000000and that is with sr in volts per microsecond.Since the LM358 has a slew rate of about 0.5v/us we end up with:2*pi*f*A=500000and dividing by 2*pi we end up with:f*A=79577We can then easily calculate the maximum amplitude A knowing the maximum frequency f:A=79577/fKnowing the max frequency is 20000Hz we end up with:A=79577/20000which of course equals 3.98 volts, and since A is in peak volts that is 3.98 volts peak which is about 4 volts peak which is 8 volts peak to peak.This of course assumes that you have a supply voltage that can actually allow that voltage output. For the LM358 the output can swing close to the negative rail but the positive output can only get within about 1.5v of the positive rail. This means for a dual power supply circuit you would need a negative supply rail of a minimum of -4 volts and a positive rail of a minimum of +5.5 volts, or a single rail power supply of 9.5 volts in order to put out the maximum at 20kHz.Now we can also calculate the minimum slew rate needed to attain a certain peak output voltage.Starting again with:2*pi*f*A=1000000.0*sr (and sr in units of volts per microsecond again)and solving for sr we get:sr=2*pi*f*A/1000000if we wanted a peak output of 8 volts at 20000Hz then we end up with:sr=2*pi*20000*8/1000000which of course comes out to:sr=1 volt per microsecond.This follows from the fact that it is a simple linear expression, so if we got 4 volts peak from 0.5v/us then it follows that we should be able to get 8 volts peak from 1v/us.In reality though we might want to go a little higher than that for practical purposes.1.5v/us or 2v/us should get us there.It should also be pointed out that the maximum output is still limited by the power supply voltages. This means we need at the very least a plus and minus 8v power supply, or 16v single supply, but that only works with a true rail to rail output op amp. Since most op amps drop at least a little, like 0.1 volts with any current, we probably need at least plus and minus 8.5 volts as a min. For the LM358 though, the positive rail has to be at least 1.5 volts higher, so we would need a supply with about -8.5 volts and +9.5 volts to ensure proper operation.Some op amps can not get very close to either rail, so the min supply voltages then have to be higher by an amount that includes that overhead voltage:+Vs=A+VohP-Vs=A-VohNwhere +Vs is the required positive rail voltage, and -Vs is the required negative rail voltage, and VohP is the positive rail overhead voltage, and VohN is the negative rail overhead voltage. For the LM358 the negative rail overhead should be taken as about 0.1 volts, and for the positive overhead voltage should be 1.5 volts.