NOTICE: This software may not work, may cause injury, loss life, fame and fortune and sanity. Use at own risk. The author and ISP have no liability for any misfortune as a result of using this software. Etc. /* copied from blink.ino on public domain and modified 2 Jan 2013 vo1na to program AD9850 DDS chip. scans the 12 5 MHz channels (USB and CW) by pushbuttons o/p from board is 100mv p/p with dc offset. fed to ch150 xtal board via 0.01 uF which loaded level down to 15 mv p/p Tried the lcd09395. Works fine. plug in V+, gnd and rxd on lcd to pin 1 (tx) on uno Moved serial pin2 to 7 as 2 is used elswhere for lcd data. dds board pin1 is gnd, 1 vcc, right to left osc, on rhs. a=arduino pin. eg a3=arduino pin3. ad9580 board pins on top. 1 vcc; 2 a5; 3 a4; 4 a3; 5,6 gnd; 7,8,9 nc, 10 output channel up switch gnd and a7 , channel down switch gnd a ***This version uses the seial LCD libraries and pin 2 for the serial data to the LCD instead of pin 1. */ #include #include int SER = 2; // data out to LCD int FQ_UD = 4; // DTR (Formerly) int W_CLK = 5; // moved to accommodate 7 SEG LED int DATA = 3; // TXD int CHNL = 7; // Channel select pin 2->7 19 jan 12 int CHNU =6; // Channel down; 16 Jan 2013 int LED_A =13; // Used by 7 set led display int LED_B =12; int LED_C =11; int LED_D =10; int i; int channel=0,fq_select; // one of 12 freqs, channel switch state int fqd_select; // frequency down char freqc[7], chanc[3]; // formatted srings for freq and channel float freqf; // for formatting unsigned long int n; double clk=(125000000.0/125000890.0)*125000000.0 * (7078.093/7078); double ratio; //=f*pow(2,32)/clk; //for uno, no 64 bit... "exactly the same as float, with no gain in precision" float fqc[6]={5329, 5332, 5348, 5358.5, 5373, 5405}; float fqi[12]; // injection freq, offset 1749.5 kHz serLCD lcd(SER); // needed for lcd.print() SoftwareSerial mySerial(3,2); // void setup() { // the setup routine runs once when you press reset: // initialise the digital pin as an output. mySerial.begin(9600); pinMode(DATA, OUTPUT); pinMode(W_CLK, OUTPUT); pinMode(FQ_UD, OUTPUT); //pinMode(CHNL, INPUT); pinMode(CHNL, INPUT_PULLUP); // simplify cky by removing 5k1 pinMode(CHNU, INPUT_PULLUP); // L=up freq CHNU = down freq. pinMode(LED_A, OUTPUT); // now can leave input floating pinMode(LED_B, OUTPUT); // without needing a pull up resistor pinMode(LED_C, OUTPUT); pinMode(LED_D, OUTPUT); Serial.begin(9600); // to check variables with serial monitor put_PULSE(FQ_UD); // 3 lines to ...(Reset address to W0) put_PULSE(W_CLK); // enable serial mode... put_PULSE(FQ_UD); // without having to hard wire chip. for (i=0; i<=5; i++){ // add injection offsets, SSB offsets fqi[i]=(fqc[i]+1750.0-1.0)*1000; // to channels 7-12 //fqc+1749 gives tx cw carrier on fqc RX 1 kHz one on CH150. // CH150 sends CW with a 1 kHz square wave. // the USB are centred 1.5 kHz below so need to take off 500 Hz. // changed 1849.5 to 1849.0 7 Jan 2013 fqi[i+6]=fqi[i]-500; } set_CHIP(fqi[0]); // put 'er on 5329 kHz to get started } void set_DATA(int data_bit) { digitalWrite(DATA, data_bit); } void put_PULSE(int pin) { digitalWrite(pin,HIGH); delay(1); digitalWrite(pin,LOW); } void set_CHIP(double f) { ratio=f*pow(2,32)/clk; // double precision n=ratio; for (i=0; i<=31; i++){ set_DATA(n%2); //modulus n%2 put_PULSE(W_CLK); n=n/2; } set_DATA(0); for (i=32; i<=39; i++){ put_PULSE(W_CLK); } put_PULSE(FQ_UD); } void loop(){ while ((fq_select=digitalRead(CHNL)==1) && (fqd_select=digitalRead(CHNU)==1)){ delay(20); } if (fq_select==0) channel=channel++; if (fqd_select==0) channel--; if (channel>11){ channel=0; } if (channel<0) channel=11; set_CHIP(fqi[channel]); lcd.print(" "); // comes out of pin2 lcd.print(" "); // no rubbish sprintf(chanc,"%2.2d",channel+1); lcd.print("VX9MRC 60 Metres"); led_DISPn(channel+1); freqf=(fqi[channel]-1749000)/1e3; dtostrf(freqf,6,1,freqc); // write frequency to formatted string lcd.print(freqc); if (channel<=5){ lcd.print(" kHz CW "); lcd.print(channel+1); } else{ lcd.print(" kHz USB "); lcd.print(channel-5); } delay(500); }