opamp switchable gain

I have a standard inverting op-amp with a 1k input resistor.

The feedback comprises one fixed resistor with three more parallel resistors which can be connected or disconnected by analog switches, giving 8 possible gain settings.

I want a minimum gain of 1 and a maximum of 20. (ok, -1 and -20, it's inverting)

Clearly, the fixed resistor should be 20k to give a gain of 20 with all three switches open. Likewise all four in parallel (all three switches closed) should equal 1k.

I'd like to space the gain settings evenly, so the eight gain settings would ideally be 1, 1.53, 2.35, 3.61, 5.54, 8.5, 13.0, 20.

What's the best way to work out resistor values to get as close as I can to this ideal?

The circuit exists and can't be changed.

Cheers

--
Clive
Reply to
Clive Arthur
Loading thread data ...

If you can write a little code it's a small enough state space to simply brute force search on all combinations of 1% resistor values.

Reply to
bitrex

I'd settle for fewer ranges - not using all 8 combinations - as long as they were fairly evenly spaced, so eg 1, 1.82, 3.31, 6.03, 11, 20 would be fine.

Cheers

--
Clive
Reply to
Clive Arthur

tches

n

I'd do a hunt and peck type thing too. Stepping back a moment, he's got a geometric progression. (1.53)^n. The R ratio's will be linear.. I think, so I'm not sure it can be done. Then again I'm often wrong. :^)

George H.

Reply to
George Herold

Could you include the 20K in the a/switch circuitry ? Things might then be more simple....

--
This email has been checked for viruses by Avast antivirus software. 
https://www.avast.com/antivirus
Reply to
TTman

It's a bunch of simultaneous equations ;-) ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
 Click to see the full signature
Reply to
Jim Thompson

It's possible to write down a system of equations to define the problem and solve it, maybe with some handsome closed form, which is fine if one had resistors of arbitrary precision available, AFAIK OP is constrained to the values they picked for 5% or 1% or whatever the standard he's using, which aren't themselves linearly spaced through the domain of the set.

So probably unless one wants to rewrite the equations to take the exponential spacing of the standard values into account you'll likely have to do some hunting and pecking anyway to check the standard values above and below the infinite-precision target to see which is best.

Meanwhile probably 10 lines of scripting language code not including some kind of appropriately formatted list of standard values could brute force the best in a millisecond

Reply to
bitrex

I think it can't be done to any useful accuracy, so I'm prepared to sacrifice the number of gain steps as long as it's still roughly geometric. Even 1, 2.11, 4.47, 9.45, 20 each +/-20% would work at a push. I'm not proud.

Cheers

--
Clive
Reply to
Clive Arthur

Treat each "gain point" on the desired line as a point in N dimensional space, same with the trials, minimize N-dimensional Euclidean distance between the two as a possible "fitness function"

Reply to
bitrex

I'm a frayed knot. The PCB is. And must remain so.

Cheers

--
Clive
Reply to
Clive Arthur

When I get a chance this week I'll try whipping up a Python script to brute-force the original problem with real resistor values and see if it comes up with anything useful

Reply to
bitrex

39kohm, 13kohm, 1200ohm get very roughly gain steps 20, 13, 8, 6 but quickly tails off too quickly towards 1. Doubt you can get the kind of curve you hope just with shunt switching alone.

piglet

Reply to
piglet

It takes slightly longer than a millisecond with an interpreted language; just as an experiment for a baseline a Python script to generate all 4 character permutations of the lower-case English letters and print out the list requires around 20 seconds on my 2.8 GHz i7 laptop processor

Reply to
bitrex

Agreed, Plugging it intoo a spreadsheet gives similar results. If he had 1 more resistor and a minimum gain of > 1

Cheers

Reply to
Martin Riddle

So, you want the switch to be a 1-of-eight analog mutiplexer, with the eight taps connected Tap #1 through 1k ohm to the op amp output #2 through 0.530 k ohm to tap #1 #3 through (2.35 - 1.53) = 82 ohm to tap #2 and so on...

with the 'common' point, of course, at the summing node of the op amp. There's gonna be a blip, of course, if the mux ever is open (so, maybe diode-clamp the op amp summing node to ground).

Reply to
whit3rd

So, you want the switch to be a 1-of-eight analog mutiplexer, with the eight taps connected Tap #1 through 1k ohm to the op amp output #2 through (1.53k - 1k) = 530 ohm to tap #1 #3 through (2.35k - 1.53k) = 820 ohm to tap #2 and so on...

with the 'common' point, of course, at the summing node of the op amp. There's gonna be a blip, of course, if the mux ever is open (so, maybe diode-clamp the op amp summing node to ground).

I'm thinking this (logarithm taper, so to speak) is not really consistent with three resistors in series or parallel. It IS consistent with an eight-way selector switch.

Reply to
whit3rd

Assuming the 20k and the other end point 1k are hard constraints then you can do it in a spreadsheet using least squares or least 1-norm fitting to choose your resistors.

Your problem is that to hit both 1 and 20 simultaneously means there will be far too many gain steps near 1. If we make the simplifying assumption that all resistors are in parallel and that 20k is in parallel with all the switched ones then it is a two parameter problem in a and b.

since 1 = 1/(1/a+1/b+1/c+1/20)

You know that all switches open gives 20k and all closed gives 1k. You can hit two more gain steps accurately and one inaccurately you can choose which ones matter to you the most.

Something like (20k) 18k, 5.8k and 1.4k gives gain steps of

1 1.059027217 1.210077728 1.297595832 3.579815438 4.472135813 9.457409024 20

You can't get the 2.11 without compromising a lot on the others.

--
Regards, 
Martin Brown
Reply to
Martin Brown

What's the mux? 405x types have an INH pin that turns all switches off, effectively giving one extra degree of freedom.

Cheers

Phil Hobbs

Reply to
pcdhobbs

Best I can think of is use a divider chain in the feedback loop and also one in the input impedance path so that you can generate :

1, x^2, x^4 where x^4 = 20 (2 switches)

and in the other leg

1 x (1 switch)

Combined you get 1 x x^2 x^3 x^4 x^5 with good ratios.

Or 3 switches in feedback and more or less exact

20, 11.66, 3.14, 1.83

giving gains of 20, 7.36, 2.71, 1

--
Regards, 
Martin Brown
Reply to
Martin Brown

No mux, three individual analog switches.

Cheers

--
Clive
Reply to
Clive Arthur

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.