Post Go back to editing

Different Resistance Values for AD5293

Category: Hardware
Product Number: AD5293

Hello, I have the following problem:

I am testing two AD5293 digital potentiometers, and when cycling through all bit values to set the resistance, one of them behaves strangely. At some points, it shows out-of-range values, such as 180kΩ (which I assume is an open circuit). Then, it starts working normally, varying between approximately 50kΩ and 100Ω.

However, when I try to set values manually, the readings are inconsistent. For example, at a setting of 0, it measures 166Ω; at 512, it measures 30kΩ; and at 1023, it measures 220Ω.

Meanwhile, the other potentiometer, which behaves more consistently, gives these values at 0, it measures 37.3kΩ; At 512, it measures 20.5kΩ; At 1023, it measures 180Ω.

Does anyone know what might be causing this? Is there a way to calibrate it, or could the potentiometer be damaged?

This is the code i'm using:|

#include <SPI.h>

const int slaveSelectPin = 5;  // CS
const int CLK = 18;
const int SDO = 19;
const int DIN = 23;


void setup()
{
  pinMode(slaveSelectPin, OUTPUT);
  SPI.begin();
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1));
  Serial.begin(115200);

  digitalWrite(slaveSelectPin, LOW);
  SPI.transfer(0x18);
  SPI.transfer(0x00); // Performance Mode
  digitalWrite(slaveSelectPin, HIGH);
  SPI.endTransaction();

  init_digiPot();
}

void loop()
{
  /*
  digitalPotWrite(0);
  delay(4000);
  digitalPotWrite(512);
  delay(4000);
  digitalPotWrite(1023);
  delay(4000);
  */
  unsigned int val;
  for (val = 0; val <= 1023; val++) {
    digitalPotWrite(val);
    delay(100);
  }
  for (val = 1023; val > 0; val--) {
    digitalPotWrite(val);
    delay(100);
  }
}

void init_digiPot()
{
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1));
  digitalWrite(slaveSelectPin, LOW);
  SPI.transfer(0x18);
  SPI.transfer(0x02); // Wiper update
  digitalWrite(slaveSelectPin, HIGH);
  Serial.print("Setup: ");
  Serial.println();
  SPI.endTransaction();
}

void digitalPotWrite(unsigned int val) {
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1));
  digitalWrite(slaveSelectPin, LOW);
  byte highbyte = (val >> 8) + 0x04;  //high wiper byte + command wiper update
  byte lowbyte = val & 0xFF;
  SPI.transfer(highbyte);  //send wiper data high byte
  SPI.transfer(lowbyte);   //send wiper data low byte
  Serial.print("Val: ");
  Serial.println(val);
  digitalWrite(slaveSelectPin, HIGH);
  SPI.endTransaction();
}
  • Hi,

    The erratic readings I tjink were likely caused by the default write protection (C1 = 0) on the RDAC register. Disable it by sending Command 4 with bit C1 set to 1.This change lets the wiper update correctly.

    Br,

    Den

  • Hi Den,

    I just tried this, but the issue wasn’t resolved, although I’m not sure if the readings became more accurate afterward. However, I implemented a code to read a value from the serial port to manually assign values and better observe the potentiometer’s behavior.

    At first, at bit 0, it read 1.3kΩ, which gradually decreased to 160Ω at bit 16. Then, at bit 17, it suddenly jumped to 200kΩ (values it shouldn’t be taking) and remained that way until bit 261. After that, at bit 262, it read 50kΩ and continued decreasing until bit 1023, where it reached 1.4kΩ.

    I activated the reset pin and reloaded the code onto the ESP32, and something similar happened. However, this time, at bit 0, it read 160Ω, and at bit 1, it jumped to 200kΩ until around bit 215. After that, it started decreasing again, reaching around 220Ω at bit 1023.

    It’s strange, almost as if the received bits were offset.

    Regards,
    Toty