AD8400 Digipot with Arduino Uno R3: Non Linear Output Resistance

I am controlling the AD8400(1 kohm) digipot with Arduino Uno R3 using SPI interface. My connections are as follows:

Digipot <-> Arduino

CS(3) <->10

SDI(4) <-> 11

CLK(5) <->13

VDD(6) <-> 5v

GND <-> GND

I am checking the resistance across terminal W and B using multimeter after giving input between 0 to 255.But the resistance obtained is not varying linearly and it also exceeds the Resistor Nonlinearity((-4) -(+4) LSB) provided in datasheet.

Below is the graph obtained for values between 0-255

Blue line indicates the observed values

Red line is for the equation:

Resistance = 43.2 + (Data/ 255) * (1000)

Below is the code used:

#include <SPI.h> // include the SPI library

#define slaveSelectPin 10 // set pin 10 as the slave select for the digital pot

int address = 0; //addr bits = 0)
int value = 72; // value can be anything between 0 to 255

void setup() {
  pinMode(slaveSelectPin, OUTPUT);// set the slaveSelectPin as an output:
  Serial.begin(115200);  
  SPI.begin(); // initialize SPI:
}

void DigitalPotWrite(int addr, int val){
  digitalWrite(slaveSelectPin, LOW);
  SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE1)); //initialises SPI clock speed, mode and bit order
  digitalWrite(slaveSelectPin, LOW);
  SPI.transfer(addr);
  SPI.transfer(val);
  digitalWrite(slaveSelectPin, HIGH);
  SPI.endTransaction(); 
}

void loop() {
  digitalWrite(slaveSelectPin, HIGH); // ensure default CS stays high for now
  DigitalPotWrite(address, value);
  delay(5000); //arbitrary delay 
}


Can someone please check what could be the error and how to reduce it??

Does your multimeter 'auto range'?
There could be discontinuities as the meter changes range.

Most autorange multimeters can be set to stay on a particular range.
Choose a range that will read up to the maximum resistance of the AD8400.

That statement should be in setup()

 SPI.endTransaction();

Remove this statement

There should be a delay after setting SS pin LOW and before setting it HIGH

Value and address should be byte

In addition to what @JohnLincoln said, if you are using this on a breadboard, consistent readings could be problematic.

Yes I had used an autoranging multimeter... will try that

How much delay would you recommend?.... I have kept SPI speed 10 MHz

The minimum you can use will depend on you physical set-up but for debugging purposes use 1ms

I would try SPI_MODE0.


https://en.wikipedia.org/wiki/Serial_Peripheral_Interface#Mode_numbers

Sorry for the late update.... I tried with SPI Mode0 and it worked! I also added made changes in code according to what @jim-p suggested. Thank you so much everyone. The graph obtained is quite linear now
Capture1

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