Controlling AD5254

Hi, I am trying to learn how to control AD5254 1k Digpot. I am using chip part #AD5254BRUZ1-ND
here is a wiring diagram of the circuit I made.


here is a simple code that will read the current position of the wiper of channel 0 and then set it to position 100. The code is able to read the current position, but not change it to 100. it is basically stuck at 127.

#include <Wire.h>
#define AD5254_ADDRESS 0x2C // I2C address of AD5254
#define RDAC0 0x00 // RDAC0 register address
byte wiperValue = 0; // variable to store wiper value

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

void loop() {
  Wire.beginTransmission(AD5254_ADDRESS);
  Wire.write(RDAC0);
  Wire.endTransmission();
  Wire.requestFrom(AD5254_ADDRESS, 1);
  while (Wire.available()) {
    wiperValue = Wire.read();
    Serial.print("Current Wiper Value: ");
    Serial.println(wiperValue);
  }
  Wire.beginTransmission(AD5254_ADDRESS);
  Wire.write(RDAC0);
 
  Wire.write(100);// set wiper value to 100
  Wire.endTransmission();
}

any help on how to change the value of the wiper is much appreciated

Take a look at this Arduino library for the AD5254.

I don't think AD0 and AD1 default to 0. Try connecting both of them to ground

Thanks, @jremington. I actually tried this lib first and still would not work.

hey @jim-p. I will definitely do that. however, I think I have tried that, also, I think by default, they are zero. I will try it again and see. what do you think about the code?

What does "not work" mean? Post the code, using code tags, and describe what did you expected to happen and what happened instead.

Does the I2C address scanner find the device and report the correct address?

Does the AD have internal pull-ups on the I2C lines?

1 Like

Even though the UNO has internal pull-ups on the I2C, for debugging purposes, connect a 10K resistor from SCL to 5V and SDA to 5V

Then try this code.

#include <Wire.h>
#define AD5254_ADDRESS 0x2C // I2C address of AD5254
#define RDAC0 0x00 // RDAC0 register address
byte wiperValue = 0; // variable to store wiper value
byte i;

void setup() 
{
  Wire.begin();
  Serial.begin(9600);
  
  // Set and read RDAC0
  // increment value from 0 to 255
  for (i=0;i<256;i++)
  {
    Wire.beginTransmission(AD5254_ADDRESS);
    Wire.write(RDAC0);
    Wire.write(i);
    Wire.endTransmission();
    delay(1);
    Wire.requestFrom(AD5254_ADDRESS, 1);
    while (Wire.available()) 
    {
      wiperValue = Wire.read();
    }
    Serial.print("Current Wiper Value: ");
    Serial.println(wiperValue);
    delay(500);
  }
  
  
}

void loop() 
{
}


Hi, here is a schematic of what you told me to do.

and here is what is happening

So, I have tried your code. It seems to be able to read the current position using your code and mine. but I want to change to the position of the wiper which I am not able to do

P.S. its a 1 k ohm DigiPot. using a ohm meter across W1 and B1 , it reads 500 ohms

Hi, @jremington. As I mentioned in above, I am able to read the current position of the wiper but not able to change it. I have used the example included in the library you mentioned.

NO. Measure on W0 and A0

WO>A0 ~ 550 Ohm
W0>B0 ~ 550 Ohm
A0>B0 ~ 1100 Ohm

Hi, I believe they do.

FOUND the PROBLEM!
WP must be connected to 5V

1 Like

Beautiful. Appreciate the help

FYI:

The AD5254 does NOT have pull-ups on SCL or SDA, so you need external pull-ups.

A0 and A1 cannot be left floating, they need to be connected to ground or 5V, depending on what I2C address you want.

WP is the write protect control for BOTH the internal EEPROM and the RDAC registers. It has an internal pull-down, so must be connected to 5V if you want to change the registers or EEPROM.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.