AnsweredAssumed Answered

AD5291 won't update wiper value

Question asked by luismex on Aug 24, 2017
Latest reply on Aug 25, 2017 by isantos

Hello to all you guys, I am new here and right now  have been working for 2 days with this component. I've been searching and finally made it work. I use Arduino Uno to control the values and using the SPI bus.  


The problem is that if I want to change the wiper value in the same loop it won't update. I have to restart the Arduino and or compile again the code so it could be updated to the actual value. Sadly I don't have an osciloscope to see the signals but I'm sure the Loop is working because by the Serial Monitor I can see the input values, also I see how the RDY blinks.




What I've been trying:

- Making sure the AD5291 has the right capacitors and resistors

- I tried sending 0x1803, 0x0000, 0xXXXX , 0x0000 but it does not update the actual value


It would be really helpful if you give me some ideas to solve this problem, Thanks in advance


I leve the code in arduino


#include <math.h>
#include <SPI.h>

const int sensorPin = A0; // Input PIN for the Sensor value
int value1; // Input value
int sensorValue;
int d=2;
byte command1 = 0x04; // Comando to change value (based on table 11 of the datasheet)


void setup() {
pinMode(10, OUTPUT); //Pin SS Digipot
digitalWrite(10, HIGH); // For default in High
pinMode(13, OUTPUT);
SPI.begin(); //Initialize SPI
delay(1000); // Delay time 
Serial.begin(9600); //Used to view values in the Serial Monitor



void loop() {
analogReference(EXTERNAL); // Reference of the Analog Input
sensorValue = analogRead(sensorPin); //  Read Analog Input
value1 = map(sensorValue, 0, 1023, 0, 64); // Mapping the Input values to what I need at the output
Serial.println(sensorValue); //Show actual value of the sensor
Serial.println(value1);  //Show mapped value

byte valorn1 = (value1 >> 6); // Moving the value six bits to the right
command1 += valorn1;  // Creating the first BYTE of the shift register
byte datos1 = (value1 <<2);  // Creating the second BYTE of the shift register


// Message to activate change of the wiper (Based on table 13 and 14 of the Datasheet)

digitalWrite (10, LOW); // Enable Digipot

SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1)); //SPI properties for the Digipot
SPI.transfer(0b00011000); // Sending 0x1802 - First BYTE
SPI.transfer(0b00000010); //Sending the second BYTE
digitalWrite (10, HIGH); // Disable Digipot
SPI.endTransaction(); // Finish session

// Messsage to change the value of wiper
digitalWrite (10, LOW); 
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1)); //Parametros SPI del Digipot
SPI.transfer(command1); // Sending fist byte
SPI.transfer(datos1); // Sending second byte
digitalWrite (10, HIGH); 


// Reseting values
valorn1 = 0b00000000;
command1 = 0b00000000;
datos1 = 0b00000000;