Interfacing A 20bit DAC AD5791 With Arduino Mega 2560
communication is not happening between ad5791bruz and arduino mega 2560
Images
Program
#include "ad57X1.h"
//#define CS_AD5791 53
#define cs_pin 53
#define ldac_pin 49
//AD5791 ad5791(CS_AD5791, &SPI); // Use AD5791 if using the 20 bit version
AD5791 ad5791(cs_pin, &SPI); // Use AD5791 if using the 20 bit version
// AD5781 pidDac(CS_AD5781, &SPI1); // Use SPI1 on MCUs, that have multiple SPI controllers (e.g. Teensy)
// AD5781 pidDac(CS_AD5791, &SPI, 30*1000*1000); // Use an SPI clock frequency of 30 MHz, the maximum specified for the DAC.
// If you experience trasmit errors, this might be due to your board layout.
void setup() {
ad5791.begin(); // Set the pin modes
SPI.begin();
ad5791.setOffsetBinaryEncoding(true); // Set the input encoding to offset binary. Default is 2s complement (false).
//ad5781.setReferenceInputRange(true); // Enable only if the reference voltage span is greater than 10 V, Default: false.
//ad5781.setOutputClamp(true); // Enable to clamp the output to GND using a 6k resistor
// ad5791.updateControlRegister(); // Call this function after changing the controll register, to update the settings
//ad5781.setTristateMode(true); // Disconnect the output (output will be tri-state)
//ad5781.updateControlRegister() // Call this function after changing the controll register, to update the settings
//ad5781.setInternalAmplifier(true) // Enable the internal amplifier. This setup allows connecting an external amplifier in a gain of 2 configuration. See the datasheet for details.
ad5791.enableOutput(); // Turn on the DAC. After startup the output will be clamped to GND and disconnected (tri-state mode)
// ad5791.setValue(0x3FFFF); // Set to full scale output
ad5791.setValue(0x20000); // Set to full scale output
}
void loop() {
}
Post a reply to Venkat
Think you can help Venkat ? Then post your thoughts that might help Venkat. You will earn a lot of reputation in the technical community.