Reference

This example uses the module’s two digital potentiometers to generate two out-of-phase triangular waves, demonstrating its basic operation and control. Configure POT0 and POT1 as voltage dividers (Terminal A to 5V, Terminal B to GND). Adjust POT0’s wiper W0 from min (0) to max (255) every 1 ms, then reverse; conversely, adjust POT1’s wiper W1 from max (255) to min (0) every 1 ms, then reverse. Use an oscilloscope’s CH1/CH2 to observe W0/W1 ground voltage waveforms respectively, verifying if all resistance values are accessible.

Library

This product uses the built-in SPI library of Arduino IDE. No additional libraries are required.

Communication Protocol Description

The MCP42100 digital potentiometer communicates via SPI. To change the wiper position:

  1. Send a command byte to select the potentiometer (POT0: 0x11, POT1: 0x12, both: 0x13).
  2. Send a data byte (0-255) to set the wiper position (0 = closest to B, 255 = closest to A).

For example, to set POT0's wiper to position 100:

  • Send command byte: 0x11 (select POT0)
  • Send data byte: 0x64 (100 in decimal)

API Description

DigitalPotWrite(int cmd, int val)

  • Purpose: Sends a command and value to the digital potentiometer via SPI.

  • Parameters:

    • cmd: Command byte (e.g., POT0_SEL = 0x11, POT1_SHUTDOWN = 0x22).
    • val: Wiper position value (0-255, constrained to this range).
  • Usage Example:

    // Set POT0's wiper to position 100
    DigitalPotWrite(POT0_SEL, 100);
    

Principle

This breakout employs MCP42100, which has two individual digital potentiometer POT0 and POT1 corresponding to two groups of terminals A0, B0, W0 and A1, B1, W1. Similar to the mechanical potentiometer, terminal A and B can be taken as two pins of a resistor (the nominal resistance is Rab=100KΩ) while terminal W is the wiper. The wiper can be changed to one of the 256 positions evenly distributed between A and B. The wiper is reset to the mid-scale position (Dn=128,0x80) upon power-up.

To change the position of the wiper W, two byte should be sent. The first byte is the command to determine which pot to be selected. The second byte is the data to determine the position of the wiper. This byte is also denoted as Dn. When Dn=0, terminal B is connected to W. When Dn=255, W is changed to the closest position to A. For example, to set W0 of POT0 to the position of 100, Arduino should first sends 0x11 (Write data, select POT0) and then 0x64 (=100, decimal) through the SPI.

DFR520_DigitalPot_basic.png

DFR0520_SPI1.png

DFR0520_SPI2.png

The resistance of each digital pot can be calculate by the equations below.

DFR0520_Res_Calculation_en.png

Was this article helpful?

TOP