# how to optimize for multistage gain selection

Started by April 17, 2019
```I'm trying to design a two stage amplifier for a sensor readout and I would like those stages to be configurable, but I also need to have the overall gain vs. configuration curve to be such that every new step is ~5% increase w.r.t. the previous.

So let's say I have 3 control bits on the first amplifier and 4 for the second, how would I design the set of values those gains need to be at? Is there an algorithm to do that?

I'm currently guesstimating it, but I doubt there's no formal method to do so.
Any pointer/comment is appreciated.
```
```On Wednesday, 17 April 2019 23:24:47 UTC+1, al.b...@gmail.com  wrote:

> I'm trying to design a two stage amplifier for a sensor readout and I would like those stages to be configurable, but I also need to have the overall gain vs. configuration curve to be such that every new step is ~5% increase w.r.t. the previous.
>
> So let's say I have 3 control bits on the first amplifier and 4 for the second, how would I design the set of values those gains need to be at? Is there an algorithm to do that?
>
> I'm currently guesstimating it, but I doubt there's no formal method to do so.
> Any pointer/comment is appreciated.

Surely the gains you need depend on your input & required output. And presumably max total gain matches your lowest possible input, min gain matches your max input.

Ad if each gain change gives 5% total gain change, then each gain setting will be 5% different from its neighbour.

So... what are you actually asking?

NT
```
```On Wednesday, April 17, 2019 at 6:24:47 PM UTC-4, al.b...@gmail.com wrote:
> I'm trying to design a two stage amplifier for a sensor readout and I would like those stages to be configurable, but I also need to have the overall gain vs. configuration curve to be such that every new step is ~5% increase w.r.t. the previous.
>
> So let's say I have 3 control bits on the first amplifier and 4 for the second, how would I design the set of values those gains need to be at? Is there an algorithm to do that?
>
> I'm currently guesstimating it, but I doubt there's no formal method to do so.
> Any pointer/comment is appreciated.

If you want gain changes to be in 5% steps, pick one amplifier to have the 5% gain steps.  Then the other amplifier will have steps of 5% * 2^n where n is the number of control bits in the amplifier with 5% steps.

The gain controls will have the control bits for the 5% stepped amplifier as the lsbs and the control bits for the other amplifier will be the msbs in a single control word.

Is that what you are asking about?

--

Rick C.

- Get a 1,000 miles of free Supercharging
- Tesla referral code - https://ts.la/richard11209
```
```On Wednesday, 17 April 2019 23:43:53 UTC+1, tabby  wrote:
> On Wednesday, 17 April 2019 23:24:47 UTC+1, al.b...@gmail.com  wrote:
>
> > I'm trying to design a two stage amplifier for a sensor readout and I would like those stages to be configurable, but I also need to have the overall gain vs. configuration curve to be such that every new step is ~5% increase w.r.t. the previous.
> >
> > So let's say I have 3 control bits on the first amplifier and 4 for the second, how would I design the set of values those gains need to be at? Is there an algorithm to do that?
> >
> > I'm currently guesstimating it, but I doubt there's no formal method to do so.
> > Any pointer/comment is appreciated.
>
> Surely the gains you need depend on your input & required output. And presumably max total gain matches your lowest possible input, min gain matches your max input.
>
> Ad if each gain change gives 5% total gain change, then each gain setting will be 5% different from its neighbour.
>
> So... what are you actually asking?
>
>
> NT

I might have slightly missed what you meant. If the digital bits controlling gain have a degree of intelligence, one of the amps needn't have 5% gain changes.
If amp stage A has 3 bits with each step being 5%, that's 8 settings giving gain from n to n x 1.05^7 = n x 1.41.
So amp stage B could have gain increments of 1.05^8 = 1.477 or 47.7% change. And if it is controlled by 4 bits that gives B a possible gain range of 1.477^15 = 347.
That gives your amp a gain range of 1 to 1.41x347= 489 times its minimum gain.

NT
```
```On Wednesday, 17 April 2019 23:24:47 UTC+1, al.b...@gmail.com  wrote:

> I'm trying to design a two stage amplifier for a sensor readout and I
> would like those stages to be configurable, but I also need to have the
> overall gain vs. configuration curve to be such that every new step is ~5%
> increase w.r.t. the previous.
>
> So let's say I have 3 control bits on the first amplifier and 4 for the
> second, how would I design the set of values those gains need to be at? Is
> there an algorithm to do that?
>
> I'm currently guesstimating it, but I doubt there's no formal method to do
> so.
> Any pointer/comment is appreciated.

You don't give max and min gain specs, only that you want 5% steps.  I
suggest making both stages increment in 5% steps for a total gain range of 1
to 1.015^(2^7) or 1 to 515.  However, I don't suggest counting one stage up
from zero to max, then setting it back to zero and incrementing the other
stage gain by one since that big gain jump in the first stage will need
extra settling time and may cause a click or other distortion.  Instead,
increment one stage by one, then the other stage by one, then the first
stage by one, etc.  Kind of like a gray code, that minimizes the maximum
gain change for a single step.  I wonder if you could interleave the bits
like this:  2(4) 1(3) 2(3) 1(2) 2(2) 1(1) 2(1) where 1 and 2 are the 3 and 4
bit control words for the two amps, and (n) is the nth bit, then just treat
it like a seven bit word and add and subtract as needed.  I'll leave it as
an exercise for the reader as to whether that actually works or not,
Jeopardy is coming on and I want to watch James Holzhauer :-).

--
Regards,
Carl Ijames

```
```On Wednesday, April 17, 2019 at 6:24:47 PM UTC-4, al.b...@gmail.com wrote:
> I'm trying to design a two stage amplifier for a sensor readout and I would like those stages to be configurable, but I also need to have the overall gain vs. configuration curve to be such that every new step is ~5% increase w.r.t. the previous.
5%!?  That seems tiny.
>
> So let's say I have 3 control bits on the first amplifier and 4 for the second, how would I design the set of values those gains need to be at? Is there an algorithm to do that?

Opamps have a GBW product that is ~constant. more Gain, less BandWidth.
One has to know all the parameters to try and design an amp.

>
> I'm currently guesstimating it, but I doubt there's no formal method to do so.
> Any pointer/comment is appreciated.
Are you using opamps?  Have you read AoE3?  there are other good opamp books.

George H.

```
```On 18/4/19 8:24 am, al.basili@gmail.com wrote:
> I'm trying to design a two stage amplifier for a sensor readout and I would like those stages to be configurable, but I also need to have the overall gain vs. configuration curve to be such that every new step is ~5% increase w.r.t. the previous.
>
> So let's say I have 3 control bits on the first amplifier and 4 for the second, how would I design the set of values those gains need to be at? Is there an algorithm to do that?
>
> I'm currently guesstimating it, but I doubt there's no formal method to do so.
> Any pointer/comment is appreciated.
>

Gain is easy; stepped attenuation is easy. Stepped gain is usually a bad
idea because it either changes the input impedance or lengthens and adds
reactance to the feedback path.

Use fixed gain and stepped attenuation.
```
```On 18-4-2019 2:45, Clifford Heath wrote:
> On 18/4/19 8:24 am, al.basili@gmail.com wrote:
>> I'm trying to design a two stage amplifier for a sensor readout and I would like those stages to be configurable, but I also need to have the overall gain vs. configuration curve to be such that every new step is ~5% increase w.r.t. the previous.
>>
>> So let's say I have 3 control bits on the first amplifier and 4 for the second, how would I design the set of values those gains need to be at? Is there an algorithm to do that?
>>
>> I'm currently guesstimating it, but I doubt there's no formal method to do so.
>> Any pointer/comment is appreciated.
>>
>
> Gain is easy; stepped attenuation is easy. Stepped gain is usually a bad
> idea because it either changes the input impedance or lengthens and adds
> reactance to the feedback path.
>
> Use fixed gain and stepped attenuation.
>
So use a multiplying DA chip to program gain or attenuation.
```
```On 4/17/19 8:45 PM, Clifford Heath wrote:
> On 18/4/19 8:24 am, al.basili@gmail.com wrote:
>> I'm trying to design a two stage amplifier for a sensor readout and I
>> would like those stages to be configurable, but I also need to have
>> the overall gain vs. configuration curve to be such that every new
>> step is ~5% increase w.r.t. the previous.
>>
>> So let's say I have 3 control bits on the first amplifier and 4 for
>> the second, how would I design the set of values those gains need to
>> be at? Is there an algorithm to do that?
>>
>> I'm currently guesstimating it, but I doubt there's no formal method
>> to do so.
>> Any pointer/comment is appreciated.
>>
>
> Gain is easy; stepped attenuation is easy. Stepped gain is usually a bad
> idea because it either changes the input impedance or lengthens and adds
> reactance to the feedback path.
>
> Use fixed gain and stepped attenuation.

If low noise is a requirement, and in the case of a sensor readout it
sounds like it is, then you have to think carefully about how you do
your post-gain attenuation - no sense in using a quiet amplifier and
input circuit design if you're just going to throw away your SNR in a
noisy attenuator.

At a minimum you'd probably want a low impedance attenuation so you
don't add self-noise from the attenuator but if the application is low
power that can also kill the power budget.

depending on specifics of application we don't know I think it's a toss
up as to whether stepped gain or stepped attenuation will be easier. a
rule of thumb of low noise measurements is DONT throw away gain
cavalierly once you've worked hard to bring a small signal up quietly,
that shit is precious.

```
```On 18/04/2019 08:24, al.basili@gmail.com wrote:
> I'm trying to design a two stage amplifier for a sensor readout and I would like those stages to be configurable, but I also need to have the overall gain vs. configuration curve to be such that every new step is ~5% increase w.r.t. the previous.
>
> So let's say I have 3 control bits on the first amplifier and 4 for the second, how would I design the set of values those gains need to be at? Is there an algorithm to do that?
>
> I'm currently guesstimating it, but I doubt there's no formal method to do so.
> Any pointer/comment is appreciated.
>

Express the gains that you want in decibels, dB.

5.925% gain steps would be 0.5dB, a nice round number in dB. Or you
could pick a nice round percentage number and work out what dB steps
that corresponds to.

e.g., you could have 3 bits giving 0...7 * 0.5dB for one stage,
0.5dB, 1dB, 1.5dB, 2dB...3.5dB
Then the second stage can give you 0...15 * 4dB for example.

You can generate 6.02dB steps with a R:2R ladder in the feedback path of
an op-amp: drive the ladder network from the output of the op-amp and
just pick off the voltage on one stage with a multiplexer and feed that
to the inverting input of the amplifier.

You can similarly generate nice 0.5dB steps with a R:75R ladder iirc.,
and R-75R could also be made with R/5:15R, with unit resistors - that is
nice on a chip because unit resistors match well. For discrete resistors
just buy the values you want.

You need to terminate the resistive ladders correctly. After doing the
maths you can check if the values are right using LTSpice.

Or, just buy a programmable gain amplifier chip, with the above inside it.

```