_455BFO_v_1_3 /* *BFO for the KG7TR homebrew 75S-2B receiver. The receiver has been *implemented as a 3.5 to 4.0 MHz (80 Meter) front end using a vacuum tube VFO and a *455kHz IF. * *A crystal controlled oscillator is used to heterodyne the 40, 20 15 and 10 meter bands *down to the 3.5 to 4.0 MHz front end. * *A Collins mechanical filter with 2.1 KHz bandwidth is used for SSB. * *An Si5351 module from QRPLabs provides BFO to the product detector. * *A simple three position rotary switch grounds one of two digital pins in the Arduino module *to provide SSB injection frequencies specified by Collins as follows: *Pin 12 LOW = true USB = .453650 MHz *Pin 11 LOW = true LSB = .456300 MHz *For AM both pin 11 and pin 12 are HIGH and the BFO module output is inhibited. * *The ceramic AM filter has a measured center frequency of .453900 MHz. * *The sketch reads the stable pin state and uses the si5351 set_freq function from the *si5351.h library to program the correct output frequency. The sketch will leave *the module alone until a pin state changes (i.e., no continuous updates everytime through the loop, *as this causes glitches). * *On 80 meters the radio is single conversion, which causes a sideband *reversal. 80 meters is sensed from the band switch on digital pin 2 and used to reverse *the BFO frequencies. */ #include "si5351.h" #include "Wire.h" Si5351 si5351; //Define functions (methods) to set frequencies. void setLSB(){si5351.set_freq(45635000ULL, SI5351_CLK0); si5351.output_enable(SI5351_CLK0,1);} void setUSB(){si5351.set_freq(45365000ULL, SI5351_CLK0); si5351.output_enable(SI5351_CLK0,1);} void setAM(){si5351.output_enable(SI5351_CLK0,0);}//Disable output for AM int preValueLSB = HIGH; int preValueUSB = HIGH; int preValue80M = HIGH; boolean Update = true; //Update if mode or bandswitch position is changed. void setup() { si5351.init(SI5351_CRYSTAL_LOAD_10PF, 27000000, 120000); //si5351.set_freq(1000000000ULL, SI5351_CLK0); //Use for a functional check at 10 MHz. pinMode(12,INPUT_PULLUP); //pin D12 also connected to counter module pin A0 pinMode(11,INPUT_PULLUP); //pin D11 also connected to counter module pin A1 pinMode(2,INPUT_PULLUP); //pin D2 also connected to counter module pin D0 for 80M status } void loop() { int ValueLSB = digitalRead(11); int ValueUSB = digitalRead(12); int Value80M = digitalRead(2); //Test whether mode or band switch has changed postion. if (ValueLSB != preValueLSB) {Update = true; preValueLSB = ValueLSB;}; if (ValueUSB != preValueUSB) {Update = true; preValueUSB = ValueUSB;}; if (Value80M != preValue80M) {Update = true; preValue80M = Value80M;}; //Turn off BFO for AM mode if (ValueLSB == HIGH && ValueUSB == HIGH) {setAM();}; //Set BFO freq for 40M thru 10M if (Update == true && Value80M == HIGH) {if (ValueLSB == LOW) {setLSB();}; if(ValueUSB == LOW) {setUSB();};}; //Set BFO freq for 80M, sidebands reversed due to single conversion if (Update == true && Value80M == LOW) {if (ValueLSB == LOW) {setUSB();}; if (ValueUSB == LOW) {setLSB();};}; delay(100); Update = false; //set to false after updates have been implemented to bypass another trip thru the loop }