VFO for the Pixie. Wiring and Sketch for the AD9850.

The AD9850 Signal Generator Module will produce the Sine Wave for the VFO. This module is well documented and easy to connect to the arduino. The Library used for this project can be downloaded from https://github.com/F4GOJ/AD9850.

AD9850 Signal Generator Module.
Advertisements
Advertisements

The Ver. 1 sketch for the Pixie VFO is very basic. Turning the rotary encoder will increase or decrease the frequency. If you push the rotary encoder button, the step rate of the VFO increases. In future versions an indicator of the step rate will be added.

/*
    Pixie VFO Ver1
    Rotary Encoder - download library 
    https://github.com/mathertel/RotaryEncoder    
    AD9850 - download Library https://github.com/F4GOJ/AD9850
    I2C LCD - download library http://www.ardumotive.com/i2clcden.html
    https://KM4NMP.com
*/

#include <AD9850.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Rotary.h>

const int RotaryButtonPin = A1;
const int PTTPin = A0;
const int W_CLK_PIN = 8;
const int FQ_UD_PIN = 9;
const int DATA_PIN = 10;
const int RESET_PIN = 11;

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
Rotary r = Rotary(2, 3);
int RotaryButtonState = 0;
int PTTPinState = 0;
long TurnNum = 100;
long Freq = 7000000;
double OldFreq = 7000000;
double trimFreq = 125000000;

int phase = 0;

void setup() {
  Serial.begin(9600);
  pinMode(RotaryButtonPin, INPUT);
  pinMode(PTTPin, INPUT);
  DDS.begin(W_CLK_PIN, FQ_UD_PIN, DATA_PIN, RESET_PIN);
  DDS.calibrate(trimFreq);
  lcd.begin(16,2);
  r.begin();
  PCICR |= (1 << PCIE2);
  PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
  sei();

  lcd.setCursor( 3, 0 );                   
  lcd.print("KM4NMP.com");  
  DDS.setfreq(Freq, phase);
  delay(2000);
   
}

Advertisements
void loop() {
  PTTPinState = digitalRead(PTTPin);
  
  RotaryButtonState = digitalRead(RotaryButtonPin);
  if (RotaryButtonState == LOW) {
     TurnNum = TurnNum * 10;
     }
  if (TurnNum > 10000) {
    TurnNum = 1;   
  }
  if (TurnNum < 1) {
    TurnNum = 10000;
  }
  if (OldFreq != Freq) {
     DDS.setfreq(Freq, phase);
     Serial.println( Freq );
  }  
  lcd.setCursor( 4, 1 );                   
  lcd.print( Freq ); 
  OldFreq = Freq;
  delay(200);
}

ISR(PCINT2_vect) {
  unsigned char result = r.process();
  if (result == DIR_NONE) {
    // do nothing
  }
  else if (result == DIR_CW) {
    Serial.println("ClockWise");
    Freq = Freq - TurnNum;
    if (Freq < 7000000){
      Freq = 7000000;
    }
    if (Freq > 7300000){
      Freq = 7300000;  
    }
   
  }
  else if (result == DIR_CCW) {
    Serial.println("CounterClockWise");
    Freq = Freq + TurnNum;
    if (Freq > 7300000){
      Freq = 7300000;
    }
    if (Freq < 7000000){
      Freq = 7000000;  
    }
  }
}
Advertisements

Links

https://km4nmp.com/2019/08/21/starting-the-vfo-for-the-pixie-lcd-screen-and-rotary-encoder/

https://km4nmp.com/2019/08/11/preparing-to-modify-the-40m-pixie/

http://www.mathertel.de/Arduino/RotaryEncoderLibrary.aspx

https://km4nmp.com/2019/08/03/assembling-the-40m-pixie/

https://www.ardumotive.com/i2clcden.html

Advertisements

Latest Posts

1 thought on “VFO for the Pixie. Wiring and Sketch for the AD9850.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

search previous next tag category expand menu location phone mail time cart zoom edit close