The first library, DDS, uses soft SPI to allow any Arduino to control a DDS Module. It is suitable for use with the Kanga / m0xpd DDS Shield.
The second library, DueDDS, uses the enhanced features of Arduino DUE and hardware SPI to achieve a faster interface to a DDS Module. I've been using the DueDDS library in my experiments with Software Defined Radio on the DUE.
To use any library, you need to have a description of the resources that library offers - this description is called the Application Programming Interface - or API...
The two DDS libraries share very similar APIs, differing only in how the resulting DDS classes are instantiated...
DDS is instantiated by...
where the arguments identify four Arduino pins which connect to the Module.
DueDDS is instantiated by...
In both cases above (and in the following examples), the resulting instance is called "dds" - but you can call it anything you like. After instantiation, the APIs are identical...
The DDS Module is initialised by the line:
and the frequency of the oscillator is set by this command:
That's all you need to use the Module - three lines - instantiate, initialise and set. Of course, you can change the oscillator frequency by calling setFrequency() as many times as you like!
I've been completely satisfied by the accuracy of the DDS Modules straight "out of the box" for my simple Ham Radio applications. Perhaps I'm easily pleased! But some people like to have oscillators set to the last part-per-million of precision. Others may have DDS Modules with a non-standard clock (the default is 125MHz).
For these demanding applications, the libraries offer one more command, which allows you to "set the clock" of the DDS:
So - if you find that your Module's clock actually runs at 125000017 Hz and you care about it, you would enter '< name>.
After the .trim() command, all responses to subsequent setFrequency() commands will reflect the trimming. The trim value is held in volatile memory, so the trim command needs to be applied every time the module is powered up.
Now you've seen how the software works - how do you connect the module to your Arduino?
Connecting the Module
The AD9850 DDS Module can run with any Arduino under the DDS library. The required connections are shown here:
You must nominate four IO pins as shown above (these are used as the arguments when you create the instance using DDS < name>
The AD9850 DDS Module can be controlled more quickly with an Arduino DUE under the DueDDS library. The required connections are shown here:
Two of the Module's pins are connected to pins on the SPI header of the DUE (which is in the same position as the ICSP header on other Arduinos). The other two lines from the DDS Module are connected to two Arduino IO pins, which you must nominate during instantiation. You must also choose one of the hardware "Slave Select" pins (one of 4, 10, or 52). This pin won't be used in our interface - but it can't be used for anything else!
The important pins on the DUE are shown below...
Download and Use of the Libraries
To download the library, visit the GitHub repository and press the "Download ZIP" button on the right of the screen...
Once you've downloaded the ZIP archive, you must de-compress it amd the change the name of the resulting folder to either DDS or DueDDS, depending upon which library you've downloaded.
Then you must put this folder in your Arduino/libraries folder.
Before you can use the library for the first time you must close and re-start the Arduino IDE.
You will be able to confirm that the library is correctly installed, as it will be in the list which appears in the Arduino IDE if you click on 'Sketch' and hover over 'Import Library...'
Examples Using the Libraries
Within each library, you'll find an examples folder. In this folder is a really simple application, "oneMHz", which sets up the DDS Module to produce a 1MHz output. These examples exercise all the functions available in the libraries - so they'll teach you all you need to know!
This is the first time I've written an Arduino library - so I'd love to hear about anybody's experiences with these resources - good or bad.
...-.- de m0xpd