Author Topic: Opamp gain - use a digital pot in the feedback loop or attenuate the input  (Read 8783 times)

0 Members and 1 Guest are viewing this topic.

Offline SkimaskTopic starter

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
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.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21681
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #1 on: September 10, 2014, 08:09:42 am »
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
« Last Edit: September 10, 2014, 08:12:03 am by T3sl4co1l »
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline penfold

  • Frequent Contributor
  • **
  • Posts: 675
  • Country: gb
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #2 on: September 10, 2014, 08:33:52 am »
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.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #3 on: September 10, 2014, 08:41:28 am »
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.

I'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.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #4 on: September 10, 2014, 12:18:41 pm »
Quote
2) Use the digital pot in the feedback loop controlling the gain of the opamp.

It may become unstable with low gain.

I would use the pot on the input.
================================
https://dannyelectronics.wordpress.com/
 

Offline jeremy

  • Super Contributor
  • ***
  • Posts: 1079
  • Country: au
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #5 on: September 10, 2014, 03:57:14 pm »
(3. Use a VGA/PGA, so you don't have to worry about adding noise or screwing with bandwidth.  Downside?  More parts...)

+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.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16615
  • Country: us
  • DavidH
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #6 on: September 10, 2014, 04:19:23 pm »
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.
 

Offline SkimaskTopic starter

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #7 on: September 11, 2014, 05:27:28 am »
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...
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline SkimaskTopic starter

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #8 on: September 11, 2014, 06:40:43 am »
Circuit design so far...(worked up using that Circuit Simulated at www.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.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16615
  • Country: us
  • DavidH
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #9 on: September 11, 2014, 03:04:30 pm »
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.
 

Offline SkimaskTopic starter

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #10 on: September 11, 2014, 04:08:36 pm »
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?
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2603
  • Country: us
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #11 on: September 11, 2014, 06:23:48 pm »
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. 
 

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #12 on: September 11, 2014, 07:00:09 pm »
(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.)
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #13 on: September 11, 2014, 09:14:52 pm »
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.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline ludzinc

  • Supporter
  • ****
  • Posts: 506
  • Country: au
    • My Misadventures In Engineering
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #14 on: September 11, 2014, 09:59:27 pm »
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=1

And here is how I managed to avoid the need for split supplies:

http://ludzinc.blogspot.com.au/2014/07/multi-channel-meter.html?m=1

Best of luck!
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7377
  • Country: nl
  • Current job: ATEX product design
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #15 on: September 11, 2014, 10:46:03 pm »
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
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #16 on: September 12, 2014, 12:39:34 am »
Quote
here's how I built a programmable gain amp without needing a digital pot:

You 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.
================================
https://dannyelectronics.wordpress.com/
 

Offline ludzinc

  • Supporter
  • ****
  • Posts: 506
  • Country: au
    • My Misadventures In Engineering
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #17 on: September 12, 2014, 03:30:49 am »
Quote
here's how I built a programmable gain amp without needing a digital pot:

You don't need an external transistor to do that -> pulling the resistors to ground or hi-z by the mcu's pins is sufficient.


Yep.  See the second link!

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.

Not following what you mean here - can you elaborate?

Cheers.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #18 on: September 12, 2014, 11:38:10 am »
You can use the digital pot in the feedback loop without a problem.

You 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?
 

Offline SkimaskTopic starter

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: Opamp gain - use a digital pot in the feedback loop or attenuate the input
« Reply #19 on: September 16, 2014, 04:30:35 am »
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...
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf