Clock & Timer Circuit Diagrams

# Learn To Use Digital Potentiometers Schematic Circuits Diagram

A resistor is an electrical device that resists the flow of electrical current. In the digital era, we can find a variety of “digital resistors” for our everyday applications. This article is about digital potentiometers. A digital potentiometer (digital pot) is a variable resistor that is controlled by digital signals instead of by mechanical movement. In principle, at the heart of a digital potentiometer is a resistor ladder with electronic switches at its every step. Only one electronic switch is closed at the same time, and in this way, the closed switch determines the wiper position and the resistance ratio. The amount of steps in the ladder determines the resolution of the digital potentiometer.

Digital potentiometers are integrated circuits with the initial position of the wiper at the midscale. However, some variants have an on-board (non-volatile) mem

ory that remembers the last wiper position. Something to take into account when you start working with digital potentiometers is the fact that most of them are rated at 5 Vdc, and 10 KΩ is the most popular value.

The MCP41010

MPC41010 is a tiny digital potentiometer from Microchip with a maximum resistance value of 10 KΩ (minimum value 100 Ω). The MCP41010 is a single-channel, 256-position digital potentiometer available in an 8-pin PDIP or SOIC package.

Now to the pin description of MCP41010:

• PA0: Potentiometer Terminal A
• PB0: Potentiometer Terminal B
• PW0: Potentiometer Wiper
• CS: Chip Select (SPI port chip select pin used to execute a new command after it has been loaded into the shift register)
• SCK: Serial Clock (SPI port clock pin used to clock in new register data)
• SI: Serial Data Input (SPI port serial data input pin. The command and data bytes are clocked into the shift register using this pin)
• VDD &VSS: Power supply terminals (2.7 V–5.5 V)

MCP41010 & Arduino Test

As you may have noticed, a digital potentiometer behaves the same as a mechanical potentiometer, except that instead of having a round handle that you can turn, it’s controlled by a digital interface. As a basic test, you can drive MCP41010 with the help of an Arduino UNO and its Serial Peripheral Interface (SPI) port. Note that SPI is a “synchronous” serial data bus — data can travel in both directions at the same time. On Arduino Uno (and compatible) boards, the SPI pins used are:

• SS – D10 (you can use other digital pins, but D10 is the default)
• MOSI – D11
• MISO – D12
• SCK – D13

Just refer to the datasheet and note that to program the digital pot, you have to first send a “command byte” (to tell the chip what to do) and a “data byte” (to tell the chip which value of resistance to set, from 0 to 255). As found in the datasheet, “executing any command is accomplished by setting CS low and then clocking in a command byte followed by a data byte into the 16-bit shift register. The command is executed when CS is raised.” Now prepare your hardware setup as follows!

In the hardware setup, MCP41010 is connected to the Arduino via the Arduino’s SPI Interface. Potentiometer terminals A (pin 5) and B (pin 7) are connected to the Arduino 5-volt supply (5 V) and Ground (Gnd). The wiper terminal W (pin 6) is connected to the Analog Pin 1 (A1) of the Arduino. The pretty simple sketch (shown below) loaded into the Arduino selects the MCP41010 and cycles through all 256 wiper positions (about 39 Ω per step). The voltage at the analog pin is then read and displayed on the serial monitor.

Sketch

#include
const int CS = 10;
int PotWiperVoltage = 1;
int RawVoltage = 0;
float Voltage = 0;
void setup() {
pinMode (CS, OUTPUT);
Serial.begin(9600);
SPI.begin(); // initialize SPI
}
void loop() {
// move the wiper in one direction
for (int level = 0; level < 255; level++) { MCP41010Write(level); delay(100); RawVoltage = analogRead(PotWiperVoltage); Voltage = (RawVoltage * 5.0 )/ 1024.0; Serial.print(“Level = ” ); Serial.print(level); Serial.print(“\t Voltage = “); Serial.println(Voltage,3); } delay(2000); // wait time // move the wiper in other direction for (int level = 255; level > 0; level–)
{
MCP41010Write(level);
delay(100);
Voltage = (RawVoltage * 5.0 )/ 1024.0;
Serial.print(“Level = ” );
Serial.print(level);
Serial.print(“\t Voltage = “);
Serial.println(Voltage,3);
}
delay(2000);
}
void MCP41010Write(byte value)
{
digitalWrite(CS,LOW); // select the chip
SPI.transfer(B00010001); // command byte
SPI.transfer(value); // data byte
digitalWrite(CS,HIGH); // de-select the chip
}

Check Also
Close

Close
Close