Few days ago I tested AD9850 DDS module in home in hope to some day have a working signal generator using it. The initial tests went well, so I could plan the next step. I was already doing some information searching to make decision if I should do the controlling using web interface (with Ethernet shield) or should I rather stick to traditional serial console controlling (through virtual serial port over USB).
When I tried to make decision on that and thinking of how much time is needed to implement the basic application for this use, I found interesting skech, something pretty much in line I was planning to code myself. When there is ready made free code, then why not use it… I found the code at https://gist.github.com/raivisr/3861473. It starts with the following documentation:
Simple controller for AD9850 modules
Uses serial protocol (refer to AD9850 datasheet what pins need to be pulled up/down
Uses library by Elecfreaks http://elecfreaks.com/store/download/datasheet/breakout/DDS/EF_AD9850_library.zip
(for use with chipkit delete that unnecessary line “#include <avr/pgmspace.h>” from .h file)
Fix the pin numbers used to communicate with module
Serial comms – 9600, NewLine (0x0A) denotes end of input,
f 10000 – set frequency
s 20 20000 10 1000 – sweep from frequency to frequency using this step size in that many milliseconds
o 10 10000 5 3000 – oscillating sweep from frequency to frequency and back using this step size in that many ms
NB! no error checking in input, code relies on intelligence of user
It looked pretty what I was looking for. So I did Cut&pase from web page and changed module connection configuration to match my wiring:
EF_AD9850 AD9850(8, 9, 11, 10);
Next task was to compile the thing and load to Arduino. But in this step I got compiling problems: Error messages told that EF_AD8950.h was missing..
Because the source code did not seem to have pointer to the needed library, I had to use Google searches in hope to find that. I found what I was looking at http://rockingdlabs.dunmire.org/exercises-experiments/ad-9850-dds-synthesizer. So I downloaded the needed library from link http://elecfreaks.com/store/download/datasheet/breakout/DDS/EF_AD9850_library.zip
Then I copied the library file form ZIP to to C:\Users\Tomi\Documents\Arduino\libraries\EF_AD9850
Tried compiling: Still problems with
I solved those problems with instructions from http://makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/. So I needed to replace
line at C:\Users\Tomi\Documents\Arduino\libraries\EF_AD9850\EF_AD8950.h with following (using Notepad++ editor):
#if ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif
Now I got the code to compile correctly.
I loaded the code to the Arduino Uno and started communication test with is using Serial Monitor provided with Arduino IDE. I connected my oscilloscope/multimeter between ZOUT1 and GND pins to monitor the output signal.
First test: f 10000 – set frequency
Sent: f 10000
Result: Nothing. After some investication I found out that I had to have the setting “No line ending” in Serial Monitor. I changed that option to “Both NL & CR” and got everythign working well. I tried different frequencies from 1 Hz to 20 MHz, and they worked well.
Next test: s 20 20000 10 1000 – sweep from frequency to frequency using this step size in that many milliseconds
Third test: o 10 10000 5 3000 – oscillating sweep from frequency to frequency and back using this step size in that many ms
One question raised after testing: How to turn off? Just set frequency to zero, meaning “f 0″ or just “f”.
The two analogue signal outputs give out around 0.5V signal level sinewave at about 100 ohms impedance. Both outputs give out same frequency but the outputs have 90 degrees phase shift between them. In addition to that there are TTL level square wave outs.