JQIamo / AD536x-arduino

Arduino library for interfacing with Analog Devices AD5360 series DACs (AD5360, AD5361, AD5362, AD5363)
4 stars 2 forks source link

A reference program #1

Closed psystein closed 2 years ago

psystein commented 3 years ago

Hello Fellow Coder,

We are trying to use your library to interface the AD5360 DAC with an Arduino. We would appreciate it if you could upload a reference program so we could understand the sequence of steps / functions / Configurations you have done to get the DAC working with the Arduino.

Would appreciate a example / reference program for this.

Warm Regards

restelli commented 3 years ago

Dear @psystein , there might be issues running this 6 years old library on modern Arduino environments since the Arduino SPI libraries have been refactored a bit over the years, so this code might have to be updated. Unfortunately the hardware that was used to develop the library is not available to me at the moment therefore I can't troubleshoot possibile issues. What I can do is to share a minimal snippet of code that should run. Assuming you have connected the AD5360's CLK MISO and MOSI to the native SPI pins of your Arduino compatibile board (we used an Arduino Due based on the SAM3X8E ARM M3) and you defined the pins cs, clr, ldac and reset you should be able to control the DAC by using some code like this:

#include "AD536x.h"

// your code here
#define CS <your specific pin here>
#define CLR <your specific pin here>
#define LDAC <your specific pin here>
#define RESET <your specific pin here>

AD536x(CS, CLR, LDAC, RESET) AD5360;

//more global variables or functions....

void setup(){
    //example where we define the global offsets in case the DAC configuration is bipolar. 
    AD5360.writeGlobalOffset(0,0x8000);
    AD5360.writeGlobalOffset(0,0x8000);

}

void loop(){

       //your code where you define bank, channel and specify value as an unsigned integer limited to 16 bit range. 

       AD5360.writeDAC(bank, channel, value);

      // other code.

}

Unfortunately I have no means to test the code or write a more extensive example without actual hardware.

Good luck!