Band Sensing

VK3ZYZ

Moderator
To add the VFOs to an HF set, the band the set is running on needs to be sensed by the VFO.
One way is to use the usually supplies band swith in the set ans add series resistors across it.
Here is an example.
BandSense.jpg
In this case, 1K resistors are used. There is on from 0V to the first switch pin, then more 1K resistors between each pin, and finally the last one to the 5V supply.
The wiper is connected to the VFO analog input.
Now, the processor can read the voltage at each position. Note that the numbers will vary a little as this is not a precision reading, but it will work quite well.

On the VFO_Delux board the following readings are found.

1 = about 150.
2 = about 450.
3 = about 770.
4 = about 1115.
These numbers are the raw ADC (analog to digital converter) readings and vary about +/-5 .
So, bow we can use these numbers to select the band.
For instance, picking a point between the numbers, the code will do something like this...

if reading is greater than 1000, band = 4
else, if reading is greater than 700, band = 3.
else, if reading is greater than 400, band = 2
else band = 1.

More resisters will be needed for more ranges, but the switch I had is only 4 positions.

The code I am running is as below..

// VFO_Delux analog in test
#define Version "VFO_DeluxAinTest" // this is not needed but helps to keep track of what code you are running
#define AIn_1 36 // Analog in1
void setup() {
Serial.begin(115200); // set up the serial port
Serial.println(Version); // this is not needed but helps to keep track of what code you are running
}
void loop(){
Serial.println(analogRead(AIn_1)); // read the voltage and output it
delay(1000); // wait a second. then do it again.
}



This code will work on other Arduino boards too, just change the AIn_1 port pin to suit.


BandTestScreen.png
This is what it looks like on my Mac. The Arduino included a Serial Monitor tool and that is what we use here.
You may note that my code does not define the AIn_1 pin, and that is because there is a file that has all the pins defined.
 

BillC

Member
Good on you Denys that is very interesting, presumably with the correct switch and resistors it would be possible to set all the ham bands in the HF range and possibly a wide tuning band eg. 0-31 mHZ, hope so. Good luck.
 
Top