Search code examples
arduinoi2c

Interfacing MCP4651-502E digital potentiometer using I2C


I am using two MCP4651 dual digital potentiometers, which I want to control from Arduino Uno thru I2C. Here's datasheet for MCP4651, so you don't have to look for it: http://www.farnell.com/datasheets/1789212.pdf

I would also attach PCB schematic, but I don't have enough reputation.

I am trying to write my value into the wiper 1 register like on page 49 of datasheet. But every command I try, I get not acknowledged. I also attached screenshot of the oscilloscope.

screenshot of the oscilloscope

Here's my code:

#include <Wire.h>

void setup()
{
  Wire.begin();
}

void loop()
{
  Wire.beginTransmission(40);
  Wire.write(0b10010000);
  Wire.write(0b10000000);
  Wire.endTransmission(40);
  delayMicroseconds(500);
}

The I2C protocol clearly works, or I would not get acknowledged address and I tried both potentiometers, both wipers, writing, incrementing and decrementing. Not a single success. If anyone knows what am I doing wrong, I would be grateful.


Solution

  • Page 49 of the datasheet details the general call details.

    The general call commands are detailed on page 48. These commands are used when you are using the general call address (0) to communicate with all the devices at the same time.

    You are trying to communicate with a single device on the bus, so you should pay attention to the commands detailed starting at page 51 and in particular Table 7-1, 7-2 and Figure 7-1.