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!

Post a Comment