Issues with OP-AMP (LM358N) - Page 1
Forum section: electronics / beginners

author: kidchemical
author_rank: Newbie
timestamp: April 03, 2020, 05:04:07 am
content: Hello EEVblog community!I am a beginner to electronics eager to learn the fundamentals of synthesizers, especially eurorack style.I have already successfully created a "Reverse Avalanche" Sawtooth oscillator using a transistor in a reverse mode, and anyone who has heard of this circuit probably knows it requires a large amount of voltage (9v+) to begin oscillation while the output is relatively low. (around 500mV+ peak-to-peak?)I've configured an OP-AMP (Lm358n) to hopefully address two issues:a. Remove DC offset (Does this only work for Op-Amps with offset pins?)b. Amplify the signal to appropriate level (~4x Gain. Works...sometimes...)Problems I am having are quite odd to me... It seems that the op-amp circuit only works briefly while the oscillator continues to oscillate. The wishful thinking part of me hopes this is only a breadboard issue making contacts but I'm afraid this might not be the case. For example, I had the circuit oscillating and amplifying correctly, I kill the power source, come back and power the circuit again, and the op-amp stops working.Also I'm not sure if this is critical information, but the Op-Amp and the Oscillator share the same voltage source.The final issue I am having is connecting a 4\$\Omega\$ speaker directly to Vout. When I do so, the output waveform @ Vout actuallychangesmy pretty saw wave into a whiny PWM sounding squelch. (change is observable on oscilloscope as well)Any thoughts or comments would be greatly appreciated!Here I've attached a circuit diagram of the Op-Amp configuration. The oscillator output feeds directly into Vin (first passing through a capacitor to remove incoming DC offset).I have temporarily also attached a 0.47uf capacitor to the output (Vout) as there is still some DC offset at the output stage. (Not shown in circuit diagram)Voltage source is 12v.I decided to use the Non-Inverting configuration as I was initially having trouble getting the Op-Amp to function at all even as a voltage follower. Using the Non-Inverting configuration ensured that the gain was at least 1.

author: xavier60
author_rank: Super Contributor
timestamp: April 03, 2020, 08:13:38 am
content: Usually if an op-amp circuit works briefly, there is something wrong with DC biasing.If the input signal is AC coupled via a capacitor, with is necessary if DC offset needs to be removed from the source, a bleed resistor needs to be placed from the non-inverting input to your ground reference.The value is typically but not necessarily the same as the feedback resistor.Don't load the output.

author: exe
author_rank: Unknown
timestamp: April 03, 2020, 09:39:35 am
content: At first glance I see two serious issues with the current approach.1) the load (4 ohm speaker) is too hight to be driven directly by an opamp, imho. I'd be careful driving anything that requires more than 10mA of current. Check the datasheet for maximum output current.2) the "virtual ground" made of a resistor divider is a wrong way to do it due to its impedance. So, either buffer it with an opamp, or use TLE2426 ("The 'Rail Splitter' Precision Virtual Ground"), or, better, start off with bipolar supply.Once those two are sorted, there, probably, will be other issues. But it's important to eliminate these two before doing anything else, as if problems are not resolved, we'll keep bumping into them.PS I'm surprised how often I see voltage divider as a power source. Where did you read this advice?PPS don't forget about decoupling capacitors.

author: wraper
author_rank: Unknown
timestamp: April 03, 2020, 10:01:23 am
content: Quote from: kidchemical on April 03, 2020, 05:04:07 amGain is not 4 but 2.2. You should consider that R3 and R4 are part of feedback loop. Basically you can calculate R3 and R4 as parallel resistors = 500 Ohm, then add in series to R2. So if R2 was connected to real GND, equivalent would be 830 Ohm.QuoteSpeaker resistance is too low for opamp and you did not say were you connected second lead of the speaker. You cannot simply connect it to V- and expect it working fine.

author: wraper
author_rank: Unknown
timestamp: April 03, 2020, 10:12:00 am
content: Also you did not write how Vin is connected. If it's connected through capacitor, circuit won't work. If directly, what is signal source matters a lot.

author: magic
author_rank: Super Contributor
timestamp: April 03, 2020, 10:29:18 am
content: If Vin is connected to the signal generator through a capacitor then the circuitwillwork, for the short time that it takes for the Vin side of the capacitor to charge up due to opamp's input bias current to a voltage beyond the opamp's valid input range.Solution: add 10kΩ between Vin and Vg.Also add some 1000µF or more in parallel with each of R3 and R4.Connect the other terminal of the speaker to Vg if you have it connected to the negative rail now. Or use an output capacitor, that's fine.As others said, LM358 is a wimpy opamp and it won't drive a 4Ω speaker to any serious loudness. It will start to clip at some tens of mV peak.

author: wraper
author_rank: Unknown
timestamp: April 03, 2020, 10:34:03 am
content: Quote from: magic on April 03, 2020, 10:29:18 am1000uF is too much. And you should not add it in parallel to both resistors. Adding in parallel to R4 is enough to get AC gain of 4 but adding second capacitor will only make things worse.

author: Circlotron
author_rank: Super Contributor
timestamp: April 03, 2020, 11:42:12 am
content: Quote from: wraper on April 03, 2020, 10:01:23 amIn relation to that, make R1 and R2 say 100x their present value. That will greatly reduce the effect of R3 and R4 on the gain.

author: xavier60
author_rank: Super Contributor
timestamp: April 03, 2020, 11:53:06 am
content: With Vg as ground reference, R3 and R4 have no affect on gain, only limits the maximum output.

author: wraper
author_rank: Unknown
timestamp: April 03, 2020, 12:25:29 pm
content: Quote from: xavier60 on April 03, 2020, 11:53:06 amPlease explain how they suddenly lose all of their resistance when used as virtual ground.

author: StillTrying
author_rank: Super Contributor
timestamp: April 03, 2020, 12:49:13 pm
content: Quote from: wraper on April 03, 2020, 12:25:29 pmIt depends on whether the virtual ground is used just as an internal V/2 biasing thing, or the V/2 becomes a new GND for the inputs and outputs. Just to add to the confusion there's no ground(s) anywhere on the schem.

author: wraper
author_rank: Unknown
timestamp: April 03, 2020, 01:04:18 pm
content: LOL

author: StillTrying
author_rank: Super Contributor
timestamp: April 03, 2020, 01:21:13 pm
content: Those 2 are equal only if GND = -Ve, half of us are assuming the V/2 is making a (not very good) +/- power supply with the new V/2 = GND.But from the text it looks like GND is the -Ve, and the V/2 is just internal biasing, butI have temporarily also attached a 0.47uf capacitor to the output (Vout) as there is still some DC offset at the output stage.Yes the output would be at DC = V/2, ignoring all the other problems.

author: wraper
author_rank: Unknown
timestamp: April 03, 2020, 01:31:17 pm
content: Quote from: StillTrying on April 03, 2020, 01:21:13 pmThose are 100% equal. If you need anything other that half of voltage supply, just choose different resistances for divider in a way that their total impedance remains the same as for variant with 3 resistors.QuoteHard to understand what you wrote here. But virtual ground made by resistive divider has nothing to do with real GND. If there is real GND in the middle of bipolar supply, you don't need/use virtual ground to begin with. What's not in the circuit is not in the circuit, no imaginary parts please.

author: Siwastaja
author_rank: Super Contributor
timestamp: April 03, 2020, 01:33:13 pm
content: Quote from: StillTrying on April 03, 2020, 01:21:13 pmGND is just an arbitrary label. The schematic in the OP message is complete and clear, showing unipolar power supply and the opamp negative supply powered from the supply negative, same as the lower leg of the divider. Assuming the circuit is actually built as in the schematic, wraper is right (as usual).

author: xavier60
author_rank: Super Contributor
timestamp: April 03, 2020, 01:36:20 pm
content: "I have temporarily also attached a 0.47uf capacitor to the output (Vout) as there is still some DC offset at the output stage. "Gives me the impression that the DC offset is something much less than 6V.

author: StillTrying
author_rank: Super Contributor
timestamp: April 03, 2020, 02:29:05 pm
content: I agree with much of wraper's and Siwastaja's points, but I can still see where much of the V/2 confusion is.If the outputhasto drive a speaker I might suggest a LM386.Quote from: xavier60 on April 03, 2020, 01:36:20 pmOP:"The oscillator output feeds directly into Vin (first passing through a capacitor to remove incoming DC offset)."With no DC path to Vg or anywhere else on the +IN input I'd expect the output's DC offset to be more than 6V, - without the 4R speakerdirectly connectedto the output. Biasing already mentioned in posts above.

author: Zero999
author_rank: Super Contributor
timestamp: April 04, 2020, 10:55:45 am
content: Yes there appears to be some confusion around ground and Norton's Theorem.Ground is just a point from where all voltages are measured. Refer to the circuits in the schematic below. They're all electrically identical, but the voltages measured differ because the common from where the voltages are referenced to changes. The 0V is just where the black lead of the multimeter is connected.When two resistors form a potential divider, the impedance seen at the node where they meet is equal to their values connected in parallel, so with 1k resistors, your circuit's earth node has an impedance of 500R. It's the extra 500R resistance to ground which is reducing the gain of the amplifier.Since the LM358 has two op-amps in the package, the spare one could be used as a unity gain buffer to reduce the impedance of the potential divider to near zero. It also means the resistor values can be increased to reduced power dissipation. C1 and C2 are needed to provide supply decoupling and reduce the noise on the virtual ground node.

author: Siwastaja
author_rank: Super Contributor
timestamp: April 04, 2020, 11:20:13 am
content: One way to avoid extra confusion in the already confusing subject is to completely avoid terms "virtual ground" or "virtual earth", and especially using any of the ground symbols to denote them.It's just a node, a net, with a function, like any other net in the circuit. It's typically connected to only maybe 2-3 places, it's not like the "ground" net which tends to be the return path for all (or most) power and signal currents (justifying "special" treatment.) When well regulated and bypassed, it's more like a power rail.Call it Vbias, Vref, or whatever instead.Just IMHO on a matter of subjective opinion.

author: wraper
author_rank: Unknown
timestamp: April 04, 2020, 12:55:47 pm
content: Quote from: Zero999 on April 04, 2020, 10:55:45 amOnly one capacitor should be used unless you have a good reason to do otherwise. Second capacitor only worsens performance. When both of them are used, they start working as decoupling caps for the rest of the circuit. With one cap to real GND you have stable virtual GND in reference to real GND (or whatever point you connected this capacitor to). With 2 capacitors, you will have all voltage instability to transfer into virtual GND. Not to say you use part which is not needed.

author: iMo
author_rank: Super Contributor
timestamp: April 04, 2020, 01:04:49 pm
content: I wonder why to use even 1 capacitor there. I've been using C2 but always in doubt whether I do it properly. Something is telling me there shouldn't be anyPS: there should be one capacitor wired at V1.

author: Siwastaja
author_rank: Super Contributor
timestamp: April 04, 2020, 02:16:27 pm
content: If nothing else, the capacitor reduces the Johnson noise of the high-value resistor divider.Obviously, it also filters the power supply ripple coming from the +6V node. This is important, because the opamp itself has some power supply ripple rejection as well, so it can handle it without coupling it to the signal, don't do it by yourself.By adding the second capacitor, you are coupling some of the power supply noise to that node.

author: Zero999
author_rank: Super Contributor
timestamp: April 04, 2020, 02:21:48 pm
content: Quote from: wraper on April 04, 2020, 12:55:47 pmWhy?Assuming a the power supply has a very low AC impedance, the amount of ripple is passed through to the output is the same, irrespective of whether only one or two capacitors are used. Only one capacitor on the negative side, does drastically reduce the ripple on the negative rail, but it doubles the ripple on the positive side, so the net ripple i.e. -V-V+ is the same.VG 1 cap low Z.png.asc(1.14 kB - downloaded 41 times.)With two capacitors, there's equal ripple on both rails and as you said, both rails become bypassed, hence it's better to use two, rather than one capacitor.VG 2 cap low Z.png.asc(1.28 kB - downloaded 49 times.)I think you're confusing it with a single supply op-amp configuration, where everything is referenced to either the positive or negative rail and only one capacitor should be used because we want the bias point to be constant with respect the reference point. With this circuit the bias point is the reference point, so it's different.

author: iMo
author_rank: Super Contributor
timestamp: April 04, 2020, 02:28:24 pm
content: With both or without both you get the same result..

author: Zero999
author_rank: Super Contributor
timestamp: April 04, 2020, 02:40:06 pm
content: Quote from: imo on April 04, 2020, 02:28:24 pmIf the supply has a higher impedance, you get better results with two capacitors, but it would be better to put one of the capacitors across both supplies though.In all honesty, I don't know which is worse: double the ripple on one rail and none on the other, or half the ripple on both.

author: iMo
author_rank: Super Contributor
timestamp: April 04, 2020, 02:42:53 pm
content: Quote from: imo on April 04, 2020, 01:04:49 pmThat is I've been asking myself since everQuote from: Zero999 on April 04, 2020, 02:40:06 pm

author: wraper
author_rank: Unknown
timestamp: April 04, 2020, 02:43:49 pm
content: Quote from: Zero999 on April 04, 2020, 02:21:48 pmYou should have separate capacitor to bypass power rails. With what you have shown, virtual GND is not stable against any of power rails. With one capacitor it will be stable against one of power rails. And if you use such virtual ground with one cap say in audio amplifier, you then can connect series capacitor with input/output and input/output will be referenced nicely to real GND. If you use two capacitors in virtual ground, you will inject noise into the signal.EDIT:http://www.ecircuitcenter.com/Circuits/opinv_ss/opinv_ss.htm

author: iMo
author_rank: Super Contributor
timestamp: April 04, 2020, 02:52:29 pm
content: A more "complex" example you may play with..

author: wraper
author_rank: Unknown
timestamp: April 04, 2020, 02:55:17 pm
content: Also consider that with one cap, you have low pass RC filter. With 2 caps you don't have it.

author: Zero999
author_rank: Super Contributor
timestamp: April 04, 2020, 03:30:01 pm
content: Quote from: wraper on April 04, 2020, 02:43:49 pmThat's different, because you've got the reference on the negative rail, rather than the midpoint, so it's not a virtual ground circuit. There's a subtle difference. In some cases the capacitor is better on positive side, if everything is referenced to the positive.In the case where all of the 0V nodes go to the centre point of the power supply, I see no problem with having both capacitors. It seems rather arbitrary.

author: wraper
author_rank: Unknown
timestamp: April 04, 2020, 03:45:24 pm
content: Quote from: Zero999 on April 04, 2020, 03:30:01 pmI see no problem using none of capacitors at all as they do nothing good for virtual ground when both of them are used. Also due to their tolerance (imbalance), you won't get exactly middle point when voltage ripple is present.

author: Zero999
author_rank: Super Contributor
timestamp: April 04, 2020, 05:12:23 pm
content: Quote from: wraper on April 04, 2020, 03:45:24 pmA capacitor will reduce the noise, both from the resistors and the op-amp bias currents, so I agree, only one is required and it can be relatively small (10µF would give a lower cut-off of 320mHz, with two 100k resistors, so is overkill). All it does is filter out the noise. It makes no difference to the ripple and the op-amp's supply rejection still has the same amount of "work" to do, whether it's there or not.

author: StillTrying
author_rank: Super Contributor
timestamp: April 04, 2020, 10:36:53 pm
content: Quote from: Siwastaja on April 03, 2020, 01:33:13 pmComplete and clear, you must be kidding. With no ground shown on the OP's schematic almost everyone would assume that the first part of it is forming a virtual +/- supply for the op amp with Vg being the signal ground, how would anyone ever guess that what looks like the -V supply is actually the signal ground.Zero999Justin case you've missed it, the OP's post is nothing at all to do with split supplies or virtual grounds, but about the only clue I can see that it's not used as a split supply is in the text of the OP:"Also I'm not sure if this is critical information, but the Op-Amp and the Oscillator share the same voltage source."I have no idea why us, or at least me! got so much stick from wraper & Siwastaja for assuming Vg was the virtual ground / signal ground of a split supply.

author: wraper
author_rank: Unknown
timestamp: April 04, 2020, 10:57:19 pm
content: Quote from: StillTrying on April 04, 2020, 10:36:53 pmFirst of all it's not really a virtual ground but just bias. Virtual ground usually means there is follower circuit so such virtual ground can at least provide some current without voltage drifting and is used for larger part of the circuit. Secondly I didn't say anything wrong about calling it a virtual ground as such. Just about some weird assumptions of how it works.

author: wraper
author_rank: Unknown
timestamp: April 04, 2020, 11:02:35 pm
content: According to description and still without OP's answers to my questions currently it's like this:

author: kidchemical
author_rank: Newbie
timestamp: April 05, 2020, 02:55:39 am
content: Wow guys I feel grateful to have so much input from this community, thanks a bunch!I will tell you one thing, adding the "Bleeding Resistor" to my "Virtual Ground" between the capacitor and non-inverting pin seemed to solve the issue!Thanks xavier60 & magic!I am still trying to wrap my head around a lot of the theory presented so bare with me while I go back and try to answer all of the questions here!I understand that the 330resistor from the feedback VGND or "DC Reference" I suppose was redundant so I removed that as well.I ended up changing my feedback resistance to something like 39k and 1k to get a much larger gain which I am looking for!When I placed a capacitor from my virtual ground to my V-, my signal was amplified a bit, keeping it there.So now my sawtooth oscillates 5v/-5v which I am pleased with, I really have no intention to drive a speaker necessarily but to actually be a "line level" output that I can connect into an effects module.

author: Siwastaja
author_rank: Super Contributor
timestamp: April 05, 2020, 08:49:11 am
content: Quote from: StillTrying on April 04, 2020, 10:36:53 pmYou know, adding the ground symbol somewhere does not change the circuit behavior the slightest. Ground is just one arbitrary circuit node, it has no special physical properties. SPICE simulators, though, AFAIK, require the ground symbol to be putsomewherein order to simulate (which is understandable - SPICE simulators are able to report single node voltages (instead / in addition to voltage differences between two nodes), and for that, you need one specified reference point.The schematic is complete because there are no floating nodes, opamp power is also connected directly (unipolarly) to the 12V voltage source. It's clear because the nets are properly labeled (inlucing opamp power rails), and drawn in a uncluttered way. I see absolutely nothing wrong* with it; I would use the ground symbol for the "V-" net, though, but it doesn't change anything.*) wrong as in the way the schematic is drawn; functionally, it's clearly wrong because the circuit does not work, hence this topic!You can add the missing ground symbol to any node (some are moreconvenientthan others, though). There is no need to "assume" anything about the schematic, it can be analyzed using the normal circuit analysis methods, like Kirchoff laws, opamp "rules of thumb", or simulated using SPICE, as long as the ground symbol is added to some node so SPICE can refer the voltages to that point.I think your confusion is a good example why terminology such as "virtual ground" is dangerous. I'm baffled, the circuit in the OP is extremely simple. At least some of the issues have been correctly listed, as well, one being the lack of biasing Vin (to counteract input bias currents) because we were later told that there is an AC coupling capacitor. The hint that this is likely the problem is given by the fact that the circuit seems to workbriefly.

author: Zero999
author_rank: Super Contributor
timestamp: April 05, 2020, 12:18:20 pm
content: Quote from: Siwastaja on April 05, 2020, 08:49:11 amYes, I'm sure he knows that the ground symbol is arbitrary and theoretically shouldn't change the operation of the circuit, however in practice it can do, because it implies where all the inputs and outputs are referenced to, which isn't shown in the schematic in the original post.Quote from: kidchemical on April 05, 2020, 02:55:39 amAwhile ago, another member here, audioguru, did a schematic showing the most common op-amp applications, both using a single and dual supply configurations. Here's my version. You want the non-inverting, single supply one which is the top right. I'd recommend using higher values though: R1 = 10k, R2 = 3k3 and just use 10k where it says ½R1, which was just to minimise the effects of bias currents, but that's not important in this application. All capacitors are 10µF aluminium.