Using the AD5693R breakout with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller, installing the Adafruit_AD569x library, and running the provided example code.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the breakout VIN.
Here is an Adafruit Metro wired up to the breakout using the STEMMA QT connector:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
The signal will be output from the DAC Vout (+) pin.
Here is an Adafruit Metro wired up using a solderless breadboard:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
The signal will be output from the DAC Vout (+) pin.
Library Installation
You can install the Adafruit_AD569x library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_AD569x, and select the Adafruit AD569x library:
If asked about dependencies, click "Install all".
If the "Dependencies" window does not come up, then you already have the dependencies installed.
#include "Adafruit_AD569x.h" #include <math.h> // For sine function Adafruit_AD569x ad5693; // Create an object of the AD5693 library void setup() { Serial.begin(115200); while (!Serial) delay(10); // Wait for serial port to start Serial.println("Adafruit AD5693 Test Sketch"); // Initialize the AD5693 chip if (ad5693.begin(0x4C, &Wire)) { // If A0 jumper is set high, use 0x4E Serial.println("AD5693 initialization successful!"); } else { Serial.println("Failed to initialize AD5693. Please check your connections."); while (1) delay(10); // Halt } // Reset the DAC ad5693.reset(); // Configure the DAC for normal mode, internal reference, and no 2x gain if (ad5693.setMode(NORMAL_MODE, true, false)) { Serial.println("AD5693 configured"); } else { Serial.println("Failed to configure AD5693."); while (1) delay(10); // Halt } // You probably will want to set the I2C clock rate to faster // than the default 100KHz, try 400K or 800K or even 1M! Wire.setClock(800000); Serial.println("Writing 2.5Vpp sine wave to output"); } void loop() { // Generate a sine wave and write it to the DAC for (float angle = 0; angle <= 2 * PI; angle += 0.1) { uint16_t value = (uint16_t)((sin(angle) + 1) * 32767.5); // Convert sine value to uint16_t if (!ad5693.writeUpdateDAC(value)) { Serial.println("Failed to update DAC."); } } }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the AD5693R recognized over I2C.
If you connect the DAC output to a scope or other analog visualizer, you will see a sine wave displayed.
Text editor powered by tinymce.