DDS AD9851 and Arduino


Direct digital synthesizer is a type of frequency synthesizer used for creating arbitrary waveforms from a single, fixed-frequency source. The AD9850 is a low cost device that can produce sine waves up to 125 mHz and the output frequency is set digitally using an MCU, such as an Arduino.

In addition to Gnd and 5 volts only four connections are required and these are shown in the sketch below. When I first obtained this device I could find very little information, but eventually came across this sketch. I quickly got it up and running and the picture shows an oscilloscope trace taken from the output Sine A.

* A simple single freq AD9850 Arduino test script
* Original AD9851 DDS sketch by Andrew Smallbone at
* Modified for testing the inexpensive AD9850 ebay DDS modules
* Pictures and pinouts at
* 9850 datasheet at
* Use freely

#define W_CLK 8 // Pin 8 - connect to AD9850 module word load clock pin (CLK)
#define FQ_UD 9 // Pin 9 - connect to freq update pin (FQ)
#define DATA 10 // Pin 10 - connect to serial data load pin (DATA)
#define RESET 11 // Pin 11 - connect to reset pin (RST).

#define pulseHigh(pin) {digitalWrite(pin, HIGH); digitalWrite(pin, LOW); }

// transfers a byte, a bit at a time, LSB first to the 9850 via serial DATA line
void tfr_byte(byte data)
for (int i=0; i<8; i++, data>>=1) {
digitalWrite(DATA, data & 0x01);
pulseHigh(W_CLK); //after each bit sent, CLK is pulsed high

// frequency calc from datasheet page 8 = <sys clock> * <frequency tuning word>/2^32
void sendFrequency(double frequency) {
int32_t freq = frequency * 4294967295/125000000; // note 125 MHz clock on 9850
for (int b=0; b<4; b++, freq>>=8) {
tfr_byte(freq & 0xFF);
tfr_byte(0x000); // Final control byte, all 0 for 9850 chip
pulseHigh(FQ_UD); // Done! Should see output

void setup() {
// configure arduino data pins for output
pinMode(FQ_UD, OUTPUT);
pinMode(W_CLK, OUTPUT);
pinMode(DATA, OUTPUT);

pulseHigh(FQ_UD); // this pulse enables serial mode - Datasheet page 12 figure 10

void loop() {
sendFrequency(10.e6); // freq


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: