Given the following circuit:

enter image description here

What is the component / circuit I should be using to switch the signal between each of the gain resistors? (the ⊠s in the schematic)

The inputs ID0 to ID2 are TTL (could be active high or active low, I don't mind). The input IA0 is analog \$\pm 2.5V\$, offset by \$+2.5V\$ by the voltage divider into the Op-Amp's non-inverting input. The output OA0 is the same (offset).

The feedback therefore is obviously going to swing around the virtual ground \$0V\$ (not sure what that would equate to in this circuit) in both directions, so needs to handle that.

I don't want the switching mechanism to give any amplification, and preferably have as little \$R_{ON}\$ as possible.

I don't have a clue what I should be using to do this switching. If it makes it easier I could fix the gain resistor to a known value and move the switching to the inverting input resistance (not shown on schematic).

  • 2
    \$\begingroup\$ Matt, will you please stop writing "-ve"? The first time it took me an hour to know what you meant :-) \$\endgroup\$
    – stevenvh
    Jun 30, 2011 at 16:29
  • \$\begingroup\$ Whats the bandwidth of this circuit? i.e. is it Audio or something else? \$\endgroup\$
    – Mark
    Jun 30, 2011 at 16:45
  • \$\begingroup\$ The op-amp has a 10MHz GBP. I am interested in between 0Hz and 1MHz. \$\endgroup\$
    – Majenko
    Jun 30, 2011 at 17:05
  • \$\begingroup\$ Your structure resembles a standard inverting amplifier, but it is missing an input resistor. \$\endgroup\$ Jul 5, 2011 at 1:05
  • 1
    \$\begingroup\$ -ve is shorthand for negative. \$\endgroup\$
    – Majenko
    Jul 5, 2011 at 8:20

7 Answers 7


The first which comes to mind is bilateral switches like 74HC4066. They have a few tens of Ohms of on-resistance, but that won't probably much of a problem if your feedback resistor values are high enough, otherwise take them in account, and for example use a 950\$\Omega\$ resistor instead of a 1k.
I'm getting some rather negative reactions on this, but I just wanted to make the same remark endolith makes: if Matt can use a symmetrical power supply the switch can be placed on the side of the virtual ground, and especially when using a high feedback resistance there will be hardly any voltage drop over it, so also no distortion. If the feedback resistance is 10k\$\Omega\$ then the resistance of the switch is only 1/10th of the tolerance on a 1/4W E12 resistor.
FakeName suggests some AD devices as better alternatives to the 74HC4066. Particularly the ADG1401 he mentions looks very interesting, with an \$R_{ON}\$ < 2\$\Omega\$. (Thanks, Fake)
Matt already seems to have found Maxim analog multiplexers, but I want to include the MAX4781, which has similar \$R_{ON}\$, in case others are interested. The Intersil ISL84781 is a pin-for-pin replacement for the MAX4781, and has a maximum \$R_{ON}\$ of 0.8\$\Omega\$.

High end audio equipment sometimes uses reed-relays here, which have the advantages of a mechanical switch: m\$\Omega\$ resistance when on, G\$\Omega\$ when off.

Just had another idea! :-) An OTA (transconductance amplifier) can be used to make a VCA (Voltage Controlled Amplifier). This one uses an LM13700:

enter image description here

Instead of having a series of digital control lines controlling switches you vary the amplification with an analog voltage. DAC can be as simple as R-2R ladder network.

Yet another solution also takes the problem one level up, like the OTA: you don't really want switches, you want a variable gain amplifier, and therefore the feedback resistor must be variable. Like with a digital potentiometer. This one has a 100k\$\Omega\$ range in 400\$\Omega\$ steps. You can also choose a smaller range in combination with a fixed resistor, of course. Possible drawback here is that the wiper has a rather high resistance of 800\$\Omega\$ (maximum), though this just means you'll always have the two lowest steps.

  • \$\begingroup\$ Using a 74 series device for switching analog is a bad idea. The ON resistance is very much non-linear as a result the frequency response of the switch is all over the map especially for voltages not at the rail. \$\endgroup\$
    – Mark
    Jun 30, 2011 at 16:59
  • 1
    \$\begingroup\$ There are many, many very good analog switch ICs available. Just because the 40HC66 does not work very well in this context does not mean you should throw away the idea. Also, there are many that work with split-rails, and incorporate level-shifting logic to make them very easy to interface. See analog.com/en/switchesmultiplexers/analog-switches/products/… \$\endgroup\$ Jul 1, 2011 at 1:45
  • 1
    \$\begingroup\$ @stevenvh - What? Then what have I been using them for for years? None of them have an intended usage of power-switching. They are all designed to switch analog voltages. Also, right on the linked page - Bipolar-Input, Dual Supply Switches. \$\endgroup\$ Jul 1, 2011 at 8:35
  • 1
    \$\begingroup\$ @stevenvh - No problem, and who said I have a shirt on anyways? \$\endgroup\$ Jul 2, 2011 at 4:26
  • 1
    \$\begingroup\$ @supercat - In series with a 10k\$\Omega\$ resistor the switch's distortion would be reduced by a factor 200! 10% distortion would become 0.05%. Also, there were other switches suggested with \$R_{ON}\$ < 1\$\Omega\$. \$\endgroup\$
    – stevenvh
    Jul 6, 2011 at 16:27

You could use a I2C/SPI adjustable resistor if you want it to be continuously adjustable rather than discrete steps. Analog Devices makes a bunch of these (i'd link but their site appears down).

If you'd rather the discrete steps, all you need is a 3 to 1 multiplexer or decoder depending on how you arrange it. It would probably come as a 4 to 1 and you use 2 inputs to control it (not 3). If you can provide the needed frequency response I could provide an example part.

The issue with using 3 discrete switches is that you should really only need 2 pins to control this, not 3. Additionally when you make a change there will likely be some "cross over" as a result of the switches not all changing at exactly the same time. The result will be artifacts in the signal. However, this may not matter for your application.

  • \$\begingroup\$ 3 is just a representation - I'm probably going to have something like 6 or so discrete resistances. The TTL inputs may come from a 3-to-8, or whatever - it's purely representative. And I already have digipots here, but getting them with high enough resistance ranges (we're talking resistances between 10MΩ and 10Ω here) is tricky. \$\endgroup\$
    – Majenko
    Jun 30, 2011 at 17:02
  • \$\begingroup\$ @Matt Jenkins gotcha, here is an example of an 8 to 1 bi-directional MUX that can be used with single or dual supplies and is designed for analog use with flat response to roughly 100Mhz: intersil.com/data/fn/fn6416.pdf Just an example of what to look for, not really a recommendation (first device I came to in google), there are lots of companies that make MUXs designed for analog use. \$\endgroup\$
    – Mark
    Jun 30, 2011 at 17:10
  • \$\begingroup\$ @Matt Jenkins One other thing, pay attention to the isolation vs frequency capabilities of the switch/MUX. That is how much "leaks through" when its off. At frequencies as high as your going there tends to be inductive/capacative coupling effects which prevent a 'perfect' off from occurring. \$\endgroup\$
    – Mark
    Jun 30, 2011 at 17:13
  • \$\begingroup\$ I have just ordered some samples from Maxim to play with \$\endgroup\$
    – Majenko
    Jun 30, 2011 at 17:23

This isn't about the switch per se, I'm going to take your problem one level up.
What you want is an amplifier with variable amplification, which you want to realize by varying the feedback resistor. Because you're working the opamp with a single supply you biased the non-inverting input at half the power supply. The input swings between -2.5V and +2.5V, and (most likely) will be zero if no signal is applied.

the schematic you posted needs some work!

First, your circuit lacks an input resistor. Whatever voltage you supply to it, the output will never be able to set the output such that the inverting input is equal to the non-inverting. So we add an \$R_{IN}\$. (edit: I now see that you mention it in the text, so that was actually alright. Sorry. Well, anyway it's necessary.)

But we're not out of the woods yet. Let's take the no signal situation, and assume a 10V supply. The opamp will keep the inverting input at 5V by regulating the output. If \$R_1\$ is equal to \$R_{IN}\$ the output voltage will be 10V, so that's your positive rail. If you apply an input voltage, the negative half of it will be clipped off (remember, the opamp inverts the signal). Not only that, but a different value for the feedback resistor (which is what you want) will result in another output voltage.

There's a number of ways to fix this. AC coupling the output through a series capacitor won't do, remember the clipping.
Best solution is to use a symmetrical power supply, so that you can keep the non-inverting input at 0V, and you won't get an offset at the output. That's also the case I referred to in my other answer, where the 74HC4066 would be at 0V, the other side very near to that, so that the switch won't have the chance to cause distortion.
If you can't do that, you have to bias the inverting input to \$\frac{V+}{2}\$ as well. The output will also swing around this virtual ground, here you can remove the offset with a series capacitor. To get this bias at \$\frac{V+}{2}\$ you cannot use two equal resistors, though!

The voltage on the inverting input should be \$\frac{V+}{2}\$ if the input is 0V. So the input resistor is effectively parallel to the lower resistor of the divider. If you pick \$R_{LOWER}\$ = \$R_{IN}\$ then \$R_{HIGHER}\$ should be half that value to get \$\frac{V+}{2}\$. The opamp should set the output so that both inputs stay the same, which means it shouldn't change our inverting input voltage. It can only do so by having no current through the feedback resistor, and that's so when \$V_{OUT}\$ is equal to the inverting input.
The good news is that, just because there's no current through the feedback resistor, this resistor's value doesn't matter for the bias, and that you actually can vary it. (We hadn't checked yet if a variable feedback resistor wouldn't change the bias.)

  • \$\begingroup\$ good point, good analysis and great detail. +1 \$\endgroup\$ Jul 1, 2011 at 10:56
  • \$\begingroup\$ I'm having trouble understanding what exactly the proposed schematic is, and what resistor values should be used to create a single-supply amplifier with voltage-controlled gain. The last couple paragraphs were hard to follow. The best I could come up with based on your description had an output voltage with a gain that did not seem adjustable. Maybe I'm missing something. Could you post a net list? Also maybe exactly which resistors should be equal? \$\endgroup\$ Jul 15, 2013 at 23:07

The function for your blocks is that of an 'analog switch'; CD4016 is the common SPST part for this, and there are many others (depending on the range of voltages and on the logic levels). There are also many-to-one multiplexer switches that would work (CD4053 is one example).

You do NOT ever want to operate with no feedback, so instead of three switches, consider leaving the largest resistor value hard-wired in, and adjust the other values according to your gain requirement.

  • \$\begingroup\$ The s.e.d. denizens have come! :) \$\endgroup\$
    – Bitrex
    Jul 5, 2011 at 0:04

literal answer

The device indicated is an "analogue switch", also called "analog switch" or "bilateral switch".

There are three popular implementations, each with its own drawbacks:

  • relays: slow to switch, eventually wear out.
  • CMOS audio switches: limited bandwidth; charge injection, some resistance.
  • CMOS video switches: relatively high resistance

If you are handling some sort of low-frequency precision analog signal, such as high-fidelity audio sound, you'll want to use a switch with less than 1 Ohm of resistance. Such as, in no particular order:

  • Maxim IC MAX4310
  • Fairchild Semiconductor FSA5157
  • Analog Devices ADG804

If you are handling high-frequency signal, such as video data, you will be forced to use a switch with more than 1 Ohm resistance, or perhaps something other than a simple solid-state switch. Such as, in no particular order:

  • Vishay Siliconix DG642
  • Texas Instruments TS5V330
  • Omron G6Z-1F-A-DC5
  • National Semiconductor LMH6574

slightly different circuit configurations

Early analog switches had on-resistances of hundreds of ohms -- and worse, resistances that varied with temperature and with the voltage of the passed signal, making it difficult to compensate. Several people have figured out clever circuit configurations such that the on-resistance had very little effect even when handling highly precise signals. See the schematic of Figure 1 of Intersil AN1034: "Analog switch and multiplexer applications", and the series of schematics starting with Figure 22 of Analog Devices MT-088: "Analog Switches and Multiplexers Basics".

significantly different circuit configurations

(Moving the question to the meta-level: what are you really trying to do?)

It appears you are trying to build a programmable gain amplifier out of an op-amp chip and some external analog switches.

That is certainly one way to build a programmable gain amplifier (see the above references, and also Analog Devices CN0146: "Low Cost Programmable Gain Instrumentation Amplifier Circuit Using the ADG1611 Quad SPST Switch and AD620 Instrumentation Amplifier").

As stevenvh pointed out, there are several other ways to implement a programmable gain amplifier, some of which may be superior in your application. Perhaps a single-chip variable gain amplifier would work just as well? In no particular order, a few very different chips:

  • Texas Instruments VCA822
  • Texas Instruments TL026
  • Microchip MCP6S26
  • Analog Devices SSM2018

You can use a photocell/photoresistor coupled with led and resistor with plastic ring in a shrinktube. It has a range from few ohms to more than 10MOhm. Or similar off the shelf product with known specs.

  • \$\begingroup\$ Sort of a home-made analog opto-isolator... hmmm... interesting... \$\endgroup\$
    – Majenko
    Jun 30, 2011 at 17:03
  • \$\begingroup\$ Keep in mind that photoresistors react slooowwly, but that could also be an advantage. \$\endgroup\$
    – stevenvh
    Jun 30, 2011 at 19:16
  • \$\begingroup\$ Also CdS LDRs will still have a relatively high resistance (10\$^2\Omega\$), even at a (very high) 10 000 lux, so there they have the same disadvantage as the 4066. \$\endgroup\$
    – stevenvh
    Jul 1, 2011 at 9:08
  • \$\begingroup\$ use an IR led and a phototransistor or photo diode instead of the CdS \$\endgroup\$
    – jsolarski
    Jul 4, 2011 at 23:33
  • \$\begingroup\$ @jsolarski - this answer may distract a bit from the original problem, which was to find a variable resistor for AC signals. We're not actually interested in measuring light levels, so a photodiode won't do. \$\endgroup\$
    – stevenvh
    Jul 5, 2011 at 6:57

I struggled with this exact same question when designing a universal crossover filter around op-amps which I wanted controlled the same way. I had two requirements (i) a respectably low Ron and (ii) through-hole IC switches. While SMD devices have very low Rons, the second requirement narrowed the choices down dramatically. My final candidates were the ADG609 and the DG409. The latter has a wider supply voltage range but a greater Ron. If you want to work with 5V supplies the ADG609 is the winner.

(PS: the filter project I mention is described in detail, with schematics, in "A Universal Continuous-Time Active Filter", Linear Audio Vol 1, pp 77, April 2011. May be a useful reference for this question.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.