Pages: [1]   Go Down
Author Topic: how to program digital potensiometer AD5260  (Read 702 times)
0 Members and 1 Guest are viewing this topic.
Indonesia
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
« Last Edit: June 02, 2013, 04:18:11 am by watha2 » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Rob Tillaart

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

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what if you set it to a fixed value?

Code:
#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()
{
}
Logged

Rob Tillaart

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

Indonesia
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

- 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:
#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?
Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: