Digipot

Digital potentiometers are very handy for controlling resistance in analog circuits. This page shows how to control one of the simplest types a MCP4011 with 64 resistors internally.

These digipots are available in a range of fixed resistance and use a up/down control with no feedback of the current position. While designed for simple front panel control with push buttons, they can still be controlled by a microprocessor running Forth as long as it keeps track of the ‘wiper’ position.

Schematic

_images/digipot-cortex-m.jpg

The main thing to know is that the potentiometer is completely floating. It can be used to control the gain of a OP-AMP for instance.

The next thing to know is that the potentiometer must only be connected to voltages not less than the 0v and not more than the Vcc of the controlling MCU.

Datasheet

_images/mcp4011.jpg

Now the datasheet above has 61 pages, so you’ll definitely want to read it.

Forth Code

We don’t really need code examples because its pretty simple.

  1. maintain a counter from 0 - 63

  2. Stepping up one count increments the counter and sends one UP pulse to the digipot

  3. Stepping down one count decrements the counter and sends one /DOWN pulse to the digipot

SPI Digipots

There are other types with higher resolution (255 resistors) and SPI, flash and dual pots. See MCP413X/415X/423X/425X