Introduction: HF Antenna Analyser With Arduino and DDS Module


In this Instructable I'll show you how I built a low-cost antenna analyser which can measure an antenna and display its VSWR over any or all of the HF frequency bands. It will find the minimum VSWR and corresponding frequency for each band but also will display a realtime VSWR for a user-selected frequency to facilitate antenna adjustment. If sweeping a single frequency band, it will display a graph of VSWR versus frequency. It also has a USB port on the back for outputting frequency and VSWR data, to allow more refined graph-plotting on a PC. The USB port can also be used to reflash the firmware if needed.

I recently got into amateur radio (because I liked the idea of peer-to-peer communication over huge distances without infrastructure) and rapidly made the following observations:

1. All of the worldwide communications that interested me take place on the HF bands (3-30 MHz)

2. HF transceivers are very expensive and will break if you don't drive them into a reasonably well-matched antenna

3. You are generally expected to rig up your own HF antenna from bits of wire strung across the garden (unless you want to spend even more money than you spent in 2).

4. Your antenna might be a bad match but you won't know till you try it.

Now a purist would probably say that one should first test the antenna on very low power at the frequency of interest and check the VSWR on the rig's meter to assess the quality of the match. I don't really have the time to muck about with that sort of thing for every frequency I might want to use. What I really wanted was an antenna analyser. These devices can test the quality of the antenna match at any frequency over the HF bands. Unfortunately they are also very expensive, so I set about considering whether I could make my own. I stumbled upon the excellent work carried out by K6BEZ (see, who investigated the use of an Arduino to control a cheap direct digital synthesiser module (DDS). He soon abandoned the Arduino on cost grounds, preferring to use a PIC. Well, in 2017 you can buy an Arduino Nano for about £3.50, so I thought it was time to revisit his work, pick up where he left off and see what I could come up with (note that I'm not the only one who has done this: there are some very nice examples to be found on the internet).

Update (29/7/2018) - this work has been built upon considerably by bi3qwq, from China, who has made some really nice improvements to the user interface, which he has kindly shared. He's designed a very professional PCB (with a great calibration resistor feature) and done a really good looking build. To top it all he has prepared a schematic, which I know will delight many of those who have commented previously. Please see the comments section for more information.

Update - I've been getting into 60 m recently, which the original sketch didn't cover. So now I've uploaded firmware version 7, which adds the 160 m and 60 m bands. These aren't add-ons; they are fully integrated into the operation of the analyser. It was fortunate that I could find an u8glib font that was still legible but allowed me to display ten bands simultaneously on that little screen (although it wasn't monospace, which caused some grief). I have estimated calibration values for the new bands, based on interpolation / extrapolation of the existing calibration values. I then checked these out with fixed resistors and they give pretty good results.

Update - as several people have asked about schematics, the fundamental Arduino / DDS / VSWR bridge circuit is largely unaltered from K6BEZ's original work. Please check out the above URL for his original schematic on which I based this project. I've added an encoder, an OLED screen and fully developed firmware to make for an effortless user experience.

Update - This system uses a very low voltage DDS signal source in conjunction with a resistive bridge containing diode detectors. Thus the diodes are operating in their non-linear regions and my first version of this system tended to under-read VSWR. As an example, a 16 ohm or 160 ohm impedance load should show a VSWR of about 3 in a 50 ohm system; this meter indicated a VSWR closer to 2 in this situation. I therefore carried out a software calibration using known loads which seems to be an effective fix for this problem. This is described in the penultimate step of this instructable and a revised sketch has been uploaded.

Update - on-board graphing facility added to single sweeps as it was too useful to leave out, particularly when tuning antenna lengths for minimum VSWR : a graph gives you an instantly visible trend.

Step 1: Buy Your Stuff

You will need the following items. Most of them can be obtained cheaply from Ebay. The most expensive single item was the box, at close on £10! It might be possible to substitute some items (I used 47 Rs instead of 50 Rs, for example). The diodes were rather unusual (I had to buy 5 off from Italy) and would be worth substituting for more readily available items if you know what you are doing.

  • Arduino Nano
  • DDS module (DDS AD9850 Signal Generator Module HC-SR08 Signal Sine Square Wave 0-40MHz)
  • 1.3" i2c OLED display
  • MCP6002 op-amp (8 pin)
  • 2 off AA143 diode
  • Ceramic capacitors: 2 off 100 nF, 3 off 10 nF
  • 1 uF electrolytic capacitor
  • Resistors: 3 off 50 R, 2 off 10 K, 2 off 100 K, 2 off 5 K, 2 off 648 R
  • 2.54 mm pitch screw terminal blocks: 3 off 2-pin, 2 off 4-pin
  • Single-core hook-up wire
  • 702 or similar hook-up wire
  • Stripboard
  • Square header strip (female) for plugging the Arduino and DDS into - don't buy the round socket stuff by mistake!
  • SO-239 chassis-mount socket
  • Rotary encoder (15 pulse, 30 detent) with push switch and knob
  • Cheap rotary encoder 'module' (optional)
  • Project box
  • Toggle switch
  • Right-angle mini-usb to USB B bulkhead mount lead (50 cm)
  • PP3 and battery clip / holder
  • Self-adhesive PCB mounting posts / standoffs

You'll also need a soldering iron and electronics tools. A 3D printer and a pillar drill are helpful for the enclosure, although if you wanted you could probably assemble the whole thing on the stripboard and not bother with a box.

Naturally you undertake this work and exploit the results generated at your own risk.

Step 2: Lay Out the Stripboard

Plan out how you are going to arrange the components on the stripboard. You can either do it yourself, referring to K6BEZ's original schematic (which lacks an encoder or screen - see Page 7 of, or you can save a load of time and copy my layout.

I do these layouts the simple way, using squared paper and a pencil. Every intersection represents a stripboard hole. The copper tracks go horizontally. A cross represents a broken track (use a 6 mm drill or the proper tool if you have one). Lines of circles with a box round them represent headers. Large boxes with screws denote the connector blocks. Note that in my diagram there is an extra line which runs horizontally through the middle of the board. Leave this out when you are putting it together (it's marked 'omit this line').

Some of the components may appear to be laid out strangely. This is because the design evolved once I'd got the basic hardware working (particularly when I realised that the encoder needed hardware interrupts, for example).

When soldering components onto the board, I use Blu-Tak to hold them in firmly in place while I turn the board over to solder the legs.

I tried to minimise the amount of wire I used by aligning the Arduino and the DDS module and just using the stripboard to connect key pins. I didn't realise at the time that the hardware interrupts needed to read the encoder only work on pins D2 and D3, so I had to move DDS RESET from its original D3 connection with a bit of wire:

DDS RESET - Arduino D7

DDS SDAT - Arduino D4

DDS FQ.UD - Arduino D5

DDS SCLK - Arduino D6

Arduino D2 & D3 are used for the encoder inputs A & B. D11 is used for the encoder switch input. D12 isn't used but I thought I'd make a screw terminal for it anyway, for future expansion.

Arduino A4 & A5 provide the SDA & SCL (I2C) signals for the OLED screen.

Arduino A0 & A1 take the inputs from the VSWR bridge (via the OPAMP).

Step 3: Install the Modules, Attach the Peripherals and Flash the Code

It's worth testing the board before going to the trouble of mounting it into an enclosure. Attach the following components using flexible wire to the board using the screw terminal blocks:

  • 1.3" OLED display (SDA and SCL are connected to Arduino pin A4 and A5 respectively; ground and Vcc go to Arduino GND and +5V, obviously)
  • Rotary encoder (this needs a ground, two signal lines and a switch line - you might need to flip the switch lines round if the encoder works the wrong way - connect these to Arduino ground, D2,D3 & D11 respectively). Note that for my prototyping work I mounted the 15/30 encoder onto a KH-XXX encoder module board, as the pins on the bare encoders are very flimsy. For the final job I soldered wires straight onto the encoder.
  • 9V battery
  • SO-239 socket - solder the centre pin to the antenna signal line and use an M3 ring terminal and screw for the antenna ground

Flash the following sketch onto the Arduino. Also make sure you have included the very good OLED driver library from Oli Kraus, or the complilation will crash and burn :

If your OLED display is slightly different you may need a different configuration setting in u8glib; this is well documented in Oli's example code.

Step 4: Put It All in a Nice Box (optional)

I seriously considered leaving the analyser as a bare board, as it was only likely to be used occasionally. On reflection though, I thought that if I was doing a lot of work on a single antenna, it might end up getting damaged. So everything went in a box. There's no point going into details about how this was done, as your box will likely be different, but some key features are worth mentioning:

1. Use self-adhesive PCB standoffs for mounting the stripboard. They make life really easy.

2. Use a short USB adaptor lead to bring out the Arduino USB port to the rear of the enclosure. Then it's easy to access the serial port to obtain frequency vs. VSWR data and also to reflash the Arduino without taking the lid off.

3. I developed a custom 3D-printed part to support the OLED display, as I couldn't find anything on the web. This has a recess to allow one to insert a 2 mm piece of acrylic to protect the fragile screen. It can either be mounted using double-sided tape or self tapping screws (with the tabs on either side). Once the display has been fitted, you can use a hot wire (think paperclip and blowlamp) to melt the PLA pins onto the back of the circuit board to secure everything. Here's the STL file for anyone who's interested:

Step 5: Calibration

Originally I didn't do any calibration but discovered that the VSWR meter was consistently reading low. This meant that although an antenna appeared to be okay, my rig's autotuner wasn't able to match to it. This problem arises because the DDS module gives out a very low amplitude signal (about 0.5 Vpp at 3.5 MHz, rolling off as frequency increases). The detector diodes in the VSWR bridge are therefore operating in their non-linear region.

There are two possible fixes for this. The first is to fit an broadband amplifier to the output of the DDS. Potentially suitable devices are available cheaply from China and they will boost the output to about 2 V pp. I have ordered one of these but have yet to try it. My feeling is that even this amplitude will be a bit marginal and some non-linearity will remain. The second method is to put known loads on the output of the existing meter and to record the displayed VSWR at each frequency band. This allows you to construct correction curves for actual versus reported VSWR, which can then be put into the Arduino sketch to apply correction on the fly.

I adopted the second method as it was easy to do. Just get hold of the following resistors: 50, 100, 150 and 200 ohms. On this 50 ohm instrument these will correspond to VSWRs of 1,2,3 and 4 by definition. In the sketch there is a switch 'use_calibration'. Set this to LOW and upload the sketch (which will display a warning on the splash screen). Then carry out measurements at the centre of each frequency band for each resistor. Use a spreadsheet to plot expected versus displayed VSWR. You can then do a logarithmic curve fit for each frequency band, which gives a multiplier and intercept of the form TrueVSWR=m.ln(MeasuredVSWR)+c. These values should be loaded into the swr_results array in the last two columns (see the preceding comment statement in the sketch). This is an odd place to put them but I was in a hurry and as this array stores floats it seemed like a sensible choice at the time. Then put the use_calibration switch back to HIGH, reflash the Arduino and off you go.

Note that when doing the spot frequency measurements, the calibration is applied for the initial choice of band. This won't be updated if you make gross changes in frequency.

Now the meter reads as expected for the fixed loads and seems to make sense when measuring my antennas! I suspect I may not bother trying that broadband amp out when it arrives...

Step 6: Using the Analyser

Attach an antenna via a PL-259 lead and switch the device on. It will display a splash screen then automatically perform a sweep of all the main HF bands. The display shows the frequency under test, the current VSWR reading, the minimum VSWR reading and the frequency at which it occurred. In order to reduce measurement noise, five measurements are taken of VSWR at every frequency point; the mean value of these five readings is then passed through a nine-point moving average filter with respect to frequency before the final value is displayed.

If you want to stop this all-bands sweep, just press the encoder knob. The sweep will stop and a summary of all the band data gathered will be displayed (with nulls for those bands not yet swept). A second press will bring up the main menu. Choices are made by rotating the encoder and then pressing it at the appropriate point. There are three choices in the main menu:

Sweep all bands will restart the sweep of all the main HF bands. When it finishes, it will display the summary screen described above. Write this down or take a photo if you want to keep it.

Sweep single band will allow you to select a single band with the encoder then sweep it. Both the wavelength and frequency range are displayed while making the selection. When the sweep has finished, a second press of the encoder will display a simple VSWR versus frequency graph of the band just swept, with a numerical indication of minimum VSWR and the frequency that it occurred. This is very handy if you want to know whether to shorten or lengthen your dipole arms, as it shows the VSWR trend with frequency; this is lost with the simple numeric report.

Single frequency allows you to choose a single fixed frequency and then continuously updates a live VSWR measurement, for antenna tuning purposes in real time. First select the relevant frequency band; the display will then show the centre frequency of the chosen band and a live VSWR reading. The relevant band calibration is applied at this point. One of the digits of the frequency will be underlined. This can be moved left and right with the encoder. Pressing the encoder emboldens the line; then rotating the encoder will reduce or increase the digit (0-9 with no wrap or carry). Press the encoder again to fix the digit, then go on to the next one. You can access pretty much any frequency across the entire HF spectrum using this facility - the band selection at the start just helps to get you close to where you probably want to be. There's a caveat though: the calibration for the selected band is loaded at the start. If you move too far away from the selected band by changing the digits the calibration will become less valid, so try to stay within the chosen band. When you have finished with this mode, move the underscore all the way to the right until it's under 'exit', then press the encoder to return to the main menu.

If you connect your PC to the USB socket on the rear of the analyser (i.e. into the Arduino), you can use the Arduino serial monitor to collect frequency versus VSWR values during any sweep operation (it's currently set to 9600 but you can change that easily by editing my sketch). The values can then be put into a spreadsheet so you can plot more permanent graphs etc.

The screenshot shows the VSWR summary for my 7.6 m fishing pole vertical antenna with 9:1 UNUN. My rig can accommodate a 3:1 max SWR with its internal auto-tuner unit. You can see that I will be able to tune it over all bands except 80 m and 17 m. So now I can relax in the knowledge that I've got a passable multi-band antenna and I'm not going to break anything expensive when transmitting on the majority of bands.

Good luck and I hope you find this useful.

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017