Opamp gain - use a digital pot in the feedback loop or attenuate the input - Page 1
Forum section: electronics / projects

author: Skimask
author_rank: Super Contributor
timestamp: September 10, 2014, 06:10:42 am
content: Using an AD9833 to feed (.6v AC coupled) an opamp (inverting configuration) and get a usable signal out of it.Two methods to control the output levels. Which is "better"?1) Set a fixed gain at the opamp itself. Use a digital pot to 'attenuate' the input. So, say I'm running the opamp at +/-5v, with a 1VAC input, I'd fix the gain at 10, and use a digital pot at the input to vary the level of the output signal.Advantage - allows me to fairly accurately control the upper limit avoiding clipping; any capacitance in the digital pot itself would be AC coupled to the opamp input anyways and not going to matter at the output.Disadvantage - ummmm....where's the missing trap?2) Use the digital pot in the feedback loop controlling the gain of the opamp.Advantage - ummmm....what is any possible advantage?Disadvantage - Any capacitance caused by the digital pot is going to affect the high freq roll off; If the digital pot is a break-before-make type, it'll cause the loop to open up for a sub-fraction of a second causing the output to saturate and from which it'll likely need another fraction of a second to recover from; lower limit isn't easily controllable.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 10, 2014, 08:09:42 am
content: What bandwidth?1. Generally good, but loses noise floor to the extra resistance and gain.2. Noise is better (you're only changing the resistance that needs to be there for the amp anyway), but the distributed capacitance of the pot can cause nasty oscillation problems (or if you're interested in step response, ugly settling).In both cases, you're hard limited by the bandwidth of the digital pot itself (usually in the 100s kHz), but in #2, you're limited by some fraction of that further, in order to ensure stability of the op-amp.I don't know that digital pots are make-before-break, or vice versa. They're probably fairly synchronous (within a fraction of a microsecond?), being CMOS switches and logic. If your op-amp is slow, it's certainly not going to saturate in that time -- but you could potentially still get an audible pop glitch. You'd want to check the datasheet in detail to see what it does, or just try it and see.If neither bandwidth nor noise is a problem (audio frequencies or DC), do whichever. I'd suggest #1, so you don't have to worry about compensation in #2.(3. Use a VGA/PGA, so you don't have to worry about adding noise or screwing with bandwidth. Downside? More parts...)Tim

author: penfold
author_rank: Frequent Contributor
timestamp: September 10, 2014, 08:33:52 am
content: Personally I would prefer to use the pot to attenuate the signal before the amp. This means that you have much more control over your opamp compensation and feedback. I wouldn't worry about noise too much since you're already dealing with quite a large signal.

author: mikerj
author_rank: Super Contributor
timestamp: September 10, 2014, 08:41:28 am
content: Quote from: penfold on September 10, 2014, 08:33:52 amI'd go for this as well, you won't be able to compensate the op-amp properly over a wide range of gains. Also, if you need adjustment down to zero output on the op-amp then you have to use an attenuator rather than gain adjustment.

author: dannyf
author_rank: Super Contributor
timestamp: September 10, 2014, 12:18:41 pm
content: QuoteIt may become unstable with low gain.I would use the pot on the input.

author: jeremy
author_rank: Super Contributor
timestamp: September 10, 2014, 03:57:14 pm
content: Quote from: T3sl4co1l on September 10, 2014, 08:09:42 am+1. I would argue even that you do not need more parts, and getting BW in the MHz is easy.Digikey has tons of these.

author: David Hess
author_rank: Super Contributor
timestamp: September 10, 2014, 04:19:23 pm
content: I would use the digital pot at the output or the input instead of using to to alter the operational amplifier's feedback network. Doing so allows optimum compensation of the operational amplifier if necessary and avoids excess capacitance at the summing node which can cause problems.In the case of an inverting amplifier, depending on accuracy requirements you may have to use the digital pot at the output because otherwise the finite input impedance will cause a gain shift as the digital pot's value is changed.If you do use the digital pot as part of the feedback network, then some capacitance may be added between the output and inverting input to swamp the effects of changing capacitance from the digital pot.

author: Skimask
author_rank: Super Contributor
timestamp: September 11, 2014, 05:27:28 am
content: All noted. I'll go with attenuating the input rather than trying to mess with the gains.Bandwidth - absolute top end is 1Mhz, but will be down around audio freq's the majority of the time.Phase shift won't hurt any as I'm not comparing the input to the output as such, but will keep it in mind in case I get any oscillation.PGA OpAmps - I checked into them. Most of the 'affordable' ones are 6 bits or so. More than 6 bits is more $$$ than I care to spend. Adding a digital pot is cheaper in most of those cases.Switching 'glitches' with the digital pots - Noted. I'm using the AD5204 & AD5206 types. I thought the datasheet said they were break-before-make. Turns out the datasheet says it's effectively neither case, but I do see glitches now when I change settings.I've got a couple circuits I'm working with. Will upload them sooner or later...

author: Skimask
author_rank: Super Contributor
timestamp: September 11, 2014, 06:40:43 am
content: Circuit design so far...(worked up using that Circuit Simulated atwww.falstad.com...love that page... and reworked using LTSpice and generic opamp parts...love that program too)#1 - The DDS section.Using an AD9833 DDS chip to make the signal, .65V output. Thru a ~7.8x gain amp, thru a 100K digital pot, AC coupled, adjust the offset with the lower pot, finally into the "power" opamp. Obviously, certain settings off the gain and offset pots will make it clip at one end or the other, but not worried about that. That situation will be avoided in software once I get it built up and characterized (eg. limit the gain with maximum offset one way or the other, and so on...)Freq's in this case will be limited to about 40Hz up to maybe 100Khz, with the absolute top at 1Mhz mainly limited by the AD9833.#2 - The ADC input section.Takes an AC signal, 0 to +/- 15VAC, above or below zero (or centered on zero, whatever), buffers it, attenuates it, mixes it with an offset, then re-amplifies that result to make it stay with the MCU's AD input limits (eg. 0-3.3v or thereabouts). Again, various combinations of input voltages, attenuation (or lack thereof), and offset can cause the final output signal going into the ADC to be out of range, but will be avoided in software once built up and characterized.

author: David Hess
author_rank: Super Contributor
timestamp: September 11, 2014, 03:04:30 pm
content: In both cases you are driving an inverting amplifier with the digital pot. The input impedance is going to change making the gain non-linear which may not be a problem but that high pass filter is also going to change cutoff frequencies.If you want to avoid that, then the pot needs to be buffered although I have seen old designs which use two pots so one could compensate the other so the output impedance is fixed.If you do buffer it, then you are trading gain error for common mode error.

author: Skimask
author_rank: Super Contributor
timestamp: September 11, 2014, 04:08:36 pm
content: Yep! Sure will. I finding out that opamps are tricky things to do right...the first time...the second time...the thirty-seventh time...etc.Buffer each pot's wiper independently? Or would buffering the point where they sum be good enough?

author: ajb
author_rank: Super Contributor
timestamp: September 11, 2014, 06:23:48 pm
content: You want to buffer the wiper of each pot so that the currents in the summing (and feedback) networks don't influence the currents in the offset and attenuation networks. Think about what happens to the currents flowing through your offset divider as the voltage at the summing point changes, and what those currents do to the voltage at the wiper of the offset pot without a buffer there.

author: SirNick
author_rank: Frequent Contributor
timestamp: September 11, 2014, 07:00:09 pm
content: (PS: You can download that Falstad sim and run it offline. I have it on all my computers -- it's the most efficient scratchpad I've found.)

author: nctnico
author_rank: Super Contributor
timestamp: September 11, 2014, 09:14:52 pm
content: You can use the digital pot in the feedback loop without a problem. A long time ago I revised a design which used that method and it worked very well. Using the pot at the input just causes more noise because the amplification is always at the maximum.

author: ludzinc
author_rank: Unknown
timestamp: September 11, 2014, 09:59:27 pm
content: For what it's worth, here's how I built a programmable gain amp without needing a digital pot:http://ludzinc.blogspot.com.au/2014/07/microcontrolled-analogue-gain.html?m=1And here is how I managed to avoid the need for split supplies:http://ludzinc.blogspot.com.au/2014/07/multi-channel-meter.html?m=1Best of luck!

author: tszaboo
author_rank: Super Contributor
timestamp: September 11, 2014, 10:46:03 pm
content: You will never get the high frequency signal through a digital pot. The key is to use a DDS which has "full scale adjust" pin like the AD9832 or there are others. You put a DAC, buffer it, and feed this signal into the pin through a resistor. There is an appnote for this, although this explains it slightly differently.http://www.analog.com/static/imported-files/application_notes/AN-423.pdf

author: dannyf
author_rank: Super Contributor
timestamp: September 12, 2014, 12:39:34 am
content: QuoteYou don't need an external transistor to do that -> pulling the resistors to ground or hi-z by the mcu's pins is sufficient.To get better DC performance, you could use a divider on the output and then put a resistor from the middle of the divider to the inverting pin.

author: ludzinc
author_rank: Unknown
timestamp: September 12, 2014, 03:30:49 am
content: Quote from: dannyf on September 12, 2014, 12:39:34 amYep. See the second link!Quote from: dannyf on September 12, 2014, 12:39:34 amNot following what you mean here - can you elaborate?Cheers.

author: mikerj
author_rank: Super Contributor
timestamp: September 12, 2014, 11:38:10 am
content: Quote from: nctnico on September 11, 2014, 09:14:52 pmYou can't state that as a fact for every possible case. It may be entirely possible to use a digitpot in the feedback loop without problems in some designs, but equally it can also cause the problems that others have mentioned.Unless the gain of the op-amp is very high, or it's a particularly noise sensitive design then the reduction in SNR with an attenuated input is unlikely to be a problem. How do you think almost every hi-fi amplifier ever made works?

author: Skimask
author_rank: Super Contributor
timestamp: September 16, 2014, 04:30:35 am
content: OK...it's all good, works like a champ...based on the inputs given above...Buffered the wiper's of the digital pots. Put the digital pot's on the inputs, attenuating the inputs rather than adjusting loop gains.Most of the amplified noise that may or may not occur can be taken care of in software. Don't have terribly high gains in any of the opamps, 10x at most in one section.TCA0372 opamp used on the output bit me in the ass though. Didn't notice the 1.3V/us slew rate in the datasheet when I selected it, only saw the 1.7Mhz GBWP. Trying to swing approx +/-10v at a couple of the outputs. Not going to happen at much more than ~65Khz or so. Would like a bit higher, maybe 100Khz at most. It's good enough for now since I know one of it's limitations. Shouldn't be that hard to find a higher performance opamp in the same SO16W package and replace it later.Next "hurdle"...slow charging a 4 cell NiMH batt pack off USB without letting the smoke out of the port...(using that 4 cell NiMH pack to drive an LM2588 to give me +/-12v for the opamps). Figured I'd double whatever the USB V+ is and current limit that into the pack, setting the current limit at whatever limits the USB current to less than 100mA. Another topic...another day...