Monday, 13 February 2017

BASIC Tech Group - MyNews 23 - New Arduino library for AD9850

There are a bunch of libraries on the net for the AD9850 synthesiser. But I wanted a one that was simple, but included the possibility of setting sub hertz frequencies, for example for WSPR use. The ADIC 9850 is of most use as an analog output frequency generator so I called mine ADS9850 (Analog Digital Synthesiser).

i have combined the best of those out there and made my own. Call ADS9850, you can find it here. It has just three functions:

void begin(int W_CLK, int FQ_UD, int DATA, int RESET);
void setFreq(unsigned long Hz, float Chz);
void calibrate(unsigned long calHz);
Example code

TAKE CARE! - Not yet tested as I am waiting for my AD9850 module to be delivered. I will report later if it works, but it complies OK.
// using ADS9850 library
// output a frequency 7100001.46Hz

#include "ADS9850.h"

// pins
#define W_CLK 8
#define FQ_UD 9
#define DATA 10
#define RESET 11

// create ads object
ADS9850 ads;

void setup() {
  ads.begin(W_CLK, FQ_UD, DATA, RESET);

  ads.calibrate(124999000); // calibrated XTAL freq

  ads.setFreq(7100000, 146); // output 7100001.46 Hz
}

void loop() {
  // put your main code here, to run repeatedly:

}

No comments: