[McHUG] DDS-60 Anyone????

Rich Mitchell geobra at att.net
Thu Nov 13 21:21:58 EST 2008



McHUGgers,

I found some avr-gcc code for programming the DDS-60 from an Atmel Tiny.  It was very easy to Arduino-ize.  Here is a sketch that will do 1 second at 7050 and 1 second at 7060.  Should be a piece of cake to turn into a library since there are no other libraries involved.  No I2C or TWI.  Real simple.  A lot easier than fixing a K2!!!!

Rich

//===============sketch begins==========
/* * * * * * * * * * * * * * * * * * * *
 * Converting Peter Marks' DDS-60 code
 * to the Arduino format.
 *
 * looks like no TWI or anything else -
 * just moving bits to pins.
 * DDS-60 pin 1 - load
 * DDS-60 pin 2 - clock
 * DDS-60 pin 3 - data
 * DDS-60 pin 4 - +5 out not needed
 * DDS-60 pin 5 - ground
 * DDS-60 pin 6 - RF out 
 * DDS-60 pin 7 - NA
 * DDS-60 pin 8 - V++
 * Simple compared to Si570
 * * * * * * * * * * * * * * * * * * * */

unsigned long ddsClock = 180000000;
int load = 7; // to DDS-60 pin 1
int clock = 8; // to DDS-60 pin 2
int data = 9; // to DDS-60 pin 3

void setup() {
 pinMode(load, OUTPUT);
 pinMode(clock, OUTPUT);
 pinMode(data, OUTPUT);
}

void loop() {
 unsigned long int f;
 f = 7050000;
 sendFreq(f);
 delay(1000);
 f = 7060000;
 sendFreq(f);
 delay(1000);
}

void sendFreq(unsigned long freq) {
 unsigned long tWord;  // tuning word
 tWord = (freq * pow(2,32)) / ddsClock;
 digitalWrite(load, LOW);
 
 int i;
 for (i = 0; i < 32; i++) {
  if ((tWord & 1) == 1) {
   outOne();
  } else {
   outZero();
  }
  tWord = tWord >> 1;
 }
 byteOut(0x09); // send this out
 digitalWrite(load, HIGH);
}

void byteOut(unsigned char byte) {
 int i;
 for (i = 0; i < 8; i++) {
  if ((byte & 1) == 1) {
   outOne();
  } else {
   outZero();
  }
  byte = byte >> 1;
 }
}

void outOne() {
 digitalWrite(clock, LOW);
 delay(1);
 digitalWrite(data, HIGH);
 delay(1);
 digitalWrite(clock, HIGH);
 delay(1);
 digitalWrite(data, LOW);
 delay(1);
}

void outZero() {
 digitalWrite(clock, LOW);
 delay(1);
 digitalWrite(data, LOW);
 delay(1);
 digitalWrite(clock, HIGH);
 delay(1);
}

//===============sketch ends==========


--
McHUG - Physical Computing ;)
MicroController Ham User Group
-------------- next part --------------
Skipped content of type multipart/related


More information about the McHUG mailing list