Go Down

Topic: how to program digital potensiometer AD5260 (Read 771 times) previous topic - next topic

watha2

Jun 02, 2013, 04:28 am Last Edit: Jun 02, 2013, 11:18 am by watha2 Reason: 1
Hello everyone I need to program digital potentiometer AD5260,
It's volatile memory and use SPI.
I connect the pin llike this :
Pin1 A +15Volt
Pin2 W Output
Pin3 - B- Ground
Pin4 VDD +15Volt
Pin5 SHDN +15Volt
Pin6 CLK Pin 13 Arduino
Pin7 SDI Pin 11 Arduino
Pin8 CS Pin 10 Arduino
Pin9 PR +15Volt
Pin10 GND Ground
Pin11 -VSS-Ground
Pin12 VL +5Volt
Pin13 -NC-No Connect
Pin14 -SDO-Pin 12 Arduino

And use the code below:
#include "SPI.h" // necessary library
int ss=10; // using digital pin 10 for SPI slave select
int del=200; // used for various delays

Code: [Select]
void setup()
{
 pinMode(ss, OUTPUT); // for SS pin
 SPI.begin(); // wake up the SPI bus.
 SPI.setBitOrder(MSBFIRST); //ent MSB (most significant byte) first
}

void setValue(int value)
{
 digitalWrite(ss, LOW);
 SPI.transfer(0); // send command byte
 SPI.transfer(value); // send value (0~255)
 digitalWrite(ss, HIGH);
}

void loop()
{
 for (int a=0; a<256; a++)
 {
    setValue(a);
    delay(del);
 }
 for (int a=255; a>=0; --a)
 {
    setValue(a);
    delay(del); }
}

But it won't work, the output on W still stuck on the midpoint, around 7,27 Volt.

robtillaart

Welcome on the Arduino board, please modify your post , select the code part and press the # button above the smileys to get proper code tags.
It will look more readable that way.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

robtillaart

what if you set it to a fixed value?

Code: [Select]

#include "SPI.h"

const int ss = 10;       // using digital pin 10 for SPI slave select
const int del = 200;

void setup()
{
  pinMode(ss, OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);

  setValue(a);
}

void setValue(int value)
{
  digitalWrite(ss, LOW);
  SPI.transfer(0); // send command byte
  SPI.transfer(value); // send value (0~255)
  digitalWrite(ss, HIGH);
}

void loop()
{
}
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

watha2

Thank you for answering my question and noticing my post Rob,
I did try this method, but it still didn't work,
Am i connect the pin to the wrong connection?
I've tried AD8402 before, the program works fine,
But it didn't in AD5260.
Please help me.

robtillaart

- http://www.analog.com/static/imported-files/data_sheets/AD5260_5262.pdf - page 5 says you only need to send a data byte, so setvalue() becomes simpler

Code: [Select]
#include "SPI.h"

const int ss = 10;       // using digital pin 10 for SPI slave select
const int del = 200;

void setup()
{
  pinMode(ss, OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);

  setValue(200);
}

void setValue(int value)
{
  digitalWrite(ss, LOW);
  SPI.transfer(value); 
  digitalWrite(ss, HIGH);
}

void loop()
{
}

Can you give it a try?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up