Electronic – Relay Controlled Gain for Microcontroller

microcontrollerrelay

I'm thinking about controlling analog circuits with a micro controller and lots of tiny relays (Omron G6L). For signal routing this is fine but gain control is troubling.

Obviously I could do something like this:

Relay Controlled Gain

But this requires a relay for each step. I'm thinking there has to be a better way.

Is there a clever resistor network arrangement that can yield the voltage dividers found in inverting and non-inverting op amp circuits, panning controls, etc?

More specifically, is there a parallel and / or series network of relay controlled resistors that can yield the ratios necessary to control gain in op amp circuits (both inverting and non-inverting), pan controls, etc?

With 2 relays that is 4 possible ideally. With 3 relays that's 2 x 2 x 2 = 8 steps. With 8 steps of 3dB each that would give me a 21dB range from say -9 to +12 or whatever. As the gain is increased or decreased, the microcontroller would just iterate through a predefined sequence of binary codes.

Surely this has been studied before but I'm not an EE (I'm just doing this for fun) so any pointers would be greatly appreciated.

Best Answer

Check out analog multiplexers like 4051. These devices are commonly used for this kind of application. In practice they form an analog (and in fact bilateral) connection between one of the 'inputs' (Y0 - Y7) and the output (Z), selected by a binary selector (A0 - A2). It would replace all your relays (up to eight) and you set attenuation per input by a resistive divider. With a supply voltage of 10V the ON resistance is in the order of couple 100\$\Omega\$.

Similar story goes for 4052 which has 2 independent 4 channel analog (de)multiplexers.

Basically the same circuit as yours:

schematic

simulate this circuit – Schematic created using CircuitLab

Another possibility is to use an DAC and feed your input signal into its reference voltage input and select the attenuation with the digital input. Not all DAC's are fast enough for this application, but it can give you many bits of resolution.