January 2017, summer holiday season down-under, afforded time to build something I’ve been wanting to build for several years, my first Digital VFO. I’ve built a kit Digital VFO with pre-soldered surface mount parts and burned-in firmware, but this was to be a scratch build with Arduino Nano, C code with modifications, and a Silicon Labs si5351 PLL clock generator on a breakout board. I used the wiring map and script from Tom AK2B (modified from one by SQ9NJE ) and uses Jason NT7S si5351 library. The script is simple, supporting a single push-button to cycle frequency increments, and dealing with encoder interrupts, contact debouncing, refreshing the LCD display, IF offset and VFO/BFO outputs. Jason’s si5351 library hides the gutsy device interfacing, giving you a handful of common-sense functions to call… for example, set_frequency() takes as its argument the frequency in centi-hertz (1/100th of a hertz) and the ‘clock 0/1/2’ flag. It couldn’t be simpler. The Adafruit board contains the si5351 and a 25MHz clock (from local IoT supplier Core Electronics). Here’s a video demonstration of the VFO’s features.
Tom’s script didn’t compile first time, as Jason’s library had changed since Tom posted his script. Jason had removed one parameter from the init() and set_frequency() methods to simplify things. In Tom’s script I removed the arguments (which were ‘0’ anyway). This was a remarkably simple build experience! The key is the si5351… three clocks, 1-160MHz, all software controlled, in a tiny 10 pin MSOP package, and all for a few dollars.
One thing’s for sure, it will be hard going back to quartz. [Postscript 12/2018: Quartz crystals are still favoured for good clean BFOs; but I can’t see any reason other than nostalgia for building a free-running VFO these days].
With the wide range of Arduino breakouts, all sorts of control and monitoring behaviours now become possible — GPS, SWR, power and temperature monitoring for power amplifier stages or linears, sequencing, switching, wifi, bluetooth, packet data links, to name a few.
Once you have control of the VFO and BFO in software, controlling other things in a transceiver like band, memories or multiple VFOs, IF filter switching is all just a matter of a few more lines of code. I came up with the following additional controls:
- Step cycle (10, 100, 1k, 10kHz steps)
- VFO cycle (A, B or C)
- Band up/down (LF, MW, 160, 80, 60, 40, 30, 20, 17, 15, 12, 10)
- Mode cycle (SSB, AM, CW)
- Rx/Mute status (Rx, Tx)
Controlling mode and band switching relays
If you decide to implement control of mode and band switching in your homebrew radio’s Arduino controller, a mechanism is needed to pass binary or BCD values representing the active mode and band selections through to the individual control lines that energise the relays for each. The traditional way of doing this is to get the controller to output a BCD 3 or 4-bit nibble on its pins, and use a CMOS/TTL 1-of-8 (74LS138) or 1-of 16 (74LS154) decoder, with an inverting transistor relay driver stage which does the actual switching. You can buy the CMOS version of the venerable 74LS154 1-of-16 IC in surface mount on an Arduino style break-out board to minimise space.
A more contemporary way of achieving the same thing is to use a 1-of-16 decoder driven by I2C. Something like this break-out expander. Or this IO expander. This is preferable because you don’t need to tie up lots of your Nano pins to synthesise a BCD nibble, instead, you pass the selected value to the expander/decoder device via I2C. I’ve not decided how to do this yet.
Supporting multiplexed pushbuttons
I came up with the need for pushbuttons to control the following features of a multiband radio:
- freq step (100Hx, 1kHz, 10kHz)
- VFO cycle (VFO A, VFO B, VFO C)
- band up (40, 30, 20 etc)
- band down (20, 30, 40 etc)
- mode cycle (SSB, CW, AM)
- mute (RX, TX).
The Hitachi LCD display does not support serial I2C. That means 4 Arduino digital outputs are necessary to convert 4 bit data values to the display, plus 2 control lines. That does not leave enough digital and analogue pins for all the pushbuttons or output lines.
A common way around this (without going to the added complexity of IO expander break-outs) is to multiplex a number of pushbuttons switching on a resistive voltage divider, on a single analog input. The script reads the pin and interprets a voltage range for each button. Here’s a circuit and tutorial. I built a rack of 6 momentary on switches (on a receiver front panel I prefer pushing down on a spring loaded switch over pushing in on a pushbutton). The values I got were quite predictable and narrow in range. In the mapping script I used wide number ranges to allow for DC supply variations or drift.
si5351 clock filtering
The si5351 clock outputs are square waves. There is some discussion in the forums about the harmonic content of the waveform and the need for low pass filtering. The answer is, it depends on what you are doing with the VFO signal. In the dual conversion multiband receiver I have in mind, all 3 mixers are SBL-1s. I asked the Yahoo QRP-TECH crowd what they thought of the need to low-pass filter a square wave when used to drive an SBL-1 Double Balanced Mixer. There wasn’t any consensus, but two themes emerged:
- square waves are rich in harmonics and these should be cleaned up, and
- a DBM is a switching device in which the diodes saturate when driven with correct oscillator signal level, so squareness of the waveform doesn’t matter much.
I decided that low pass filtering was desirable, and plan to add a 5 element Chebychev LPF and a broad-band 2N3904 amplifier stage on at least the VFO clock.
Arduino Nano pin plan
Here’s a plan for how I used the Nano’s IO pins (it assumes an HD7044 LCD and old-fashioned TTL band and mode decoding and switching):
D0 – NC
D1 – NC
D2 – rotary encoder up
D3 – rotary encoder down
D4 – // mode output (lsb) (TBC)
D5 – LCD Register Select
D6 – LCD Enable/Clock
D7 – LCD D4
D8 – LCD D5
D9 – LCD D6
D10 – LCD D7
D11 – // mode output (msb) (TBC)
D12 – // band output (lsb) (TBC)
D13 – // (internal LED) –
A0 – // Multiplexed buttons — VFO cycle, Step cycle, band up, band down, Mode cycle, mute)
A1 – // band output . (TBC)
A2 – // band output . (TBC)
A3 – // band output (msb) (TBC)
A4 – si5351 SDA
A5 – si5351 SCL
Experimenters are using Arduino analog inputs with simple external circuitry to implement the following meters in transceiver projects:
- Voltmeter: a volt meter is valuable for monitoring battery voltage and health from a portable QRP rig. A voltmeter is one of the easiest additions — simply create a voltage divider with two resistors across the supply rail so that the peak supply voltage is a bit less than 5 volts (measures close to 1024 on the pin using AnalogRead()) and scale the resulting value in software.
- S-meter: a simple one transistor circuit can sample and rectify IF or audio signal and bring it into the 0-5 volt range for another analogue pin.
- RF-meter: sample and rectify the PA output via a tiny capacitor (a few pF); the Arduino can use the same display space for S-meter on receive and RF on transmit.
- SWR: a simple directional coupler can supply both forward and reflected indicative voltages, which can be displayed concurrently or alternately.
Useful notes on Arduino Nano
While researching the Nano I found the following useful facts:
- D0 and D1 are used in the serial interface between the Arduino and the PC. The same channel is used by the system’s serial monitor Serial:: which allows a script to trace to the attached screen or other serial device. Seems best to not use these pins.
- D13 controls an on-board LED through an appropriate resistor to ground. As the Nano boots, D13 is made an output (all the other i/o lines come out of a reset as inputs). And the system software, before it executes whatever you’ve put in setup(); will briefly take D13 high before returning it to low. For this reason this pin should be used for input only, to avoid relays clattering during the first seconds after power up.
- Arduino analogue I/Os can be used as digital ones. To set A0 as output and high you use:
August 2017: I made up a second Arduino Nano and si5351 VFO/BFO/Controller for another homebrew rig, with some improvements. The post describing the VFO is here. A video of the new rig (receiver only at this stage) is here.
March 2018: Have built four or five Arduino Nano/si5351 VFO/Controllers now. A post describing my latest Nano/si5351 controlled QRP rig is here.
September 2018: Here’s a post on a compact G6LBQ BiTx using an Arduino/si5351 VFO and BFO.
November 2018: Here’s the github repo with my code. It works on a HFSignals (VU2ESE) Raduino module. If you use it, remember to execute the Initialiser script once (to set up EEPROM). Further details in the readme and main file header.
December 2018: And another Arduino/si5351 compact VFO/BFO/Controller and CW Keyer, first stage of a compact multiband SSB/CW transceiver.