AnsweredAssumed Answered

Controlling a digital potentiometer (AD5142) by Arduino Uno

Question asked by sunghunkim on Jun 4, 2015
Latest reply on Jul 6, 2015 by msamera

Hi, I am trying to control digital potentiometer (AD5142) by Arduino UNO.

캡처.PNG
Here is the pin configuration of AD5142.

I connect SCLK pin to 13 pin of Arduino (serial clock pin), SDI pin to 11 pin of Arduino (MOSI pin) and SDO pin to 12 pin of Arduino (MISO pin).

SYNC pin was connected to digital output pin of Arduino.

And according to the data sheet of AD5142, I connected the RESET pin to V(LOGIC) pin because I don't want to use reset.

V(DD), A1 and A2 pin to 5V and V(SS) to ground.

And I used the Arduino code below,

 

------------------------------------------------

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

// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 8;

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

void loop() {
//***********************************************************
int channel1 = 0;
/////////////////////
double voltage1 = 2;
/////////////////////
double level1 = voltage1 * 51;
digitalPotWrite(channel1, level1);

 

int channel2 = 1;
/////////////////////
double voltage2 = 2;
/////////////////////
double level2 = voltage2 * 51;
digitalPotWrite(channel2, level2);
}
//***********************************************************

void digitalPotWrite(int address, double value) {
   // take the SS pin low to select the chip:
   digitalWrite(slaveSelectPin,LOW);
   //  send in the address and value via SPI:
   SPI.transfer(address);
   SPI.transfer(value);
   // take the SS pin high to de-select the chip:
   digitalWrite(slaveSelectPin,HIGH);
}

------------------------------------------------

 

However, I cannot control the resistance of AD5142.

Can you help me?

Outcomes