# gain control

Discussion in 'General Electronics Chat' started by bug13, May 26, 2013.

1. ### bug13 Thread Starter Well-Known Member

Feb 13, 2012
1,213
38

Hi guys

I want to control the gain of the op amp in a current sensing application, what is the practical way to do that? thanks.

2. ### nigelwright7557 Senior Member

May 10, 2008
488
71
Make R1 a potentiometer.

3. ### bug13 Thread Starter Well-Known Member

Feb 13, 2012
1,213
38
Sorry I should have mention in my OP, I want to control it electronically, considering cost and part count ect, there is a MCU in other part of the circuit.

PS: the output of the op amp is fed to the ADC of a MCU

4. ### Ron H AAC Fanatic!

Apr 14, 2005
7,050
657
bug13 likes this.
5. ### crutschow Expert

Mar 14, 2008
13,475
3,362
Depends upon how many gain steps you need. If only a few, you could use a multiplexer or analog switch and several R2 resistors in series. The mux/switch selects the tap point off the resistor string that goes to the minus (-) input which determines the gain. That configuration avoids any effect the mux/switch resistance has on the gain.

bug13 likes this.
6. ### bug13 Thread Starter Well-Known Member

Feb 13, 2012
1,213
38
I am not quite understand this configuration here, can you explain it a little bit more please, thanks!

7. ### crutschow Expert

Mar 14, 2008
13,475
3,362
Below is a simplified schematic of the scheme.

The switch can be any multiplexer or analog switch. Three gain steps are shown but it's limited only by the number of resistors and the number of switches or analog mux I/O's.

Since no current goes through the switch (except for the op amp bias current) the gain is little affected by the switch ON resistance.

The gain will be the ratio of the sum of the resistors above the switch position divided by the number below, plus 1. Thus, in the switch position shown, the gain is 1 + (R1 / (R2 + R3 +R4). The resistor values are selected to give the gain sequence you want and each resistor can have a different value depending upon the gains you need.

Last edited: May 28, 2013
spark8217 and bug13 like this.
8. ### bug13 Thread Starter Well-Known Member

Feb 13, 2012
1,213
38
Thanks crutschow, this is a little neat configuration I haven't come crass before, thank for showing that to me. It's going to be very useful.

9. ### crutschow Expert

Mar 14, 2008
13,475
3,362
Below is a simulation for the three switch positions with equal value resistors and a 1V pulse input.

Edit: Here is the simulation with resistors selected to give gains of 2, 4, and 8.

Last edited: May 28, 2013
bug13 and spark8217 like this.
10. ### Ron H AAC Fanatic!

Apr 14, 2005
7,050
657
One more switch position could be unity gain.
Also, a 1 Meg resistor from output to inverting input would prevent the gain from being open loop if the switch if break before make.

bug13 likes this.
11. ### screen1988 Member

Mar 7, 2013
310
3
Can you explain more about the use of this resistor?

12. ### Ron H AAC Fanatic!

Apr 14, 2005
7,050
657
Some analog multiplexers have make-before-break switching. This means that, for a brief instant during switching, the "wiper" on the switch will be connected to the input it is leaving AND the input it is going to. In this case, feedback always exists between output and input. This is probably the best choice, if one can be found.
Other MUXes have break-before-make switching. This means that, for a brief instant during switching, the "wiper" on the switch will be connected only to the op amp -input, so there is no feedback path. The -input will have no current path to ground, so the output will have a "glitch" as the output attempts to go to one of the rails.
If you add a large value resistor (e.g., 1 MegΩ) from output to -input, then, while the switch is open, the op amp will run in unity gain mode, and the output will attempt to go to the voltage on the +input pin.
With slow op amps, the difference is probably unimportant. With wideband op amps, you might see an improvement.
The 1Meg resistor will cause a slight gain error due to the fact that it shunts the selected feedback resistance.
If individual analog switches are used, then the switch timing could be arranged to provide make-before-break switching, and the 1Meg resistor would be unnecessary.

bug13 and screen1988 like this.
13. ### screen1988 Member

Mar 7, 2013
310
3
Thanks, that is completely new to me.
This part is not quite clear to me.
Do you refer a circuit like this?

Then the output will be V+ or V- which depends on tapping point?

File size:
25.6 KB
Views:
33
14. ### Andreas Active Member

Jan 26, 2009
68
4
Thanks Crutshow. A nicely detailed response. What cct simulator have you used here?

Tnx.

15. ### crutschow Expert

Mar 14, 2008
13,475
3,362
I used LTspice which is a free program from Linear Technology that many on these forums use.

Andreas likes this.
16. ### crutschow Expert

Mar 14, 2008
13,475
3,362
That is a very simplified diagram of an op amp. It doesn't really show the open-input condition being referred to. When one of the inputs of an op amp is open-circuit then there is no place for the bias current to go and the input will drift in voltage. As soon as that occurs, the high open loop gain of the op amp will drive the output to one of the rails. If you add a high resistance from the output to the negative (-) input, then there is always a path for the bias current and the output won't saturate if the negative feedback path is momentarily interrupted.

screen1988 likes this.
17. ### bug13 Thread Starter Well-Known Member

Feb 13, 2012
1,213
38
So I just one or two switch, the mux I found are usually 8 channels, can I do that with transistor or something?

The gain I'm interested in are unity gain and x10

18. ### Ron H AAC Fanatic!

Apr 14, 2005
7,050
657
How much bandwidth do you need?

19. ### bug13 Thread Starter Well-Known Member

Feb 13, 2012
1,213
38
I have not thought of that part yet, but I would like to start with an easy one, say 1KHz.

20. ### Ron H AAC Fanatic!

Apr 14, 2005
7,050
657
What is the output voltage range, i.e., does it swing ± around ground, or is it unipolar? What are the maximum voltages?