#include /* Version 2.2 to use lower LO injection for higher RF output at upper frequencies Sep 6 2017 * This version uses same BFO frequency for USB and LSB * fine tune seperately for frequency accuracy for below 14 Mhz and 14 Mhz and above * transmit controller program for th WA3TFS 11212016 COMPANION SSB TRANSMITTER * modified Dec 2016 to add functions to control second dds for BFO * modified april 2 2015 by WA3TFS to convert arduino to launchpad * DDS frequency set up and control program using launchpad and 430G2553 * If using ver 1.4 or below board, jumper RXD and TXD diagonally * WA3TFS Added serial function to load frequency and control of 5 low pass filters */ #define W_CLK 7 // Pin 7 - connect to AD9850 module word load clock pin (CLK) #define FQ_UD 10 // Pin 10 - connect to freq update pin (FQ_UD) #define DATA 9 // Pin 9 - connect to serial data load pin (DATA) #define RESET 8 // Pin 8 - connect to reset pin (RST). #define pulseHigh(pin) {digitalWrite(pin, HIGH); digitalWrite(pin, LOW); } #define ONESXTY 6 // select 160 meter band filter PIN 6 #define EIGHTY 5 // select 80 meter band filter PIN 5 #define FORTY 11 //select 40 meter band filter PIN 11 #define TWENTY 15 //select 20 meter and above filter PIN 15 #define FIFTEEN 18 //SELECT 15 meter and above filter PIN 18 #define TOP 19 //SELECT 10 METER LPF PIN 19 #define B_CLK 12 //clock BFO DDS PIN 12 #define BQ_UD 13 //load BFO DDS PIN 13 #define BATA 14 //BFO frequency PIN 14 #define BESET 2 //BFO reset PIN 2 long bfo; long frequency; long val; long val2; long val3; long val4; long bfreq; // transfers a byte, a bit at a time, LSB first to the 9850 via serial DATA line void tfr_bfobyte(byte data) { for (int f=0; f<8; f++, data>>=1) { digitalWrite(BATA, data & 0x01); pulseHigh(B_CLK); //after each bit sent, CLK is pulsed high } } // 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 = * /2^32 void sendFrequency(double frequency) { int32_t freq = frequency * 34.35973836; // 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 } // frequency calc from datasheet page 8 = * /2^32 void sendBfo(double bfo) { int32_t bfreq = bfo * 34.35973836; // note 125 MHz clock on 9850V for (int e=0; e<4; e++, bfreq>>=8) { tfr_bfobyte(bfreq & 0xFF); } tfr_bfobyte(0x000); // Final control byte, all 0 for 9850 chip pulseHigh(BQ_UD); // Done! Should see BFO output } //added this code to talk serially void setup() { Serial.begin(9600); // configure launchpad data pins for output pinMode(FQ_UD, OUTPUT); pinMode(W_CLK, OUTPUT); pinMode(DATA, OUTPUT); pinMode(RESET, OUTPUT); pinMode(ONESXTY, OUTPUT); pinMode(EIGHTY, OUTPUT); pinMode(FORTY, OUTPUT); pinMode(TWENTY, OUTPUT); pinMode(FIFTEEN, OUTPUT); pinMode(TOP, OUTPUT); pinMode(B_CLK, OUTPUT); pinMode(BQ_UD, OUTPUT); pinMode(BATA, OUTPUT); pinMode(BESET, OUTPUT); digitalWrite(ONESXTY, LOW); //SET UP INITIAL STATE OF CONTROL PINS digitalWrite(EIGHTY, LOW); digitalWrite(FORTY, LOW); digitalWrite(TWENTY, LOW); digitalWrite(TOP, LOW); digitalWrite(FIFTEEN, LOW); //ON START UP ACTIVATE NO FILTER pulseHigh(RESET); //main dds reset pulseHigh(W_CLK); //main dds clock pulseHigh(FQ_UD); // this pulse enables updates main dds pulseHigh(BESET); //bfo dds reset pulseHigh(B_CLK); //bfo dds clock pulseHigh(BQ_UD); // this pulse updates bfo dds } //added this below to input required frequencies and offsets //this also selects the proper low pass filter and BFO for the frequencies programmed void loop() { if (Serial.available()) { frequency = Serial.parseInt(); if (frequency<1000) goto loop1; if (frequency>1500000 && frequency<2100000) { digitalWrite(ONESXTY, HIGH); //IF TRUE TURN ON THIS FILTER Serial.println("transmit accepted"); } else { digitalWrite(ONESXTY, LOW); //TURN OFF OTHER LOW PASS FILTERS } if (frequency>2100001 && frequency<4000000) { digitalWrite(EIGHTY, HIGH); //IF TRUE TURN ON THIS FILTER Serial.println("transmit accepted"); } else { digitalWrite(EIGHTY, LOW); //TURN OFF OTHER LOW PASS FILTERS } if (frequency>4000001 && frequency<7400000) { digitalWrite(FORTY, HIGH); //IF TRUE TURN ON THIS FILTER Serial.println("transmit accepted"); } else { digitalWrite(FORTY, LOW); //TURN OFF OTHER LOW PASS FILTERS } if (frequency>7400001 && frequency<14500000) { digitalWrite(TWENTY, HIGH); //IF TRUE TURN ON THIS FILTER Serial.println("transmit accepted"); } else { digitalWrite(TWENTY, LOW); //TURN OFF OTHER LOW PASS FILTERS } if (frequency>14400001 && frequency<28000000) { digitalWrite(FIFTEEN, HIGH); //IF TRUE TURN ON THIS FILTER Serial.println("transmit accepted"); } else { digitalWrite(FIFTEEN, LOW); //TURN OFF OTHER LOW PASS FILTERS } if (frequency>28000001 && frequency<35000000) { digitalWrite(TOP, HIGH); //IF TRUE TURN ON THIS FILTER Serial.println("transmit accepted"); } else { digitalWrite(TOP, LOW); //TURN OFF OTHER LOW PASS FILTERS } if (frequency<(7400000)) { bfo = (8996900); //LSB bfo injection frequency 8996600 frequency = (frequency + 10); //add or subtranct to set exact transmit freq 250 } else { bfo = (9000250); //test bfo offset replace next line //bfo = (9000000); //USB bfo injection frequency frequency = (frequency - 100); //add or subtract to set exact transmit freq (40) } if (frequency<(13999000))//changed to get lo lower { frequency = (frequency + bfo);// create local oscillator injection offset (350) from bfo to correct transmit frequency } else { frequency = (frequency + bfo);// set higher frequency injection offset for higher RF output at upper frequencies (15,14,12 and 10 meters) } bfo = bfo; sendFrequency(frequency); // send LO frequency to DDS ctrl.Offset 175 corrects frequency //Serial.print(frequency); //print actual value to monitor to debug offset not displayed //Serial.print(bfo); //print actual value to monitor to debug sendBfo(bfo); // send BFO frequency to DDS ctrl. loop1:; } }