Arduino VFO Using VK3ZYZ PCB

sadarc

Administrator
Staff member
I think I'll start a new thread, so as to not distract from Denys existing thread.

The main changes from Denys's version is I've moved to a different Si5351 library which is smaller and faster and claims less phase noise and no clicks.

https://laptrinhx.com/arduino-si5351-library-tuned-for-size-and-click-free-2958433958/

The zip file library is attached.

To drive the Si5351 is quite a bit more straight forward.

Si5351mcu clockgen; // declare the instance

clockgen.init(25000000); // Si5351 Crystal is 25 Mhz
clockgen.correction(1552); // Calibration
clockgen.enable(0); // enable clock 0 output
clockgen.setFreq(0,146000000); // 146 Mz Test

IMG_3647.JPG


That picture was cheating a bit, because 5 minutes later it had drifted down to 145.999973 Mhz

The library claims to be click free which is better than the one in the uBitX.

As far as size goes the object code is 7K smaller than the previous one. With the OLED library and Denys's code its 19,128 bytes vs 26,284 bytes
That might be enough to fit the code for an OLED S meter? that's on the nano.

I'll post the sketch a bit later after I do some more testing.
 

Attachments

V

VK3ZYZ

Guest
That sounds interesting!
I'm please you are able to help with the code. It is good to get more input to that and if the meter can fit in the memory space of the nano that will be a bonus.
 
V

VK3YNV

Guest
Did some work on the encoder software this afternoon. The mechanical encoders can produce noisy outputs with lots of contact bounce, this routine ignores the contact bounces and provides clean signals for clockwise or counter clockwise rotation.

Code:
//******************************
//  Adapted from https://www.best-microcontroller-projects.com/rotary-encoder.html
//
// Robust Rotary encoder reading
//
// Copyright John Main - best-microcontroller-projects.com
// Adapted for the VFO project VK3YNV
//

#define ENCODER_A A0
#define ENCODER_B A1

void setup() {
  pinMode(ENCODER_A, INPUT);
  pinMode(ENCODER_A, INPUT_PULLUP);
  pinMode(ENCODER_B, INPUT);
  pinMode(ENCODER_B, INPUT_PULLUP);
  Serial.begin (9600);
}


static uint8_t prevNextCode = 0;
static uint16_t store=0;

void loop() {
static int8_t c,val;
   val=read_encoder();
   if( val!=0) {
      if (val==1)   { Serial.println("CW"); }
      if (val==-1)  { Serial.println("CCW"); }
   }
}

// A vald CW or  CCW move returns 1, invalid returns 0.

int8_t read_encoder() {
static int8_t rot_enc_table[] = {0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0};

  prevNextCode <<= 2;
  if (digitalRead(ENCODER_A)) prevNextCode |= 0x02;
  if (digitalRead(ENCODER_B)) prevNextCode |= 0x01;
  prevNextCode &= 0x0f;

   // If valid then store as 16 bit data.
   if  (rot_enc_table[prevNextCode] ) {
      store <<= 4;
      store |= prevNextCode;
      if ((store&0xff)==0x2b) return -1;   // CCW
      if ((store&0xff)==0x17) return 1;    // CW
   }
   return 0;   // on detent or invalid bounce.
}
The secret to handling the debounce is the encoder phase table. I've been testing it and so far it seems rock solid.
 

Attachments

Last edited by a moderator:
V

VK3YNV

Guest
Still working through the code, but I thought I'd test the receiver. No modifications to the FM828, just poked a bit of coax into the crystal socket and it works just fine.

IMG_3648.JPG
IMG_3649.JPG

IMG_3650.JPG


Still wondering what the best way of integrating into the system.

Next job to come up is the display software. I need to think about supporting LCD as well as OLED and maybe TFT.

Also Ive added .ino as an acceptable file type for forum attachments.
 
V

VK3ZYZ

Guest
Have you thought of switching to 3.3V and replacing the Nano with a Nulceo board, Ray?
If I remember correctly, that encoder code is what is used on the Codan and Hawk versions.
And the Codan code has a #define to select LCD or OLED display. I'll have a look tomorrow.
That is in some of the code I've developed, just cannot remember what one it is in.
The next job is to test the displays and ESP32 boards for the fancy dial and lay out the PCB.
 
V

VK3YNV

Guest
Nucleo would be a nice option, but I've got the nano's and they work just fine. The encoder routine I posted doesn't need the delays for debounce, there is a very good write up on how it works in the link. Also it's very clean and compact.

I notice the frequency of the Si5351 drifts quite a bit. More than I would have thought. Maybe I got a bad one.
 
V

VK3YNV

Guest
The cabling inside the FM828 uses RG178 tiny coax 1.8mm diameter for the routing of RF signals around various places.
I found the following on ebay.

https://www.ebay.com.au/itm/5Pcs-RG...e=STRK:MEBIDX:IT&_trksid=p2060353.m2749.l2649


s-l1600.jpg


You get 5 cables with SMA connectors both ends 300 mm long, so if you cut them in half you get two 150mm RG178 cables with SMA connectors already terminated that will screw directly to the VFO board. So that's about $2.20 each cable.
 
V

VK3ZYZ

Guest
I must get some too. The version I have uses the thicker coax (RG316???? ) and that thin stuff will be a lot better.
 
Top