OPAMP following a square wave - Page 1
Forum section: electronics / beginners

author: Aeternam
author_rank: Unknown
timestamp: March 10, 2016, 12:13:21 pm
content: Hey gang,I have an LM324 configured as voltage follower. It is hooked up to a DAC through a voltage divider, the DAC is generating a square wave of 0 - 5V (see schematic). I hooked up my scope to this circuit to see how fast the OPAMP would react to a change on its positive input. Which is where I found something strangeThe first screenshot shows the OPAMP doing its deed to ramp up the output. It's not perfectly following the input signal but I guess it's doing an OK job.The second screenshot shows what's happening when the positive input falls from 0.33 to 0V. I don't understand where those ripples come from? As you can see on the 3rd screenshot they start way before the input starts falling off, so I suppose the DAC is not at fault.I should probably mention that there are a few other components on the same breadboard (7812, 7805, another LM324, a LED, a few caps). Oh and the other 3 OPAMPs on the IC are properly terminated.What the hell is going on here?

author: RobK_NL
author_rank: Frequent Contributor
timestamp: March 10, 2016, 12:52:40 pm
content: Quote from: Aeternam on March 10, 2016, 12:13:21 pmFrom the fact that those "ripples" appear just before the transition, it is almost certainly the DAC's digital input coupling into your analog output.

author: kg4arn
author_rank: Unknown
timestamp: March 10, 2016, 01:16:48 pm
content: Try probing the op amp output with the 10x setting on the probe with a 4.7 or 10K resistor in series between the output and the probe. If you are placing the probe directly on the output pin, the probe capacitance may be causing the loop to oscillate especially on the 1x setting where the capacitance is much greater. Just a thought.

author: idpromnut
author_rank: Unknown
timestamp: March 10, 2016, 01:21:25 pm
content: Gentlemen, check your decoupling, something suspicious is going on there

author: AndersJ
author_rank: Frequent Contributor
timestamp: March 10, 2016, 01:26:53 pm
content: Your decoupling capacitor needs to be connected properly.The op-amp works near ground, but not AT ground level.The DAC needs to be grounded.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 10, 2016, 02:35:45 pm
content: Put a small capacitor from +in to GND, and probably assorted other filtering. Most importantly is the kind of filtering that can't be expressed on the schematic. If you have digital switching currents flowing around the LM324, it will pick those up.Shitty bipolar amps like LM324 don't respond to high frequency signals, proportionally; rather, they rectify them into an offset. Anything from 10 to 1000 MHz will do. You can very easily get signals in that range, which are beyond your scope's capability to see, with readily available digital ICs.You should also have a pre-load resistor from OUT to GND, about 1-10k. This will keep the output in class A operation, at least for some of its range. LM324 is about the worst thing you can attach to a DAC -- unless you have good reason to shave every cent and have no need for a nice voltage output.Tim

author: danadak
author_rank: Super Contributor
timestamp: March 10, 2016, 02:39:44 pm
content: The LM324 is unity gain stable at low C loads. See attached response for C = 0and C = 50 pF. Note the 50 pF load chart shows reduced phase margin, eg. stability.The V divider, very high Z elements ? Like in the 100K ohms + element values ?If so you can get stray pickup other signals in your lab.The second pic, I take it green is output of LM324, violet the input to 324. A 324should not show that kind of ripple. It does have a slew rate of ~ .5 V/uS so thatlimits its step response significantly.Bypassing critical, supply pins should have a .01 and .1 uF ceramic on them, aswell as a suitable bulk, like tantalum. Figure the tant size based on load drivingimpedance and I = C x dV/dT, or C = (I x dT) / dV, what is the droop you wantto live with on supply pin...Pay attention to any ground loops. That adds L to the ground path, and could bethe cause of unexpected ripple. Grounds, analog, should be single point groundingsystem where possible.Some ap notes on noise -https://www.dropbox.com/s/2h96beh1fbvz4e2/noise_notes.zip?dl=0https://www.dropbox.com/s/ruaf9booe17jk8n/PCB%20Layout.zip?dl=0Regards, Dana.

author: Audioguru
author_rank: Super Contributor
timestamp: March 10, 2016, 04:53:24 pm
content: EVERY time somebody asks what causes his circuit to make weird output signals it was wired on a solderless breadboard with intermittent contacts and stray coupling caused by its many rows of contacts and long jumper wires all over the place. Frequently its rows and jumpers are antennas that pickup all kinds of external interference. Use a pcb instead.

author: suicidaleggroll
author_rank: Super Contributor
timestamp: March 10, 2016, 04:59:05 pm
content: You only have one wire coming from your DAC in that schematic. Where is its ground reference?Your decoupling of the op-amp is also quite...interesting. Your cap needs to run between V+ and V-, as you've drawn it those caps are doing absolutely nothing.

author: Aeternam
author_rank: Unknown
timestamp: March 10, 2016, 04:59:41 pm
content: You guys are the best, thank youI will check out the different pointers and report back on what I found

author: tggzzz
author_rank: Super Contributor
timestamp: March 10, 2016, 05:37:44 pm
content: Quote from: Audioguru on March 10, 2016, 04:53:24 pmYes, indeed, breadboards are the spawn of the devil.But there are perfectly satisfactory halfway houses that work up to UHF. Dead-bug and manhattan techniques spring to mind.

author: alsetalokin4017
author_rank: Super Contributor
timestamp: March 10, 2016, 07:27:01 pm
content: Try as I might, I can't seem to reproduce the OP's problem. I am getting relatively clean and accurate output signals. I get a single switching transient on LE and TE but nothing like the oscillations and wobbly ramp that Aeternam is getting.I am using:A breadboardA KA324 (unfortunately no LM324 in my stash)Metal-film resistorsA cheapo DDS FG to produce a 0-5V square pulse train at 1 kHz with 50 percent duty cycle (this produces a much higher slew rate for the input signal but the output signal has a slower slew rate of course)I have tried:unused outputs/inputs floating100nF directly between pins 4 and 11 of the LM324 or no decoupling1x or 10x probe attenuationdifferent frequencies

author: Aeternam
author_rank: Unknown
timestamp: March 10, 2016, 10:41:38 pm
content: Ok so I dug a bit deeper and found that the LM324 is not to blame. It's the DACIts output is picking up the clock signal from the I2C bus used to control it -- which explains why the signal deteriorates just before the DAC drops the voltage. I haven't found a way around this yet. The DAC is on a breakout board (the one from Adafruit) so my hands are a bit tied there.Anyways. Reducing the voltage by an order of magnitude (down to 47k/3.3K) seems to reduce the amount of pickup considerably. I'm not sure why that is, anyone willing to give me a pointer to the mechanics at work here?After reading your posts it looks like it would be a prudent approach to reconsider my decouplingsBut that will be for tomorrow, I'm turning in now.Thanks again for all the help, much appreciated.

author: danadak
author_rank: Super Contributor
timestamp: March 10, 2016, 11:01:36 pm
content: You could always implement a S/H timed to hold the DAC valueafter its settled. Or use a LPF after DAC. All of course have timingissues, whose significance depends on your sampling rate.Regards, Dana.

author: uncle_bob
author_rank: Unknown
timestamp: March 11, 2016, 12:36:41 am
content: HiIf you want clean signals, start with the ground. You need a nice copper sheet or something similar to tie everything down to. Any part more than 1/4" off of that sheet does not count as "grounded". The digital stuff needs to be *much* closer to ground. The digital edges are likely fast enough that 0.01" (no not a typo) is a good guideline for both the ground pins and the high speed conductors spacing off ground.Yes, you *can* back off of that a bit. A few years experience and a couple years at school will let you figure out when.===Now that the ground at least has a chance of being quiet, you need good supply rails. That involves bypassing each supply pin to ground at the IC with at least 0.1 uf. It also means "bulk bypassing" that is appropriate to what you are doing. For analog, start with 10 uF of ceramic or tantalum and another few hundred uF of electrolytic. That bypassing goes on each rail and it all ties to your ground sheet. Can you back off? Sure, after a few years and some courses you will get a pretty good feel on how much you can back off. You may also find that the guidelines above are not enough for what you are trying to do.====At this point you at least are set up to start hooking up parts. Solder a few down and check things out. Solder a few more and check them. Don't try to do it all at once. Doing this on a plugin breadboard is fine as long as you accept that there will be noise all over the place. You have to do it another way to keep things quiet.Yes, you could lay out a pc board for your "gizmo". It normally is easier to womp up a circuit point to point than laying out a board. If you do a board, all the same rules apply.Bob