Pages: [1]   Go Down
Author Topic: Digit Pot AD5293 SPI not working using NANO Board  (Read 628 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

and sorry in advance for a possibly stupid question! But after trying 2 days get the digital potentiometer AD5292 on an Arduino Nano working with no success this forum is my last hope. I have 2 other digi pots AD5242 which works perfect on i2c and a MCP4152 50k on SPI is also working. So I think my board should be ok.
I read a lot of threads were people have the same problem with the AD5293. I read the datasheet carefully and I think there is something wrong in my code. Some guys on the internet say I have send the 0x1802 command first then 0x02 and at least the value. So I tried the Arduino sample code for SPI which works perfect with my mcp4152.
Here is the tronixstuff code:
Code:
#include <SPI.h>

/*
 Example 34.1 - SPI bus demo using a Microchip MCP4162 digital potentiometer [http://bit.ly/iwDmnd]
 http://tronixstuff.com/tutorials > chapter 34 | CC by-sa-nc | John Boxall
*/
//POT          ARDU Nano
// CS  -->     10
// SLK -->     13
// MOSI(SDI)-> 11
// MISO(SDO)->(not used)
// Vdd --> +5V or 3.3V for Logic // higher external voltage is not used at the moment because I want to measure only the resistor value with an ohm-meter
// Vss --> GND
//Reset --> Vdd
//Ready --> Vdd

int ss=10; // using digital pin 10 for SPI slave select
int del=400; // used for various delays

void setup()
{
  pinMode(ss, OUTPUT); // we use this for SS pin
  SPI.begin(); // wake up the SPI bus.
  SPI.setBitOrder(MSBFIRST);
  // our MCP4162 requires data to be sent MSB (most significant byte) first
}

void setValue(int value)
{
  digitalWrite(ss, LOW);
  SPI.transfer(6146); // send command byte as int  which is 1802 hex
  SPI.transfer(value); // send value (0~1280) // I using the sample value given in the Datasheet which is hex 0x0500 -->  int= 1280 this should move up the pot to1/4 of full scale
  digitalWrite(ss, HIGH);
}

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

Maybe the code is correct and my pot was soldered too hot, but I'm absolutely not sure, because when I power up the NANO the Ohm-Meter shows the default value of the pot wich is 500 Ohm, but nothing  more happens after uploading the code.
So if anybody can help it would be absolutely great!
BTW: No, I can not use other pots because only this can handle +-9V and up to 2mA.

I heard that other have successfully worked with the AD5290 but this has different behaviors with CLK, CS and SDI.

Best regards
Maik

PS: I have very basic knowledge of this stuff. I'm able to read and understand most of the things from datasheets and code but adapting things is very hard for me - thank you.
Logged

Pages: [1]   Go Up
Jump to: