Digital potentiometers function using a "ladder" of resistors with floating wires at each junction. By setting the wiper register, the user can select which junction is connected to the wiper, and thus how many resistors in the ladder comprise the connection from A-to-W or from W-to-B.
Block diagram of a digipot's resistor network from the MCP4531T manual
The total number of resistors in a digipot is referred to as its number of taps or steps. In the above example from the manual of the MCP453X/455X/463X/465X family of digipots, the digipots can have 129 taps (i.e., 128 resistor ladder with 129 possible wiper positions) or 257 taps (i.e., 256 resistor ladder with 257 possible wiper positions). The resistance change at each step is then calculated as:
Step resistance equations from the MCP4531T manual
Digipot Hardware Limitations
Digipots are very low current devices.
The max allowable current across a digipot wiper is around 1-2.5 mA.
Here is example code for getting a MCP4531T digipot to increment its wiper value over time, and print the voltage at the wiper over Serial. The wiring diagram necessary for this code is also included below.
The necessary wiring of the MCP4531 digipot for the above code.
#include <Wire.h>
byte val = 0;
int errorPot;
byte a;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
// Wait until serial port is opened
while (!Serial) { delay(1); }
Wire.begin();
Wire.beginTransmission(46);
Wire.write(byte(0x00));
Wire.write(byte(10));
errorPot = Wire.endTransmission();
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("Wiper set to ");
Serial.println(val);
Wire.beginTransmission(46);
Wire.write(byte(0x00));
Wire.write(val);
errorPot = Wire.endTransmission();
float wiper_value = analogRead(A0);
wiper_value *= 5.0;
wiper_value /= 1024;
Serial.print("Error message: ");
Serial.print(errorPot);
Serial.print("\t");
Serial.print("Wiper Voltage: ");
Serial.println(wiper_value);
delay(1000);
val++; // Increment value
// if reached 128th position (max)
if(val == 128) {
val = 0; // Start over from lowest value
}
}