Tuesday 25 February 2014

AD9850 DDS Chip Experiment

Today I decided to do some experimenting with the Chinese AD9850 Module and pulled out the trusty Freeduino which is permanently on my breadboard as a prototyping setup.

IMG_20140225_115141 

This is the module on the top and Freeduino on the bottom. Wiring up this little board is really simple. I am going to use 4 pin control of the board so therefore we only need four jumpers between our Freeduino/Arduino and the module.

  • Arduino Pin 8 – Module CLK (Clock) Pin
  • Arduino Pin 9 – Module FQ (Frequency Update) Pin
  • Arduino Pin 10 – Module DATA (Serial Data Load) Pin
  • Arduino Pin 11 – Module RST (Reset) Pin

 

Thats it from the wiring up perspective. Now instead of re-inventing the wheel I have found several sources of good code already made for running these boards quiet well and considering this is not a final production circuit there is no harm in showing what is already out there.

 

The Sketch:

/*
* A simple single freq AD9850 Arduino test script
* Original AD9851 DDS sketch by Andrew Smallbone at www.rocketnumbernine.com
* Modified for testing the inexpensive AD9850 ebay DDS modules
* Pictures and pinouts at nr8o.dhlpilotcentral.com
* 9850 datasheet at
http://www.analog.com/static/imported-files/data_sheets/AD9850.pdf
* 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);
  pinMode(RESET, OUTPUT);
  pulseHigh(RESET);
  pulseHigh(W_CLK);
  pulseHigh(FQ_UD);  // this pulse enables serial mode - Datasheet page 12 figure 10
}
void loop() {
  sendFrequency(55.e6);  // freq
  while(1);
}

 

As you can see in the above sketch that the frequency can be controlled with the command sendFrequency(55.e6); with 55 being the frequency that you are wanting.

The above code places the device on 55Mhz and powers it on.

My spectrum annylyzer screenshots below:

before

As you can see above there  is no signals on 55Mhz.

after

After powering up the Freeduino and module you can see the spike on 55Mhz clearly which means this little fella is outputting a nice 55Mhz. Please note that there is no antenna or power amp on the output of the circuit so this is just the modules output showing up.

zoomed

The frequency is also almost spot on. Very impressed with this little board. More to follow when I start actually replacing Oscillator circuits in old two way radios :-P Some fun could be had.

No comments:

Post a Comment