/* Shuttle Tuned PLL VFO for BITX40 Raduino Don Cantrell,ND6T v 1.0.1 2 September 2017 Compiles under Etherkit Si5351 library v 2.0.6 This source file is under General Public License version 3.0 Simplified sketch. No metering but with idle indicator. Straight key only */ #include Si5351 si5351; #include LiquidCrystal lcd(8,9,10,11,12,13); int tune; //Tuning knob position int offset=700; //CW offset float QSK=1.5; //Delay (in seconds)for semi-QSK long count = 0; //Timeout counter unsigned long post = 0;// Time post float BFO = 11.99855e6;//My I.F. frequency float LO = BFO -7.2e6; //Local Oscillator frequency minus starting frequency void setup() { lcd.begin(16, 2); si5351.init(SI5351_CRYSTAL_LOAD_8PF,24999020L,0); //My actual ref osc freq. si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA); si5351.set_freq(LO * 100, SI5351_CLK2); //Program the synthesizer pinMode(5, INPUT_PULLUP); // Key input on Plug 3 pin 3 pinMode(6, OUTPUT); //Sidetone from Plug 3 pin 2 pinMode(7, OUTPUT); // T/R keying for CW Plug 3 pin 1 lcd.setCursor(0,0); ///////////Splash///////////// lcd.print("simpleSTsk"); lcd.setCursor(0,1); lcd.print("ver. 1.0.1"); delay(2000); post=millis(); //Set starting time post } void loop() { if(digitalRead(5)==LOW) CW();//If the key is pressed go to CW mode digitalWrite(7, LOW); // Restore T/R relays from CW mode tune = analogRead(A7);// Read the input on analog pin 7: if (tune>560)up(); //Establish tuning direction if (tune<464)down(); //and idle zone if(millis()-post<50) show(); //Display the frequency } //****Functions**** void show() { //Display lcd.clear(); lcd.setCursor(0, 0); lcd.print ((BFO-LO)/1e3,3);//Calculate & show frequency if(tune>560)lcd.print(" >");//Tuning direction indicators if(tune<464)lcd.print(" <"); if(tune>464 && tune<560) lcd.print(" I"); //Idle indicator lcd.print(" KHz"); } void down() { LO = LO + (pow((464 - tune)/5,3)/100); //Increase local osc frequency (decreases T/R freq) si5351.set_freq(LO * 100, SI5351_CLK2);//Program the synthesizer delay(300); //To ease tuning post=millis();//Display } void up() { LO = LO - (pow((tune - 560)/5,3)/100); //Decrease local osc frequency (increases T/R freq) si5351.set_freq(LO * 100, SI5351_CLK2);//Program the synthesizer delay(300); //To ease tuning post=millis();//Display } void CW() { //CW mode, Straight Key only digitalWrite(7,HIGH); // Key T/R relays and do the setup while they activate while (count < (QSK*1300)){ // Delay time after last action to return to normal SSB while(digitalRead(5)==LOW){ //Key down si5351.set_freq(((BFO-LO)-offset) * 100 , SI5351_CLK1); tone(6,offset); //Sidetone count=0; //Reset counter } si5351.output_enable(SI5351_CLK1, 0); // Unkey transmit noTone(6); count++; } count=0; //Reset counter }