What The Tech

Digital Potentiometers

Variable Resistance at your Digital Fingertips

Mike Hansell

Issue 13, July 2018

This article includes additional downloadable resources.
Please log in to access.

Log in

We take a look at digital potentiometers, often referred to as "digipots".

Analogue potentiometers are one of the fundamental parts of electronics, but they can be difficult to interact with in a digital world. If you have ever used a potentiometer with an Arduino or other microcontroller, you’ll know how volatile the readings can be. Even without touching the potentiometer at all, if you output the reading to serial monitor each second or two, you’ll see a reasonable swing in values.

Part of this is not the fault of the potentiometer at all. Instead, it’s the analogue to digital converter (ADC) in your microcontroller, trying to rationalise what it’s measuring in a short space of time, which is prone to voltage fluctuations by the microsecond, electrical noise, and other influencing factors. This can make the task of reading a traditional potentiometer something of a challenge.

THE DIGITAL SOLUTION

A digital potentiometer is effectively a series of resistors, organised into a resistor ladder, with the virtual wiper represented by a series of transistors acting as switches. This enables output of a physical resistance via the digital potentiometer, which can in turn control all sorts of things.

As you may have guessed, a digital potentiometer doesn’t have the same resolution as its analogue counterpart (since the analogue resolution is virtually infinite). However, what it lacks in resolution it makes up for in stability. It’s also worth noting that a microcontroller such as an Arduino usually has an analogue to digital converter (ADC) with a resolution of 10 bits. This provides a range of 1024 steps; therefore, a 10 bit digital potentiometer with 1024 steps is actually a perfect match for an Arduino’s ADC too!

WHY USE A DIGITAL POT?

One major benefit is the accuracy. A digital pot is stable, and repeatable. Set it to a precise value, and you’re virtually guaranteed the wiper will be accurate each time. With an analogue potentiometer, even rotating it to “half way” is an approximation at best.

The second major benefit is the ability to make adjustments digitally. Most digital pots allow you to increment by one step, or jump instantly to a precise value. Even with a motorised analogue potentiometer, you can have some difficulty moving the physical wiper to a precise location. The task is also made more difficult the faster you wish to get there!

PRACTICAL IMPLEMENTATIONS

Digital potentiometers can be used, for the most-part, as 3-pin potentiometers, and 2-pin rheostats (variable resistors) depending on the application.

Because of the physical change in resistance between the pins, whatever device you’re connecting the potentiometer to should be totally oblivious to a digital pot over a traditional one. The only prerequisite is that most digital pots will have a suitable operating range. As long as you’re within those parameters, you can generally interface them with any other systems using regular pots.

BUTTON UP/DOWN

While many cases using digital pots are integrating microcontrollers, most of them will work with simple momentary switches on the up/down pins. The precise implementation of this depends on the digital pot you have, but the circuitry is quite straight forward.

Say for instance, you’re controlling a PWM signal using a conventional pot. Using an up and down button system instead, provides reliability and repeatability of that selection down to 1/1024th of the possible scale, or about 0.1% duty cycle. Obtaining this kind of fine-grain control can be very difficult with conventional pots. Of course, it only takes a little additional circuitry to add “push and hold” functionality, so you can increment steps more quickly.

ROTARY ENCODERS

Digital potentiometers are a prime candidate for use with rotary encoders. When the user experience expects some kind of “dial”, you can use a rotary encoder to drive the digital pot (or multiple pots for that matter). Rotary encoders will provide a pulse when turned clockwise or anticlockwise, which can in turn adjust the digital pot up or down.

This provides the precise control and flexible inputs you might be looking for; however, it also means that when the device is controlled by a remote control or app, in addition to the pot, you don’t have to worry about using a motorised potentiometer to keep track of the position.

MEMORY FUNCTIONS / RESTART

Depending on the digital pot you have and your application, it’s worth noting that different pots have different memory mechanisms. This means that if power is lost and the system is reset, your digital potentiometer may reset its position, failing to retain the original setting. This could be detrimental in certain circuits, or purely frustrating in others. In many applications however, it won’t matter.

This difference is determined by the memory method, which seems to be either EEPROM or RAM. EEPROM (electrically erasable programmable read only memory) is not power sensitive. Unless the contents of the EEPROM are explicitly changed, the memory will retain. However, if your digital pot uses RAM (random access memory), the memory only exists while power is applied.

If you’re integrating with a microcontroller, you can easily set the preferred starting value of the digital pot (or store it in the microcontroller’s own EEPROM). However if you’re planning to use it in a discrete build, or critical application where a reset could create an issue, it’s worth determining whether or not you should try and locate an EEPROM version.

Practical Example:

Testing The Output

fritzing

We got our hands on a few digital pots, namely the Microchip MCP4131. This is a 7 bit digital potentiometer, which means it has 128 steps. It operates from 1.8-5V, which makes it perfect for use with Arduino or Raspberry Pi, or your other favourite microcontroller. This particular version has a 10kΩ maximum resistance, but they’re available in 5, 10, 50, and 100kΩ variants (although availability may vary).

This is a single potentiometer version, however they’re available in single and double potentiometer, as well as single and double rheostat versions, with different options for memory, and 7 or 8 bit (129 or 257 step) resolutions. That’s plenty of options, but again, availability may vary. Sometimes it’s worth working with what’s readily available, than designing a circuit around one that’s harder to obtain.

In our test circuit, we’re going to use an Arduino UNO to communicate with the potentiometer, and basically sweep the potentiometer from one end of the range to the other. From there we can put a multimeter between the wiper and A or B terminals on the chip, and watch the resistance value change up and down.

schematic

Construct the circuit on the breadboard as shown, and load digital_pot_test.ino. You should instantly see the resistance value sweeping up and down when you apply your multimeter (select the range most suitable for a maximum 10kΩ resistance value).

Using the same circuit, you can also load digital_pot_triangle_wave.ino. This uses the “set value” command available in the digital pot, to step between resistance values. This may be a little more difficult to see on your multimeter; however, if you have an oscilloscope you will be able to see the waveform created.

CONCLUSION

This really only scratches the surface of what you can do with digital pots, so expect to see more of them in future editions.