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&gt;
#include <Wire.h&gt; 
#include <LiquidCrystal_I2C.h&gt;
#include <Rotary.h&gt;

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 &gt; 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 &gt; 7300000){
      Freq = 7300000;  
    }
   
  }
  else if (result == DIR_CCW) {
    Serial.println("CounterClockWise");
    Freq = Freq + TurnNum;
    if (Freq &gt; 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

Advertisements

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close