Updated 2015-03-06
Here’s a library that I created for interfacing the Arduino to Analog Devices DDS chips. Currently the 9850 and 9851 are supported. Support for the 9834 is currently in development. Please post on the Radio Artisan discussion group if you are interested in support for other chips or if you can contribute code.
To install this library:
1. Download dds.h and dds.cpp from GitHub or Sourceforge.
2. Create a directory in your sketchbook library directory called dds.
3. Copy the two files into the dds directory.
How to use the library:
First you need to create a dds instance by calling ddschip like so:
dds ddschip(DDS9850, 8, 6, 7, 100000000LL);
The parameters are:
- Chip type
- Data Pin Number
- Load Pin Number
- Clock Pin Number
- Clock Frequency in Hertz (if using the clock multiplier on chips equipped with one, use the frequency after multiplication, not the actual clock frequency going into the chip)
If you are using the clock multiplier in the 9851 chip, activate the multiplier:
ddschip.set_clock_multiplier(1);
If you would like to calibrate the frequency output, call the calibrate function like so:
ddschip.calibrate(0.0000495);
This is used to compensate for a reference clock that is off frequency (they all are, unless you’re using some sort of uber-expensive atomic clock. The correct factor is applied as so:
clock_frequency_used_in_formula = clock_frequency – ( clock frequency * calibration_value)
In the example above, the calibration value of 0.0000495 would result in a correction of -4.95 kHz.
To set the unit frequency, call the setfrequency function:
ddschip.setfrequency(7000000LL);
The frequency unit is hertz.
Connecting the Arduino to the Chip
There are three data connections required: data, clock, and load, and of course, a common ground. The three pins on the Arduino side are defined in the ddschip instance, as shown in the example above. Here are the pins to connect to on the chips:
9850 & 9851
- Data Pin: 25
- Load Pin: 8
- Clock Pin: 7
9834
- Data Pin: 13
- Load Pin: 15
- Clock Pin: 14
Support and Feature Requests
For support or to request features, please go to the Radio Artisan discussion group.
sample code
#include #include // chip, data_pin, load_pin, clock_pin, clock_hz dds ddschip(DDS9850, 8, 6, 7, 100000000LL); void setup() { ddschip.calibrate(0.0000495); } void loop() { ddschip.setfrequency(7000000LL); delay(2000); ddschip.setfrequency(8000000LL); delay(2000); }
Hi, can you add support for AD9834 and publish some schematics of how connect arduino to dds pin?
Thank you
Yes. I’m looking at the 9834 datasheet and I should be able to add support for that in a few days. I’ll also enhance the documentation here on how to connect the chip to the Arduino and use the library.
Updated code uploaded with 9834 support. I have no way to test this as I don’t have a 9834 chip, but I’ve followed the device documentation in writing this. I also added a function to activate triangle wave:
ddschip.set_triangle_wave(1);
You’ll need to do a ddschip.setfrequency to activate it.
Thank you very much! Is possible to use DDS with a breakout on breadboard?
It should work in a pinch, though you might get erratic operation above 30 Mhz.
I’ve found http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=1423&item_type=project library, I’ve tested it and works but how to generate triangle wave?
Thank you but I’ve tested it but doesn’t works with 9834 (that is like 9833 in programming)..
There is no load pin, i’ve used FSYNC but doesn’t works..
Output is always a 12.5 MHz Sine wave (with a 50 MHz oscillator)
Send me your .ino file, email address anthony dot good at gmail dot com, and we’ll troubleshoot it over email.
I found several errors in my code and I added some additional initialization items. The output of it now matches an example they have in this application note: http://www.analog.com/static/imported-files/application_notes/AN-1070.pdf
Try the new library files I uploaded, and if it still doesn’t work, send me your ino file.