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 http://pa0fri.home.xs4all.nl/Diversen/VK5JST/Ant%20analyzereng.htm
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 @ leipper.org