A digital potentiometer probably can’t be considered the most glamorous of electronic components. But it is easy to use and versatile. In this article, Stuart digs into the uses, advantages and disadvantages of digital potentiometers, including how they contrast to mechanical potentiometers.
One good entry point into understanding digital potentiometers is to contrast them with mechanical potentiometers. So, let’s start there. If you wanted a volume control on a headphone amplifier, you might use a circuit similar to the one shown in Figure 1. A mechanical potentiometer connects to the audio input from some signal source, such as a radio or computer. The other end of the potentiometer connects to ground. The wiper connects to the input of the audio amplifier.
The potentiometer has a knob, and as you turn the knob, the wiper moves across a resistive element between the audio input and ground. When the wiper is at the ground end of the resistive element, the amplifier gets almost no signal, and the volume is off. When the wiper is at the other end of the resistive element, the amplifier gets the full signal amplitude, and the volume is at maximum. Between the two endpoints, the volume is attenuated. A stereo system would typically have two potentiometers on the same shaft, so the volume in both channels is the same.
The mechanical potentiometer has some drawbacks. The most obvious one is the need for one knob for every function to be controlled. If you have volume plus tone controls for high, midrange and bass, then you need three more knobs. If you have volume plus an eight-band stereo graphic equalizer, then you need a total of 17 knobs, one for volume and eight equalizer knobs for each stereo channel.
Another issue with mechanical potentiometers is that the wiper must maintain contact with the resistive element. As the knob is turned, the wiper slowly wears away the material on the resistive element, leaving dead spots where no contact is made. If you’ve ever heard a scratchy sound as you turn a volume knob, that is usually the result of the potentiometer material wearing away in spots.
The issue of a worn potentiometer element also causes the wiper to be momentarily open or disconnected as the knob is turned. In an audio circuit, this causes undesirable noise. In other circuits, such as those involving motor control, this can cause more serious consequences.
Figure 2 is a block diagram of a digital potentiometer, or “digipot,” connected to a microcontroller (MCU). Like a mechanical potentiometer, the digital potentiometer has two ends (A1 and B1) and a “wiper” (W1). But the digital potentiometer doesn’t have a single resistance element with a moveable wiper. Instead, it is a series string of resistors with electronic switches that select taps in the string (Figure 3). For an 8-bit, 256-position device, there are 256 internal switches and 256 taps in the resistor string. The position of the “wiper” is defined by a digital word, controlling which switch is turned on and which tap is selected. It is controlled electronically by the MCU. In Figure 2 the potentiometer uses the standard SPI interface, though other interfaces such as I2C are available.
Showing an example circuit, Figure 4 is a schematic of a Texas Instruments (TI) TM4C1233H6 MCU  connected to an Analog Devices AD8400 digital potentiometer . In the schematic, the wiper output of the potentiometer drives (through op-amp U4) the base of a transistor that acts as a constant current driver for an LED. The digital potentiometer is an 8-bit device, meaning that the wiper moves between the B1 and A1 values as the control byte ranges from 0 to 255.
The upper terminal of the potentiometer is connected to 3.3 V, and the lower terminal is connected to ground. As a result, the wiper varies between these two voltages as the control value varies from 0 to 255. That voltage drives the transistor base through U4. The current through the LED is approximately equal to the current through the emitter, which is:
or about 16 mA when the base is 3.3 V.
U4 is a voltage follower, and provides sufficient drive current to make sure the base of Q1 equals the wiper voltage at W1. Without U4, the wiper of the digital potentiometer could directly connect to the base of the transistor. However, the emitter resistor, R7, when reflected back into the base, would load the digital potentiometer, reducing the base voltage. The circuit would still work, but the LED brightness at any given setting would be lessened.
The combination of U3, U4, and Q1 makes a simple DAC (digital-to-analog converter) that converts the potentiometer setting to an LED current. If you remove Q1, D3, and R7, the output of U4 would be a simple 8-bit voltage DAC with an output range from 0 to 3.3 V. This is not the most efficient way to make a DAC, but it illustrates the principle.
The MCU firmware slowly cycles the digital potentiometer between about 0.7 V and 3.3 V, which causes the LED to brighten slowly over the space of about 2 seconds, then turn off and start over. The lower bound of the potentiometer is set at 0.7 V to match the forward bias voltage of the transistor. If you were to connect an oscilloscope to the transistor base, you would see a sawtooth waveform as the voltage slowly ramps up and then suddenly resets to the 0.7 V lower bound.
The example circuit could be implemented with any MCU, but the TM4C SPI connections are well-suited to parts like the AD8400. The AD8400 is one of a family of parts (AD8400/8402/8403) with one, two, or four digital potentiometers in the package. Although the control word to set the potentiometer value is only 8 bits, two address bits are needed to select which potentiometer in the package is being written.
In the case of the single-channel AD8400, the address bits are always zero, but the extra bits make the control word 10 bits wide. The SPI interface on some MCUs only supports 8-bit operation. The SSI (synchronous serial interface) on the TM4C MCU—used to implement SPI—has a programmable word width from 4 to 16 bits. This makes it easy to connect to SPI devices with word widths that are not multiples of 8 bits. For an MCU with an SPI interface that only supports multiples of 8 bits, you could also use a digital potentiometer with an 8-bit SPI interface, such as the AD5160, or implement the SPI interface in the firmware by toggling the interface pins. This circuit could also be implemented by wiring a board with U3, U4, Q1, D3, and R7, and connecting it to a TI TM4C Launchpad board.
J2 is a programming connector and uses an external RS232 converter to connect to the host serial port. This was described in my article “Debugging Embedded Systems with Minimal Resources” (Circuit Cellar 312, July 2016). Shorting W1 on start-up enables programming. Figure 5 is a schematic of the converter.
ADVANTAGES OF DIGITAL POTENTIOMETERS
Although a digital potentiometer requires extra circuitry, including an MCU, there are several advantages to using one.
No mechanical wear: The digital potentiometer doesn’t have a mechanical wiper, so there is no mechanical wear on the resistive elements.
Combined functionality: A digital potentiometer can be combined with other parts of a circuit to enhance functionality for the user. For example, if you have a Bluetooth-connected phone in your car, the car’s audio system can mute the radio when the phone rings, and unmute it when the call is completed. You don’t have to manually turn down the volume to answer the phone. If your car has a Bluetooth phone capability, it probably works exactly this way.
Fewer manual controls: Again, using the car as an example, you can have anything from a three-band tone control for the radio, or even a multiband graphic equalizer, all without extra knobs. The tone control adjustments can be made from the display in the console, with the MCU adjusting a digital potentiometer for each function.
Multi-use controls: Because the volume and tone controls are electronic, you don’t need one knob for each function. Instead, a single knob can be used to control multiple functions. For example, when using the phone, the volume knob might control audio volume to the phone, without affecting the radio volume when the call ends and the radio is unmuted. The volume knob can be context-sensitive and can control functions that are completely unrelated to volume. When in the clock-setting mode, the volume knob can be used to adjust hours or minutes. When adjusting those tone control values, the volume knob can be used to adjust the selected tone band. Because the MCU is adjusting the various digital potentiometers and other things, the knob can be used for any number of different functions.
Logarithmic potentiometers: Mechanical potentiometers used in volume control applications are usually logarithmic, matching the response of the human ear. Although the AD8400 used in the example is a linear device, there are digital potentiometers with logarithmic response. It is also possible to drive a linear potentiometer with logarithmic values, though this requires additional calculations or a look-up table in the MCU firmware. See Sidebar “Making a Linear Potentiometer Logarithmic” for details.
DIGITAL POTENTIOMETER LIMITATIONS
As with most design decisions, digital potentiometers also have some drawbacks.
Voltage limitations: Besides the obvious need for an MCU to control the device, the input values are limited. A mechanical potentiometer can be driven with any voltage, as long as the power and voltage limitations aren’t exceeded. But for the switches to work, the three resistance terminals of the digital potentiometer can’t go beyond the supply rails. In the example circuit, that means the A1, B1 and W1 pins can’t go below ground or above 3.3 V. This can be an issue with audio circuits, which tend to be AC-coupled and, therefore, swing between a positive and negative voltage.
Figure 6 shows how you might solve that problem using a digital potentiometer. Instead of connecting the lower resistor terminal to ground, it is instead connected to a 1.5 V reference diode. A 10 µF capacitor bypasses the reference, so that the lower terminal is effectively at ground for AC signals. The net result is that the upper terminal is at 1.5 V with no signal applied.
The circuit in Figure 6 fixes the issue of the AC signal driving below ground, but we’re not out of the woods yet. The amplitude of the input signal has to be below 3 V peak-to-peak (PP). If the input is driven with a 4 VPP signal, the peaks will drive the upper terminal beyond the supply rails. The moral of the story is to be sure that the terminal pins not only aren’t biased beyond the supply rails, but also aren’t driven beyond the supply rails over the full range of circuit operation.
The circuit in Figure 6 is relevant to another problem—for a mechanical potentiometer, the three terminals can effectively be isolated from everything else. A mechanical potentiometer could be used to adjust something in a 24 V circuit, as long as the ratings aren’t exceeded. In contrast, the digital potentiometer would fry in that kind of application, unless you floated the entire circuit—MCU and all—at the 24 V level.
Memory: A mechanical potentiometer retains its position when power is removed. Therefore, when you turn the circuit on, the setting of the potentiometer is wherever you left it. If you turn the volume knob all the way down while the amplifier is turned off, then when you turn it on, the volume will be turned off.
The AD8400 used in the example circuit doesn’t have any non-volatile memory. When you turn the power on, the wiper goes to some random location between 0 and 255. If you want to remember the last position of the wiper, you must store it in MCU EEPROM or some other non-volatile memory. Some digital potentiometers, such as the Microchip Technology MCP4161T, have internal non-volatile memory to store the most recent resistance setting. But you should make sure that your design doesn’t do something unexpected the first time you turn it on, even with a non-volatile part.
Current: Digital potentiometers have much lower current capacity than that of mechanical potentiometers. The AD8400 used in the example has a maximum continuous current across the two endpoint terminals of 2 mA. Clearly you aren’t going to use this part to handle any significant amount of power. A mechanical potentiometer also has a maximum power rating, but it is much higher than for a digital potentiometer. In the example circuit, I could have eliminated U4 and used a 1K version of the AD8400 directly driving the transistor Q1, but the current would be 3.3 mA, exceeding the 2 mA continuous current rating of the device.
Tolerance: Like mechanical potentiometers, digital potentiometers don’t have tight resistance tolerance. The AD8400 has about 20% tolerance, though the matching between values is closer to 1%, if using a version with multiple resistors in one package. A few parts, such as the AD5291, have precision as good as 1%. In some applications, the end-to-end resistance tolerance is less important than the ratio of the wiper position to overall resistance.
Audio clicks: Digital potentiometers switch between different resistance values using solid-state switches. For many applications, this is not an issue. But when a digital potentiometer is used as a volume control, it is possible to hear an audible click when the switches open and close. One way to avoid this is to only allow the volume to be changed on zero-crossings of the input signal. This makes the switch transitions inaudible. Some digital potentiometers, such as the Maxim Integrated’s MAX5408, are designed specifically for volume control applications, with built-in zero crossing detectors. Mechanical potentiometers do not have this issue. However, as they wear, they do have a similar issue with noise on dead spots.
OTHER USES FOR DIGITAL POTENTIOMETERS
I have focused on audio applications for the digital potentiometer because they are easy to understand, but there are other applications as well. A digital potentiometer can be used to electronically compensate a bridge circuit. Coupled with a thermistor or other temperature-measurement component, a digital potentiometer can be used to compensate for temperature variation in a temperature-sensitive circuit.
A digital potentiometer in the feedback path of an op amp circuit can be used to control gain or other parameters. Figure 7 shows how the AD8400 could be wired to control the gain of an op amp. A pair of digital potentiometers can be used to tune a low-pass or high-pass audio filter . Analog Devices has an application note describing the use of digital potentiometers to control the frequency and gain of a Wein Bridge oscillator .
Here, I have concentrated on applications using an MCU. Digital potentiometers such as the AD5228 have inputs for two buttons. One button steps the wiper up, the other steps it down. However, many of the advantages of an MCU-based design cannot be realized with these parts, unless the up/down inputs are connected to an MCU. For that reason, I omitted discussion of these parts from this article.
The digital potentiometer isn’t a glamorous component, but it solves a lot of problems. Hopefully, this brief tutorial has provided some insight into the benefits of digital potentiometers and the things you need to plan for if you use them in your designs.
MAKING A LINEAR POTENTIOMETER LOGARITHMIC
A linear potentiometer has a linear relationship between the “position” of the wiper and the attenuation. The attenuation is proportional to the wiper position. If the wiper (mechanical or electronic) is at the halfway position, the attenuation is 50%, or 6 dB below the maximum value. However, the response of the human ear isn’t linear, but rather logarithmic.
For a logarithmic 8-bit potentiometer, the relationship is:
Audio volume changes are measured in decibels (dB). To make a 256-step, 8-bit linear potentiometer into a log potentiometer, you don’t use all 256 positions. Instead, you use resistance (wiper) values that result in a constant separation in dB. So, for the AD8400, you could have 9 steps of 6 dB each, with the resistance control values shown in Table 1.
If you calculate the midpoint, 128, using the logarithmic formula, you will see that it is 20 log(.5) or -6 dB from maximum volume. Doing the same calculation with the next step, 64, you will find it is -12 dB below maximum.
You can do something similar to get 3 dB steps, but the more steps you want to have, the less accurate the logarithmic scale will be. A conversion of 3 dB per step with 16 steps in the AD8400 would have values like this:
0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 45, 64, 90, 128, 180, 255
If you do the math for the low end of the scale, you find it isn’t very close to 3 dB steps. But at very low volume levels, it usually matters less.
For detailed article references and additional resources go to:
References  through  as marked in the article can be found there
PUBLISHED IN CIRCUIT CELLAR MAGAZINE • OCTOBER 2019 #351 – Get a PDF of the issueBecome a Sponsor