16
\$\begingroup\$

I have a current signal that can vary in amplitude. I currently have a transresistance amplifier which uses 330 Ohm resistors.

However the amplitude of this signal can vary and I would like to be able to change the gain, when required from a micro controller.

Is there anything like an SPI part that alters resistance on command ?

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Does it matter if you change the voltage or the resistance? It's usually easier to change the voltage, by using an OP amp or DAC etc. \$\endgroup\$
    – Lundin
    Commented Apr 29, 2021 at 13:42
  • 5
    \$\begingroup\$ there is such a thing as a motor driven potentiometer \$\endgroup\$
    – jsotola
    Commented Apr 29, 2021 at 19:40
  • 2
    \$\begingroup\$ You can always put a motor on the shaft of a regular old mechanical tuner and rotate it mechanically. This might seem silly, but there are cases where solid state electronics might not have the desired properties (frequency, linearity, longevity, precision, cost) that you can easily achieve with a mechanical potentiometer. (dang, jsotola just beat me to it) \$\endgroup\$
    – trent
    Commented Apr 29, 2021 at 19:41
  • \$\begingroup\$ Lundin: I am using a transresistance amplifier to measure small currents (circa 1mA) \$\endgroup\$
    – Robin
    Commented Apr 30, 2021 at 8:32

5 Answers 5

35
\$\begingroup\$

The term you are looking for is digital potentiometer.

Search for parts to find one that fits your needs. You can get them with up to 10 Bits of resolution. Be aware that on power-up the value might be at min or max until you send the needed value via the digital interface.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Typically they start at around quarter-way, but there's usually a way to set a default value on startup. This default value sometimes can only be set once though! Generally as you say it's a good idea for the micro to get a good value in there before analogue power comes on (or at least before anything does anything important). \$\endgroup\$
    – Graham
    Commented Apr 29, 2021 at 23:21
  • 2
    \$\begingroup\$ That's why it's a good idea to have them in series with a resistor whose value is low enough not to impact the performance much and high enough to avoid short-circuit. \$\endgroup\$
    – Mast
    Commented Apr 30, 2021 at 12:55
20
\$\begingroup\$

It seems you're trying to build a programmable gain amplifier. Programmable resistors, as jusaca says, exist in the shape of digital potentiometers.

However, there's also programmable gain amplifiers that you can buy like that; look for PGAs with your favourite electronics distributor (farnell, digikey, mouser, …).

Both devices don't have infinite bandwidth (and I know a student who ran into trouble exactly because they wanted to use a digital potentiometer for a 1 MHz signal, and the digital potentiometer wouldn't let that through), but it tends to be the case that PGAs have more predictable / better specified frequency responses in their datasheets.

Also, you'll want to read up on Friis' Noise Formula; the first amplifier in a chain of signal processing step dominates the overall noise performance and should therefore be as high (gain / noise figure) as possible; it might make sense to have fixed, low-noise amplification up front, and then variable attenuation (and that can be done with a digital potentiometer, or a "multiplying DAC*, or other means). Especially in RF, that's what you'll most commonly find!

\$\endgroup\$
8
\$\begingroup\$

As well as the solutions given above, you can use a voltage controlled resistor and drive it from a D to A. One way is to use an FET, a more obscure one is to use a light dependent resistor which is mechanically and optically coupled to an LED.

The FET approach is perhaps of limited value, as it can only be used unipolar; however the LDR method has the nice quality that the LDR is completely isolated from the control signal, and is completely bipolar.

\$\endgroup\$
7
\$\begingroup\$

There are a few ways this can be implemented without specialized chips.

1. Using GPIO pins as a rudimentary DAC

Design the amplifier circuit so that gain can be varied with a resistor connected to ground. This is not possible in the usual transimpedance amplifier, but easy to achieve if you add a separate non-inverting opamp amplifier circuit after it.

schematic

simulate this circuit – Schematic created using CircuitLab

In the above example, there are three GPIOs connected with 1, 2 and 4 kohm resistors. The gain can be varied by setting some of the GPIOs to output 0, and others as High-Z input pins:

GP1 GP2 GP3   Gain
 Z   Z   Z    1x
 Z   Z   0    2x
 Z   0   Z    3x
 Z   0   0    4x
 0   Z   Z    5x
 0   Z   0    6x
 0   0   Z    7x
 0   0   0    8x

2. Using several ADC channels

If a couple of gain steps is enough, an alternative solution is to take advantage of the multiple analog channels available in most microcontrollers.

Design the transimpedance amplifier with a constant gain. Try to minimize the noise level, as often the first gain stage has the largest effect on total noise in the system - and it is easier to minimize the noise if you have small SMD resistors instead of a programmable resistance chip.

Add further voltage amplification stages after that, each with fixed gain (for example 4x and 16x stages). Now connect the direct 1x signal to one ADC input, the 4x signal to another input and 16x signal to a third input. By selecting different ADC channels you can vary the effective gain in software.

schematic

simulate this circuit

\$\endgroup\$
1
\$\begingroup\$

Yes, there are. Usually, in the literature, they are called Digital Potentiometers (DigiPOT).

One of the most popular one (and my personal favorite) is AD8403. It is up to 100 kΩ controlled by 3-Wire SPI-Compatible Serial Data Input with 256-bit register.

enter image description here

But you can find much more options to chose from here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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