# AN-1169: Linear Gain Setting Mode: A Detailed Description

### Introduction

Digipots are commonly used to digitally program the gain in an amplifier or set the output voltage of a power supply regulator as shown in Figure 1 and Figure 2.

In both cases, the transfer equation depends on two different
variables, R_{1} and R_{2}, as shown in Equation 1 for the LDO and
in Equation 2 for the noninverting amplifier.

Using the digipot in potentiometer mode in these transfer
equations is not straightforward since both resistors strings,
R_{AW} and R_{WB}, are complementary; in other words,
R_{AW} = R_{AB} − R_{WB}, as shown in Figure 3.

If the resistances R_{1} and R_{2} are directly replaced with a digital
potentiometer, then the transfer function becomes logarithmic.
Figure 4 shows an example for the LDO.

This logarithmic transfer function can be desirable in some applications, such as light or audio control, because the human body is not a linear receptor of those stimuli, but in many electronic applications a linear transfer function is preferred.

### Linearizing The Output

There are three different methods to achieve a linear output directly proportional to the code loaded in the digipot. These three methods are described in detail in the sections that follow.

#### Use the Digipot in Rheostat Mode

The digipot can be used in rheostat mode, where only two terminals are used, as shown in Figure 5.

This mode requires using a discrete resistor in conjunction with the digipot. An example of the noninverting amplifier is shown in Figure 6.

The main benefit of using this solution is the simplicity in the
circuit, the wide output ranges, and the fast settling time. As
a trade-off, the overall output error may be quite high because
the typical tolerance error in a digipot is around ±20% maximum. Given that R_{2} is fixed, this can cause resistor mismatches.

Analog Devices, Inc., offers ±8% and ±1% resistor tolerance error digipots to improve the performance in these configurations as shown in the selection table.

Additionally, the output error can be reduced by using a serial resistor with the digipot, as shown in Figure 7, for the LDO

In this case, to assume the 20% tolerance error is negligible
R_{2} >> R_{WB}; or, in other words, the output error can be improved
by reducing the adjustable output gain and increasing the
settling time. The final resistance is defined in Equation 3.

A second way to reduce the error is by placing a parallel resistance with the digipot as shown in Figure 8.

In this case, the assumption is that R_{2} << R_{WB} due to the
nominal end-to-end resistor values, 10 kΩ, 50 kΩ and 100 kΩ

The consequences are similar to the previous approach, that
is, the adjustable output gain is reduced, but, in this case, the
settling time is reduced due to the lower R_{WB}’ value, as defined
in Equation 4.

The overall parallel resistance value is smaller, thus the resistor noise is lower than the series resistance approach.

As a precaution, remember that the digipot has internal leakage
current. If you choose the parallel resistor, R_{2}, to be small
enough to force not enough current through the digipot, the
linearity errors, R-INL and R-DNL, could be considerable
higher than specified in the data sheet.

#### Linearize The Potentiometer

Configuring the digipot as a vernier DAC, as shown in Figure 9,
the voltages in the Terminal A and Terminal B are limited by
the placement of the in-series resistors, R_{1} and R_{2}.

The idea of this approach is to reduce the output range resulting in a more linear output, as shown in Figure 10, for two different configurations.

This configuration provides lower linearity error than using the digipot in rheostat mode and it results in a lower tempco.

The final resistance between terminals is defined in Equation 5 and Equation 6.

It is recommended to use a low resistor tolerance error digipot, ±8% and ±1%. Note that the higher the tolerance, the greater the mismatch resistance error.

In this case, using a typical 20% resistance tolerance error, a parallel resistor should be used with the digipot to reduce the overall error as shown in Figure 11.

Again, it is important to consider the effect of the leakage
current in this configuration. Selecting a low parallel value
could force the current through R_{3}.

To calculate the final resistance between terminals can be quite complex, thus the best approach is to use a Y-Δ transform as shown in Figure 12.

where:

R_{6} should be connected to a high impedance input so that the
effect of this resistance can be considered negligible.

#### Enable The Linear Gain Setting Mode

In linear gain setting mode, the internal resistors strings, R_{AW}
and R_{WB}, are dependant. The newly patented architecture implemented in the AD5144, AD5142, AD5124A, and AD5141 improves flexibility, allowing independent programming of the
value for each string, R_{AW} and R_{WB}, as shown in Figure 13.

Enabling this mode, the output voltage can be linear, fixing the
value of one resistor string, that is, R_{WB}, and setting the other
string, R_{AW}. The mode of operation is similar to using the
digipot in rheostat mode in conjunction with a discrete resistor,
but in this case the overall tolerance error is below 1% without
using any external parallel or series resistance combination.

This is achieved because the gain is set by the resistance ratios, and the overall resistor tolerance error, as is common in both string arrays, can be disregarded.

Figure 14 shows an example of sweeping R_{AW} from zero scale to
full scale, fixing R_{WB} at midscale for a 10 kΩ digipot. Analyzing
the plot in detail, at lower codes when the resistances, RAW or
R_{WB}, are small, the mismatch becomes higher than ±1%. This is
due to an error added by the non-negligible effect in the
internal CMOS switches resistance.

The switches effect can be cancelled by selecting codes higher than quarter scale.

Enabling linear setting mode, the maximum resistance between
Terminal A and Terminal B can be set to double the nominal
digipot resistance. In other words, if the R_{AB} resistance is 10 kΩ
in potentiometer mode, in lineal setting mode when programming both string resistors at full scale, the R_{AB} = 20 kΩ.

Similar performance can be achieved by using a dual channel digipot, but this solution increases the cost and size with degradation in the settling time.

Another additional benefit of using this configuration is the reduced temperature coefficient, as shown in Figure 14. In this case, the importance is not the absolute tempco for each string resistor, but the difference between the tempco for the specific codes that define the ratio.

Take, for example, the circuit in Figure 16. Choosing a gain of 3, the codes ratio is defined in equation 11.

Fixing the R_{WB }code to 250, the R_{AW }code is 125. As a rough
estimate, the overall error due tempco over the full temperature range is defined as,

R_{AW} at code 125 is 20 ppm/C

R_{WB} at code 250 is −2 ppm/C

The gain error due to R_{AW }is

The gain error due to R_{WB}

Error_{RBW}=0.04%

Thus, the total error is defined as,

GAIN_{ERROR}=Error_{RAW}+Error_{RWB}=0.17%

Similar to the resistance match error, at lower codes the switch resistance tempco is dominant, but the effect is minimizing at higher codes.

If a lower error vs. temperature is required, a higher end-to-end resistance value needs to be used as shown in Figure 17 for 100 kΩ. In this particular case, the tempco is much more flat in all the code range, so the error expected should be smaller.