A Small Digital QRP SWR Meter with OLED Display
Thin
0.96" 128 x 64 pixel high contrast OLED LCD displays available at
attractive prices led me to design and build this compact QRP SWR
meter.
UPDATED SOFTWARE NOW AVAILABLE:
1. 0.96" OLED display problem fixed
2. Improved low power operation
3. ATtiny45 and ATtiny85 versions, and
3. 1.3" OLED software (ATtiny85 only) version
Some
recent (late-2018 and early-2019) 0.96" OLED displays do not work
correctly with the original software. To resolve this required a
significant revision of the software to ensure the software works with
all 0.96" OLED displays with integrated SSD1306.
In
addition, some improvements have been made to the operation of the
meter when used with very low QRP power. Versions have been provided
(below) for use with ATtiny45 and ATtiny85 devices.
My sincere thanks go to Bob ZS6RZ for bringing these problems to my attention and patiently working with me to test the revised software.
Finally,
for those like me whose eyesight is not quite so good as it once was, I
have created a version of software for use with the latest larger 1.3" OLED displays.
Please carefully read the details for this change in the relevant
section below. The OLED display pinout and its integrated processor are
different. Note: This larger display will NOT fit the current 3D
printed case shown below.
Introduction
Standing
Wave Ratio (SWR) meters are built into most modern transceivers. However, for those of
us who build their own equipment, it's useful to have a compact
standalone
SWR meter.
SWR meters measure the impedance match between a
transmitter and the output load. If the load differs from the reference
impedance then ‘standing waves’, i.e. peaks and drops in RF voltages,
will be present in the transmission line between the transmitter and
the antenna. The ratio of the peak to minimum RF voltage is displayed
on the SWR meter, referenced to the transmission line’s characteristic
impedance, usually 50 ohms.
Figure 1 : The SWR meter is located between the transmitter and the antenna tuner
Transmitter-antenna
matching is a complex and controversial subject. However, most accept
that transmitters operate best when the power output is connected to a
load which presents an SWR below 2:1. For example, 100 ohms, 25 ohms,
or a reactive load such as 35+j25 ohms.
In some cases,
severe mismatching the output can result in damage to the transmitter
output stage. Antenna tuners (one is described elsewhere on my website)
are used to match an antenna’s impedance, sometimes outside of this
notionally safe 2:1 SWR range, to a more suitable value. SWR
meters allow antenna matching to be measured, and so are often used to
adjust an antenna tuning unit or matching network to the correct
setting.
Inside SWR Meters
While
SWR
can be determined from measurements using an impedance bridge.
Several examples of impedance bridges - analog and digital - are
described elsewhere on this website. Impedance bridges
are typically standalone test instruments. They are seldom used
with a transmitter or remain connected to an antenna for the long-term.
By contrast, SWR meters are designed to be used with transmitters
and remain in-circuit.
Most
SWR meters use directional couplers. Legacy directional couplers used
parallel transmission line couplers. These used ‘forward’ and ‘reverse’ transmission line measurements to determine
SWR. Most modern SWR meters use either the Breune coupler or the
Stockton coupler. These measure voltage and current on the transmission
line and phase differences across the couplers, usually using from one
to four toroids, allow impedance, and thus SWR, to be measured.
Numerous
versions of Breune and Stockton couplers have been published. Detailed
analysis of the functioning of each coupler type can be found on the
web and will not be repeated here.
Resistor-based bridge
circuits can also be used to measure SWR, particularly for QRP (low
power) applications. However, these have high insertion loss and, unlike
directional coupler-based SWR meters, these resistor bridge types
cannot be left in circuit while operating the transmitter for long
periods.
Most couplers use simple diode detectors, many
combined with additional op-amps for buffering and compensation. A
few more recent designs have adopted IC-based active logarithmic power
detectors for better sensitivity and wider dynamic range.
For a
variety of reasons, including simplicity, this design uses a Breune
coupler and simple diode detectors
Transmitters range in power, and
operate from LF to UHF. This meter is designed for use with HF QRP
transmitters with output powers from about 3W to 15W which operate over
the HF spectrum, from 3 to 30MHz.
Circuit Description
The
schematic is shown in Figure 2. The Breune directional coupler consists
of the toroid T1, which samples the current in the transmission line,
and capacitors C2 and C3 which sample the voltage on the line. The
current sampling transformer produces two anti-phase outputs at each
end of R1. Along with the voltage from the C2/C3 voltage sampling, this
arrangement allows ‘forward’ and ‘reverse’ power to be detected by the
diodes (D1 and D2).
By the way, you must use germanium
diodes in this bridge. I tried Schottky diodes and regular small signal
silicon diodes, but they gave poor results in comparison to the 1N60
germanium diodes I was finally able to purchase. These other diodes are
probably fine if you are using higher RF power, like 50 – 150W or more.
Figure 2 : The SWR meter runs from a single AAA battery
The
detected forward and reverse voltages pass to two 10-bit analog to
digital (A2D) converters inside the ATtiny45 microprocessor. The
firmware in the processor then calculates the resulting SWR.
Note:
The design can use either the ATtiny45 chip as shown in the schematic
or the pin-compatible ATtiny85 which has twice the flash memory
space of its little ATtiny45 brother. Software for both versions is
available for download below)
A
compact OLED LCD is used to display forward and reverse power as well
as SWR simultaneously on three bar graphs. This OLED display is a very
thin 0.96” 128 x 96 pixel module with excellent contrast, ideal for
both indoor and outdoor use. The simple I2C interface requires just two
pins on the processor. That allowed me use the equally small 8-pin
ATtiny45 processor.
In addition, a small icon in the lower
left corner of the OLED display also reports the battery level. This is
scaled to display from 0.9 to 1.5V. Based on extensive work reported on
the well-known eevblog website [www.eevblog.com], 0.9V is a reasonable
‘end-of-life’ value for a 1.5V AAA battery. The battery voltage is
measured via R5 (100k). This relatively high value is necessary to
ensure the battery voltage does not keep the ATtiny45 in the reset
condition on power-up.
A small 3mm diameter LED is
connected to pin 6 of the ATtiny45 (or ATtiny85). This is turned on by the software
when the SWR is greater than 2:1. It allows faster tuning of an antenna
tuner. The tuner is adjusted either until the SWR bar graph shows an
acceptable value, say 1.5:1 if this is the value you prefer, or simply
adjust the tuner until the LED goes out (i.e. SWR ≤ 2:1).
A
miniature DC-DC boost converter module is used to boost the AAA battery
voltage to 5V for the processor and display. This module is reasonably
efficient, and reduced the overall size and weight of the SWR meter.
With battery installed, the meter weighs about 50 grams.
Operating
the meter from a 1.5V AAA battery increased the versatility of the SWR
meter. These batteries are readily available, and it provides a
reasonable lifetime in this design.
The SWR bar graph also
features an expanded scale. If SWR was displayed linearly, then the
most useful part of the display (from 1:1 to 3:1) would be displayed
over just 30% of the scale. Instead, this is expanded out to
cover 50% of the meter scale.
Parts List
These are the parts you’ll require:
Table 1 : Parts list for the SWR meter
Just
as I finished this meter, I noticed that the price for these OLED
displays had surged in price, and were suddenly from 2 to 10 times more
expensive. The usual Chinese suppliers were also reporting no stocks. A fire
in the Chinese factory perhaps? Interestingly, some 12-18 months later, things returned to normal with excellent pricing again.
Construction
It’s
built on a small piece of prototyping board. I began by winding the
toroid, and mounting the parts for the Breune coupler. I could then
test that section using a voltmeter to measure results. The diode
detectors produced about 1.5V across the 1M resistors with 5W of RF.
I
used phono sockets for the RF connectors. I can hear the screams of
horror from readers over that choice. Feel free to use SO-239 or BNC
sockets if you prefer. I could not buy those where I live, and without
a reliable postal service, I couldn’t order anything more suitable.
Anyway, this is only for QRP power levels, and phono sockets have
proven OK for me. At some stage, I may rebuild it using BNC sockets.
The
remaining parts associated with the ATtiny45 can then be mounted. I
used a socket for the processor, and a four-way socket for the display.
The OLED LCD came complete with a four way matching connector soldered
to the display. The small DC-DC module can also be added at this
point.
If the ATtiny45 and display are left unplugged,
almost all of the circuit can be tested including checking the supply
voltage on pin 8 of the processor socket with the AAA battery
installed. (It should be 5V +/- 0.5V)
Making the 3D Printed Enclosure
I
also designed a 3D-printed plastic enclosure for the SWR meter
and 0.96" OLED display consisting of an upper and lower half. I use the DesignSpark Mechanical
software for these 3D designs which I have found to be excellent. The connectors and switch
fit along the case seam for a neat finish. The box measures a very
compact 70 x 50mm, and tapers in height from 22mm at the back to 15mm
at the front, roughly one-third of the volume of a packet of cigarettes.
Figure 3 : The 3D-printed enclosure includes an integrated AAA battery holder
I
printed it using standard black 1.75mm PLA plastic. I used my Printrbot
Simple Metal 3D printer (without heated platform) to print out the
case. The required STL-format files are available for download below.
Figure 4 : The tapered enclosure is compact and robust when assembled
To
make the battery contacts for the AAA holder, cut two 10mm x 4mm flat
tin strips from a tin can. Solder a short piece of red hookup wire to
the end of one strip and a similar short black hookup wire to the
other. Slide each strip into the slots located in the ends of the
battery holder. Adjust if necessary to ensure there is just a slight
pressure on the battery terminals when the battery is in place.
Figure 5 : Battery contact details
The
assembled circuit board can be placed in this enclosure, the battery
wires connected as shown, and the top and bottom covers screwed
together using two short M3 self-tapping screws. You will need to drill
two 3.3mm holes for clearance for the two M3 screws that hold the case
together.
The 0.96" OLED
display is carefully placed into the upper half of the case. A drop of
glue can hold it in place. Be careful not to apply any pressure to the
display. They are very delicate. Then close the case ensuring the
display pins slide into the 4-way socket on the lower board.
The
artwork can be printed out using a laser printer, covered with
self-adhesive clear plastic film, and glued to the top cover. (The
panel artwork is available for download below)
Programming the ATtiny45 or ATtiny85
All
of the software is written in Bascom, a Basic-like language for the AVR
processor family. To ensure the display is updated quickly, the OLED
LCD screen is not completely updated every time some value changes.
Instead, each bar graph (and battery icon) is updated, speeding up the
display significantly.
I used a USBasp programmer to program the chip. Ready-to-use USBasp
programmers can be purchased from any number of Chinese suppliers over
the web, usually for less than $US3 delivered. Examples include
Banggood (SKU064451 or SKU131560, for example) and Hobbyking (e.g. Part
381000147). Note: These part numbers vary periodically.
GUI
software to drive the programmer is available (free) from various
websites including Khazama and Extreme.
The
ATtiny45 processor has flash memory, EEPROM, and “fuses”, all of which
are programmable. Flash memory contains the program. EEPROM can
also be programmed by an external programmer (like the USBasp above)
but is more typically used by the ATtiny, to save user-entered
settings, for example.
The “fuses” save special parameters
semi-permanently. These configure the ATtiny for its operation. That
includes the clock oscillator configuration, reset timing, and so forth.
In
this case, you will need to (FIRST!) program the flash memory with one
of the HEX files. Use the 't85' version for ATtiny85 chips and the
't45' version for ATtiny45 chips.
This is the compiled Bascom software which is saved in an
Intel-formatted HEX file. It’s available for download below.
THEN, program the fuses in the ATtiny45 or ATtiny85. The details for
fuse settings are described in the source code and are the same for both chips. For convenience, I shall repeat them here:
Lock: &0FF
Extended: &0FF
High: &05F
Low: &0E1
IMPORTANT:
The Low fuse bits include one bit which configures the RESET pin for
use with the battery monitor. This prevents the chip from being
reprogrammed again (should you need to do this) until the fuses are
first reset using a specialised High Voltage Programmer. If you
need to make your own, an excellent design for a "Fusebit Doctor
(HVPP+HVSP)" which handles an extensive range of devices is available
from elektroda.pl (Search in your favourite search engine for the
latest location of the schematics and software. It seems to change
periodically)
Operation
Connect the SWR meter as shown in Figure 1 and turn the meter on. The battery icon should indicate the battery level.
Turn
on the transmitter’s carrier. The output power should be less than 15W
to avoid damaging the meter. The SWR meter should then display the
relative forward and reverse power levels and the SWR.
Adjust the antenna tuner and confirm that the SWR LED goes out when the SWR is about 2:1 or less.
The meter may be left in circuit, either turned on or off, as required.
Figure 6 : The SWR meter in use with my 5W QRP transceiver displaying
a SWR of about 1.5:1 and a nearly 100% battery level
Using a 1.3" OLED Display
For
some, the 0.96" OLED displays might be too small for regular use. While
updating the software recently, with the extensive and helpful support
with testing of the revised software from Bob ZS6RZ, I went on to
experiment with some recently released (2019) 1.3" OLED displays.
The
sellers suggest these are compatible with 0.96" OLED
displays. Unfortunately, this is not correct. The 0.96" displays
(almost always) have SSD1306 controllers inside them while the 1.3" displays (almost
always) use SH1106 controllers. The SH1106 chip does not support automatic
column and page address incrementing, and, unlike the SSD1306, it
also requires specific page and column addressing. Using
these larger displays therefore required some changes to the
original code along with some additional software to handle the
addressing differences.
Also, be aware that there are several other very important differences between these displays. First, the display pinout
for the 1.3" displays I purchased were different to the pinouts on all
of my 0.96" OLED displays. The VCC and GND pins were reversed compared
with most other 0.96" OLED displays. In addition, some 1.3" displays
are limited to 3.3V operation(!!).
This requires an additional change for this design which normally operates from 5V.
I
tested my SWR meter design
with both 3.3V and a 5V 1.3" SH1106-based OLEDs with a supply voltage
of 3.3V and 5V respectively and they worked
perfectly. But, while my tests went perfectly, I
cannot guarantee that YOUR display and YOUR processor and my software
will work correctly at 3.3V. One reason: The fuses as set here
(See above for details) configure the chip to operate with its internal
RC and PLL clock running at
16MHz. That's beyond the chip's rated performance when running at 3.3V
although I have not found any of my chips that have failed to operate
at that clock speed at that voltage. But "your mileage may vary", as
they say i.e. It worked for me in my tests with at least eight
different
chips from different maufacturing batches, but it may not work for your
chip, or, say, on some cold days, or when the battery runs down too
far, or ... whatever.
(Of course, if you want to run your
SWR meter at 3.3V, you will also need to replace the DC-DC boost
regulator module shown in the schematic with a more suitable version
rated at 3.3V output)
Key fact to note: Check
and double check the OLED display you buy to ensure it's compatible. If
you want to use a 0.96" OLED, make sure you get one that uses a SSD1306
controller. If you want to use the 1.3" OLED, check it uses the SH1106
controller and check what voltage is runs at, preferably 5V.
Downloads:
IMPORTANT:
This software and firmware is provided for personal non-commercial use only. That means
you are able to use the software in your own SWR meter, and you may share the
software with others at no cost provided you retain details of the design source i.e. www.zl2pd.com etc. You MAY NOT resell
the software or the design
without written permission from the copyright owner (That's me, Andrew,
ZL2PD). This includes such things as club kits. However, permission is
readily given in
most cases at no cost provided the source is clearly noted. Please also
note that republishing or making available the design and/or software
in any form on other
websites etc is also NOT permitted without permission.
(Sorry,
folks. Problems with some individuals and companies copying and
reselling my designs as their own work for profit has brought
about the need to highlight these obligations)
Software for the SWR meter (including
Bascom source code and a HEX file for directly programming the ATtiny45
or ATtiny85, plus software for the larger 1.3" OLED)
Included in the ZIP file are:
- swr08_t85.bas BASCOM source code for the ATtiny85
- swr08_t85.hex Standard Intel-format HEX file for directly programming an ATtiny85 for this project
- swr08_t45.hex Standard Intel-format HEX file for an ATtiny45 for this project
- swr08_130sh1106LCD_t85.hex HEX file for programming an ATtiny85 with 1.3" OLED for this project
- swr08_130sh1106LCD_t45.hex HEX file for programming an ATtiny45 with 1.3" OLED for this project
Note: Fuse details are documented near the top of the source code.
Front panel artwork (0.96" OLED only. Not compatible with 1.3" OLED displays)
STL-format 3D printer enclosure file (0.96" OLED only. Not compatible with 1.3" OLED displays)
Want to go back to the main page? Click
here to
return directly.