AD5175 i2c digital pot issues

Hi, I’m looking for someone that has used the ad5175 digital pot with arduino before. I see a couple people did on here, but didn’t go into any detail about how they got it working.

I ran an i2c scanner, and it’s finding the ad5175. All I’m getting out of the wiper is 5k, which from the datasheet normal(at 50%).
I’m running the code from this example, but I changed the max val to 1024 to match the ad5175. Still should work, right?

// I2C Digital Potentiometer
// by Nicholas Zambetti <http://www.zambetti.com>
// and Shawn Bonkowski <http://people.interaction-ivrea.it/s.bonkowski/>

// Demonstrates use of the Wire library
// Controls AD5171 digital potentiometer via I2C/TWI

// Created 31 March 2006

// This example code is in the public domain.

// This example code is in the public domain.


#include <Wire.h>

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
}

byte val = 0;

void loop()
{
  Wire.beginTransmission(47); // transmit to device #47 
                              // device address is specified in datasheet
  Wire.write(byte(0x00));            // sends instruction byte  
  Wire.write(val);             // sends potentiometer value byte  
  Wire.endTransmission();     // stop transmitting

  val++;        // increment value
  if(val == 1024) // if reached 1024th position (max)
  {
    val = 0;    // start over from lowest value
  }
  delay(500);
}

Hi noobtube

The AD7175 powers up with write protect on and wiper at 50% (as you found), so you can't immediately write new values to it.

In setup(), use this code to enable writing and (as a first test) set the wiper to 25%. I'm assuming that 47 decimal is the value reported by I2C scanner?

For this first test, remove all your code from loop().

Wire.beginTransmission(47);
Wire.write(0x01);  // Disable write protect on RDAC
Wire.write(0xC2);  //
Wire.endTransmission();

Wire.beginTransmission(47);
Wire.write(0x05);  // Write 0x0100 to RDAC
Wire.write(0x00);  //
Wire.endTransmission();

If that works, then here are some comments on your program.

Wire.write(val);

Wire can only send 8 bits in each write. To send a bigger value (in this case up to 1024), you need two writes. Only the bottom 10 bits of the 16 bits sent to the AD7175 hold data (10 bits to give 1024 different values). But the AD7175 command structure means that the 10 bits have to be combined with a top 6 bits that include a fixed command code. That is why (in the example above) the first byte is 0x05 when the data of interest is 0x01.

So your statement needs to become two statements ...

Wire.write((val / 256) | 0x04);  // Take top byte of val and OR with 0x04 to set command value
Wire.write(val % 256); // Send bottom byte of val

At present, the code below will wait 0.5s between each increase in val. So it will take 8 minutes to complete one cycle. You may want to reduce the delay to see the change happening more easily.

val++;        // increment value
...
delay(500);

Regards

Ray

Hi,

Thanks for the reply. Makes sense. Unfortunately, even the test didn't work. still 5k. I don't have the 10uf cap between vdd and grnd, only .1uf. Think that would do it?

i2c scanner shows address of 47.

I ran out of time today, but hopefully this weekend I can take another crack at it with the 10uf cap.

Thanks again,

Mark

Adding the extra capacitor could help.

Also, do you have pull-up resistors from SDA and SCL to +5V? Are you powering the AD7175 from +5V?

And another thing to try is to print the return code to see if there are transmission errors.

Serial.print("Result of disable write protect: ");
Wire.beginTransmission(47);
Wire.write(0x01);  // Disable write protect on RDAC
Wire.write(0xC2);  //
Serial.println(Wire.endTransmission());

Hi, yes I'm using pull up resistors on both to 5v. Powering the ad5175 with 5v as well. I'll report back asap. I'll also try an external power supply vs usb. Thanks!

I post this incase someone needs it
RST Pin7 to VCC
ADR Pin8 to GND make I2C address as 47
Connect 1uF to Pin5 Cap

This pot is slightly adjust better MCP41010 256 steps

#include <Wire.h>
#define Addr                      47    
#define Write_RDAC              1   
#define Read_RDAC               2 
#define Reset_RDAC              4
#define Write_Reg                 7
#define Emable_WP               0
#define Disable_WP               2
#define Pot_Resolution          10000/1024          //9.765 Ohm/Step  8K Ohm  = (8000/9.765 = 819 Steps for AD5175

int i=0;

void setup()
{
  Serial.begin (19200);
  Wire.begin();
  AD5175_control (Reset_RDAC);
  AD5175_control (Disable_WP);
    


  for (i = 0; i <= 1023; i++)
    {
      Serial.println (i);
      AD5175_write_data (i);
      delay(1500);
    }

}

void loop()
{



}

void AD5175_control (unsigned int data)   {     
  data = data |  Write_Reg  << 10;                 // include control code before write..
  Wire.beginTransmission(Addr);               // Start I2C transmission to that address
  Wire.write(highByte(data));
  Wire.write(lowByte(data));
  Wire.endTransmission();                     // Stop I2C transmission
}
    


void AD5175_write_data (unsigned int data)   { 
  data = data |  Write_RDAC << 10;                 // include control code before write..
  Wire.beginTransmission(Addr);               // Start I2C transmission to that address
  Wire.write(highByte(data));
  Wire.write(lowByte(data));
  Wire.endTransmission();                     // Stop I2C transmission
}