Skip to content

Month: December 2016

bitx: star wars lunch box

The bitx module now has its own enclosure: A star wars lunch box!

 

I didn’t change much about my original setup. I ditched the s meter and added a manual usb/lsb switch to the front panel.

The red knob is the power/volume pot. There is a headphone jack under the switch and the rotary encoder on the right.

On the rear panel, I added the antenna jack, a dc jack that supplies the 12 volts to power the module, and an optional set of binding posts to supply up to 25 volts for the power amplifier. The switch changes the supply to the power amp on the bitx board. I wont be using the higher power until I can add a larger heat sink to the IRF510 and possibly a fan. I did a quick test on the output using both settings and the default 12 volts puts out about 5 watts and with 25 volts, I measured about 25 watts.

Inside the lunch box, you can see the bitx module on the left and the vfo board on the right. The vfo is an SI5351 board with an arduino pro mini. The board also contains a LPF for the SI5351 output and a 5v regulator.

The blue tape on the right side is holding the mic preamp board, from one of my previous bitx posts.

So far, everything is working as it should. I still need to add a fuse to the power input, a mic jack for using an external input, and I will probably tweak the arduino code a little more. For now, I will leave the current arduino code below. Most of the code below is based on code from Jason Mildrum, NT7S, Przemek Sadowski, SQ9NJE, and Tom Hall, AK2B.

#include <Rotary.h>
#include <si5351.h>
#include <Wire.h>
#include <LiquidCrystal.h>

#define F_MIN        100000000UL               
#define F_MAX        5000000000UL

#define ENCODER_A    2                      
#define ENCODER_B    3                      
#define ENCODER_BTN  11
#define LCD_RS		5
#define LCD_E		  6
#define LCD_D4		7
#define LCD_D5		8
#define LCD_D6		9
#define LCD_D7		10

#define SWITCH_PIN 12
int switchstate = 0; 

LiquidCrystal lcd(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7);       // LCD - pin assignement in
Si5351 si5351;
Rotary r = Rotary(ENCODER_A, ENCODER_B);
volatile int32_t LSB = -1199950000ULL;
volatile int32_t USB = -1200150000ULL;
volatile int32_t bfo = -1199950000ULL; //start in lsb
//These USB/LSB frequencies are added to or subtracted from the vfo frequency in the "Loop()"
volatile int32_t vfo = 710000000ULL / SI5351_FREQ_MULT; //start freq - change to suit
volatile uint32_t radix = 100;	//start step size - change to suit
boolean changed_f = 0;
String tbfo = "";


/**************************************/
/* Interrupt service routine for      */
/* encoder frequency change           */
/**************************************/
ISR(PCINT2_vect) {
  unsigned char result = r.process();
  if (result == DIR_CW)
    set_frequency(1);
  else if (result == DIR_CCW)
    set_frequency(-1);
}

/**************************************/
/* Change the frequency               */
/* dir = 1    Increment               */
/* dir = -1   Decrement               */
/**************************************/
void set_frequency(short dir)
{
  if (dir == 1)
    vfo += radix;
  if (dir == -1)
    vfo -= radix;

  changed_f = 1;
}

/**************************************/
/* Read the button with debouncing    */
/**************************************/
boolean get_button()
{
  if (!digitalRead(ENCODER_BTN))
  {
    delay(20);
    if (!digitalRead(ENCODER_BTN))
    {
      while (!digitalRead(ENCODER_BTN));
      return 1;
    }
  }
  return 0;
}

/**************************************/
/* Displays the frequency             */
/**************************************/
void display_frequency()
{
  uint16_t f, g;

  lcd.setCursor(3, 0);
  f = vfo / 1000000; 	//variable is now vfo instead of 'frequency'
  if (f < 10)
    lcd.print(' ');
  lcd.print(f);
  lcd.print('.');
  f = (vfo % 1000000) / 1000;
  if (f < 100)
    lcd.print('0');
  if (f < 10)
    lcd.print('0');
  lcd.print(f);
  lcd.print('.');
  f = vfo % 1000;
  if (f < 100)
    lcd.print('0');
  if (f < 10)
    lcd.print('0');
  lcd.print(f);
  lcd.print("Hz");
  lcd.setCursor(0, 1);
  lcd.print(tbfo);


}

/**************************************/
/* Displays the frequency change step */
/**************************************/
void display_radix()
{
  lcd.setCursor(9, 1);
  switch (radix)
  {
    case 1:
      lcd.print("    1");
      break;
    case 10:
      lcd.print("   10");
      break;
    case 100:
      lcd.print("  100");
      break;
    case 1000:
      lcd.print("   1k");
      break;
    case 10000:
      lcd.print("  10k");
      break;
    case 100000:
      //lcd.setCursor(10, 1);
      lcd.print(" 100k");
      break;
  }
  lcd.print("Hz");
}


void setup()
{


  pinMode(SWITCH_PIN, INPUT_PULLUP);
  
  Serial.begin(19200);
  lcd.begin(16, 2);                                                    
  lcd.clear();
  Wire.begin();

  si5351.set_correction(140); //**mine. There is a calibration sketch in File/Examples/si5351Arduino-Jason
  //where you can determine the correction by using the serial monitor.

  //initialize the Si5351
  si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0); //If you're using a 27Mhz crystal, put in 27000000 instead of 0
  // 0 is the default crystal frequency of 25Mhz.

  si5351.set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
  // Set CLK0 to output the starting "vfo" frequency as set above by vfo = ?

  //Serial.println((long)((vfo * SI5351_FREQ_MULT) + bfo) * -1);
  si5351.set_freq(((vfo * SI5351_FREQ_MULT) + bfo) * -1, SI5351_PLL_FIXED, SI5351_CLK0);
  volatile uint32_t vfoT = abs((vfo * SI5351_FREQ_MULT) + bfo);
  tbfo = "USB";
  // Set CLK2 to output bfo frequency
  si5351.set_freq( bfo, 0, SI5351_CLK2);
  //si5351.drive_strength(SI5351_CLK0,SI5351_DRIVE_2MA); //you can set this to 2MA, 4MA, 6MA or 8MA
  //si5351.drive_strength(SI5351_CLK1,SI5351_DRIVE_2MA); //be careful though - measure into 50ohms
  //si5351.drive_strength(SI5351_CLK2,SI5351_DRIVE_2MA); //

  Splash();

  pinMode(ENCODER_BTN, INPUT_PULLUP);
  PCICR |= (1 << PCIE2);           // Enable pin change interrupt for the encoder
  PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
  sei();
  display_frequency();  // Update the display
  display_radix();
}


void loop()
{
  
  // Update the display if the frequency has been changed
  if (changed_f)
  {
    display_frequency();


    //Serial.println((long)((vfo * SI5351_FREQ_MULT) + bfo) * -1);
    si5351.set_freq(((vfo * SI5351_FREQ_MULT) + bfo) * -1, SI5351_PLL_FIXED, SI5351_CLK0);
    //you can also subtract the bfo to suit your needs
    //si5351.set_freq((vfo * SI5351_FREQ_MULT) - bfo  , SI5351_PLL_FIXED, SI5351_CLK0);

    switchstate = digitalRead(SWITCH_PIN);
    if (switchstate == HIGH) {
      //USB
      bfo = USB;
      tbfo = "USB";
      si5351.set_freq( bfo, 0, SI5351_CLK2);
      Serial.println("We've switched from LSB to USB");
    } else {
      // LSB
      bfo = LSB;
      tbfo = "LSB";
      si5351.set_freq( bfo, 0, SI5351_CLK2);
      Serial.println("We've switched from USB to LSB");
    
    }

    changed_f = 0;
  }

  // Button press changes the frequency change step for 1 Hz steps
  if (get_button())
  {
    switch (radix)
    {
      case 1:
        radix = 10;
        break;
      case 10:
        radix = 100;
        break;
      case 100:
        radix = 1000;
        break;
      case 1000:
        radix = 10000;
        break;
      case 10000:
        radix = 100000;
        break;
      case 100000:
        radix = 1;
        break;
    }
    display_radix();
  }

  lcd.setCursor(0, 1);
  lcd.print(tbfo);
}

void Splash()
{

  lcd.setCursor(0, 0);
  lcd.print("BITX 40M XCVR");
  //lcd.setCursor(3, 1);
  //lcd.print("40M XCVR");
  delay(4000);
  lcd.clear();
}

 

 

4 Comments