Skip to content

{ vk5jst“” } Search Results

VK5JST Aerial Analyzer software re-engineering update

About what happened to the VK5JST Aerial Analyzer Picaxe software at K1CD (PicAxe basic code at the link):

The idea was to learn about how the analyzer works, what the Picaxe can do and how it works, and to improve the code as a learning tool for radio amateurs trying to put that test answer about impedance into practical knowledge.

1) Inline square root calculations were replaced with the built in function.

2) Inline number formatting was replaced by a subroutine.

3) EEPROM was used for output template storage and the the scratchpad for a display buffer rather than using the lookup function in a loop to output strings.

4) The code was restructured so all one-use startup instructions were at the top of the listing, all the multiple use functions were placed as subroutines at the bottom, and the main loop was in the center section. Comments were added to help explain the what and why of code sections.

5) Conditional instructions were re-written to better utilize the If-Then-Else construct, avoid goto’s, and more clearly communicate function.

6) Calculation error detection was simplified base on an analysis of intermediate calculation values and considerations of the particular problem being solved.

7) Terminal output for debugging was implemented to allow watching the program progress via the serial port used for program downloading. this also serves to comment and describe the code function.

8) Compile defines were utilized to faciliate including or removing code sections for functions like terminal debugging, test value
insertion and monitoring, or development code.

9) Variables were shoehorned into the registers available and given names to assist in understanding the code.

10) Peek and poke variable access was eliminated.

Voltage values are read before and after the count with 10 bit resolution. The two readings are then averaged and scaled for use. The idea is to improve the accuracy of the voltage readings and reduce jitter and other artifacts. It doesn’t seem to matter much, though.

VA3SMM’s L and C calculation is calculated and displayed only when the SWR calculation fails basic sanity checks for input values. It is intended to be a placeholder for now but is useful for exploring just how good an LC meter this thing can be.

Tab stops of 4 were mainly used but the IDE (Axepad) doesn’t render them very well so some alignment issues persist.

Since the code only occupies about a quarter of the memory available there is room for a lot more stuff. A 32 bit fixed point calculation library might be interesting to add. That would make it easier to calculate resonant frequencies, cable issues, or whatnot.

There are a number of pins available that could be used for function selection or other option input. That would require a bit of surgery on the circuit board and hardware tweaking is for when the software tweaking is pretty well finished.

The inactivity and battery low detection only really make sense if the entire device power can be shut off. The device pulls a bit over 1 Watt and turning off the Picaxe makes very little difference in that. (more hardware tweaking?)

There are still a lot of ‘magic numbers’ that might be better implemented as compile constants. There is no need to get carried away but a good balance will help facilitate code changes and also document functions.

A table at the bottom of one listing (from VK3DPM, I think) was transferred to a spreadsheet as a means to analyze intermediate results from calculations and to verify results in simulation runs. This was used to determine valid input ranges, calculation roundoff errors, accumulated errors, and other issues.

Now for the hardware. One of the best resources I have seen for tweaks is

Despite all the software changes, it still seems to work.

If you see something of note or something that needs fixin’ – let me know: tcl @

VK5JST analyser software: mathmatics considerations

There are a number of programs out there for the VK5JST aerial analyser. One problem is that I don’t know which one was the pre-load so I take a risk in fiddling with the code. The PICAXE doesn’t have a code backup feature so if I load it with test software, how do I know I can get it back to its original state? Then there’s the state of the various programs I can find. There has obviously been some development but there is a long ways to go from anything I have seen to modern software practice. Much of the code is in assembler style. Routines for extraction of digits from a number and for taking the square root are inline and repeated frequently. Word and byte register references use machine names rather than symbolic names and there is no discipline about whether to use the byte or the entire word in calculations.

The arithmetic is not that esoteric. Only basic operations plus square and square root are needed. The primary limitation is that the hardware only supports natural numbers up to 16 bits in size. That’s the integers between 1 and 65535. That is one reason why the bridge voltages are set to values of 240 or less. 240 squared is 57600 so it will fit in the number scheme.

It is easy to set up a spreadsheet to examine intermediate calculation values to see if (and where) accommodations need be taken for overflow. From what I can tell so far, simple triangle checks will do for resistance and reactance calculations. To prevent overflow on SWR calculations, scaling can be used when either the reactance or resistance values exceed 100.

There are two tests in the code that assure an obtuse triangle. In the complex plane, the angle ranges from 0 to 45 degrees only. The hypotenuse is set by the oscillator voltage and the angle by the reference resistance. 0 degrees represents a load with resistance only and the reference plus load voltages simply add to the oscillator voltage. 45 degrees represents a load with reactance only and is a simple right triangle. In between these two tests is the valid region for calculations. At the edges, the code sets the oscillator value to match the case which might be off due to round-off issues. I adjusted the code so that it sets the reference and load voltages as appropriate as well and solve the triangles only when in between the edge cases.

Rather than use value tests for out of range detection and error notices such as “>500” or whatnot, I’ll take a look at just whether the number will fit in the number of digits allowed for display as the test and show an infinity symbol if the number has too many digits for the display field. This appears reasonable from the spreadsheet tests of the triangle test conditions. It also emphasises the precision and accuracy issues that need some investigation.

One question is about how much the oscillator voltage will vary with load. It is calibrated to be 240 and it doesn’t seem that it should change that much with load especially considering the 50 ohm reference resistance in series. It does seem, though, that it can be dragged down. Dave was tickled when he saw the ‘oscillator KAPUT’ error message when testing the analyser indicating no oscillator voltage. If something does cause an increase in the oscillator voltage, overflow could result. Since I am not that up on the theory of the circuit and its implications, I’ll have to use empirical experimentation to see how the oscillator voltage is influenced by load.

Understanding units is also something I need to investigate. Output reactance is in ohms, How is that influenced by the input voltages, which are scaled? This is a particular issue when it comes to the capacitance and inductance calculations. Since it is ratios of the sides of triangles, it’s all a matter of scaling but I am not happy until I can actually see how output units match input units.

The PICAXE 28X1 does carry 32 bits on calculations but only returns the low word result unless you specify you want the high word. That means you can do 32 bit arithmetic and there are some routines out there to implement it. That needs some investigation. The 28X1 also has routines built in to handle the square root and digit extraction. Another feature is EEPROM and scratchpad memory that can be used to facilitate display management. Use of these features should greatly simplify the code and make it much easier to follow and understand. The question is what taking advantage of these features will do to the operation of the device.

There is also a serial output that the IDE (integrated development environment) can display in a terminal window. I can use this for debug output of pertinent values to see if my spreadsheet analysis has holes when it comes to the PICAXE environment. I could use the IDE simulator – and may do that just to see how it works – but it seems that it’d be easier to wander through input options by using the actual device and tracking its calculations.

I see anther interesting application for the PICAXE. VK4ADC built a PICAXE-based Auto Antenna Switch for Icom Radios. He used the serial port to monitor the C-IV port on an IC706 so he could automatically change antenna to match the frequency of the radio. That has possibilities!

VK5JST Aerial Analyser

Things have changed since the Knight Kit Grid Dip Oscillator days. The Adelaide Hills Amateur Radio Society offers the parts for VK5JST’s Aerial Analyser at about half the price of getting one from MFJ or elsewhere. It is a ‘collection of parts’ and not a kit! The circuit board is nice but not silk screened with parts placement identifications so you have to use the board layout provided in the manual to get the right parts in the right places. There is no surface mount stuff so the soldering isn’t that much of an issue.

The Aerial Analyser is an hf oscillator that feeds an impedance bridge. That outputs voltages for the oscillator, a reference 50 ohm resistance, and the load for analysis by a PICAXE microcontroller. That chip is part of an educational effort for electronic projects such as robots or interactive devices. It is cheap (~$10 for the one in the analyser). There are all sorts of devices, starter kits, and support for it. Programming is simplified as much of the low level stuff is provided in firmware and accessed by a BASIC like interpreter. It appears to be ideally suited to VK5JST’s device.

One indicator of a good design is what people do with it. PA0FRI has a good rundown on his ideas to provide better oscillator buffering. A number of folks have modified the code to add L/C calculations or other things.

This sort of project can be a very good self taught lab course. You can get into the oscillator circuit itself, the calculation of impedance from the bridge measurements, issues of precision and accuracy in analog to digital conversion, natural number arithmetic for complex variables, and all sorts of other fun topics.

more later!


First link was to an Antenna Analyzer by Beric Dunn, K6BEZ via DxZone. That lead to SierraRadio’s Hamstack and that to KJ6HFR’s PIC18F4620 Cookbook (PDF).

When I find a microcontroller website that doesn’t fall headlong into the Arduino craze my interest goes up. Hamstack does seem to be mcu agnostic and even language agnostic. There are projects for repeater control as well as station control and accessories.

KJ6HFR’s cookbook is an exploration into fundamental chip configuration. The YouTube video says

“Most of the experiments are done without compiling any code. Instead, the Configuration Word Editor in the PICkit2 application is used to set and investigate chip configurations, such as oscillators and the Watch-Dog Timer. Additionally a tiny amount of hand-assembled instructions are used.”

That means it provides a good insight into the kind of learning often bypassed in may mcu project books with experiments that you can do to learn yourself.

The original stimulus was the antenna analyzer. The questions were about what it used as a signal source and what sort of measurement bridge it used. Those two items and something like the ChipKit or that GPS development board could make for a quite potent analyzer upgrade to VK5JST’s kit. AD9850 based DDS boards are all over EBay for under $10, many with the interesting note that “The after harmonic becomes bigger and bigger when the frequency is between 20-30MHz,and the wave form becomes unclean.” so getting up to 6m or higher isn’t SOP with these devices.

Aerial Analyzer auto-off considerations

One of the tempting features to add to VK5JST’s Aerial Analyzer is an auto-off function. This would shut down the device if the battery got run down or if there were no adjustments made for, say, 10 minutes. This would be fairly simple to do in the software. The problem is with the hardware.

It is easy to turn off the Picaxe. That is just a matter of issuing the ‘END’ statement. That turns off the microcontroller’s use of a few milliwatts and makes very little difference in the analyzer overall battery power draw. That means that an ‘auto-off’ function is nearly useless unless you can install some sort of power control device.

You could isolate the Picaxe to its own power supply and then use some sort of switching it could use to control the oscillator and related circuits. What some have done is to use a second Picaxe as a power control device. I’ve seen one description of this sort of thing as an effort to reduce battery consumption of an Arduino based sensor device. The idea is for the analyzer controller to signal when it no longer needs power. That would be a pin output going high or something. The control processor would see this and then shut down power to the test instrument.

The control processor would spend most of its time in a sleep state pulling very little power (micro-amps, usually). It’d wake up every second or so to check its sensors to see if something need be done.

For the VK5JST Aerial Analyser, the power draw is about 1 watt. If you use NiCd batteries for a 12v supply, you’d have about 10 watt hours of battery available. That’d keep the analyser up for a full day between charges. From that perspective, a whole lotta’ effort trying to reduce battery draw is probably not all that cost effective.

Impedance measuring devices: simple and notso

The VK5JST Aerial Analyser is an excellent kit project to add to the antenna building support collection. This device runs a bit under $150 for a kit of parts. W5BIG has an article in November 2006 QST, An Antenna Impedance Meter for the High Frequency Band (W5BIG site link) that describes another approach. It is interesting comparing and contrasting. W5BIG sells his item for about twice (and up) the price of the VK5JST.

Both use a bridge to determine voltage across the load and current through it at a given frequency. The VK5 uses an analog oscillator with a bridge that provides rectified and filtered voltages for the 8 bit ADC in a Picaxe microcontroller that then handles all the arithmetic and display functions. The W5 device use DDS (direct digital synthesized) signals for the oscillator and mixes two of them so the load measures are down converted to 1 kHz signals fed to a 12 bit ADC (except his commercial offering for hams only use 8 or 10). The microcontroller feeds off both the voltage and current amplitude and phase measures to a PC to do the number crunching and display management. The RigExpert line includes a display.

The VK5 uses a 28 pin Pic microcontroller while the W5 RigExpert uses a 64 pin Amtel with a lot of support circuitry. Both have 8/10 bit ADC and are very similar in terms of capabilities. The Amtel has a lot more internal memory for programming and this shows in the W5 device capabilities.

The use of DDS rather than analog oscillator and a graphic LCD rather than a 2×16 character display means the W5 can scan frequency ranges and create graphs of SWR versus frequency or whatnot.

The VK5 is much simpler at least as far as basic functions and software go. That gives it an edge in terms of learning and potential for modification, especially when compared and contrasted to other approaches such as that W5BIG describes.

Microcontrollers for nifty projects

You can have a lot of fun with a bit of processing power, some analog to digital conversion capability, and some ‘glue’ such as memory, software, and support circuitry. On one end of this type of device is the ‘computer on a chip’ and on the other is the custom programmed hardware. In between there are a bunch of options that balance off cost and capability. Two of the current favorites for the hobbyists are the Arduino and the PICAXE.

The VK5JST Aerial Analyser uses a PICAXE and is a rather typical microcontroller project. It has an oscillator feeding a bridge to measure antenna characteristics. Three voltages from that bridge are fed to ADC ports on the PICAXE to calculate reactance and resistance of the antenna using standard trigonometry calculations.

The PICAXE project is geared towards educational activities like building robots. It is not the fastest nor most compute capable microcontroller but it is cheap and will do the job for interactive devices such as the antenna analyser. It has a BASIC interpreter built into the microcode that makes access and use of its ports a simple affair. The Arduino is a bit faster, more capable, and more difficult to program.

Where this is going is seem with the Digispark. That’s an effort to make a USB dongle with an Arduino cheap enough to play with. The Rasberry Pi at about twice the price (~ $25) not only has USB but also Ethernet and Video but is perhaps a bit short on built in customizable ports.

I don’t know the selection criteria VK5JST used for the PICAXE but it does illustrate a very simple solution that is adequate for its purpose. The fact that several hams have updated and modified the software says something about its complexity as well. Since this particular microcontroller will provide PWM motor control, it should also be adaptable to manipulate capacitors in a tuner, for instance. The antenna analyzer is a good example of just what you can do.