When I last wrote about the Automatic Antenna Selector, I mentioned adding modes to select more antenna options. Getting that to work took some doing.
Test Mode
Holding down the mode button invokes test mode. When entered, it selects port A0. Tapping the mode button advances to port A1, A2, to A5, then it goes to B0, B1, to B5, then back to A0. In this way, all antenna / port combinations can be selected. This allows new antennas or conducting tests or experiments before a new configuration can be programmed.
The unit signals Test Mode with the mode LED being on continuously. Holding down the mode button again goes back to Standard Mode.
Standard Mode
Standard mode determines antenna selections according to the connected K3 BAND0-3 signals. When only one radio is connected, both ports are based on the current band for that radio. The first port is the primary, the second part gets the secondary selection. Tapping the mode button cycles through the secondary port selections, the primary port being unchanged.
When two radios are connected, port selections are based on the K3 BAND0-3 signal for both radios. Radio A gets the primary selection. Radio B gets its primary selection, unless that port conflicts with Radio A. It then gets the secondary selection (unless that also conflicts). Tapping the mode button cycles through the Radio B selections.
The unit signal Standard Mode with a mostly dark LED. Off completely for the primary selection, pulsing twice for secondary, three times for tertiary. At the moment, there are only three stages. Adding a fourth would be easy.
Easy in concept, but after the code changes, it didn't all work.
Test mode worked great. Entering and exiting were reliable, and each tap selected the correct port.
Standard mode, however, didn't seem to do anything. The LED indication showed the mode selected, but the port selection did not change. I had only implemented the single radio logic, since I couldn't find a second cable to connect a K3.
Debugging
Debugging this over the last couple of weeks was driving me mad. No matter what changes I made to the code, the behavior did not change. Further, I noticed that when the K3 was on 6m, port B was also selecting a dipole antenna. That was unexpected, as it wasn't a valid antenna for 6m.
Eventually, it dawned on me that this was not single-radio mode. For some reason, the selector believed there were two radios connected.
That was a revelation. I knew there was a problem when the K3 powered down. When no K3s are connected, the selector was supposed to deselect all relays. Instead, it had two dipoles selected.
This was connected with how Elecraft encoded the bands on the BAND0-3 pins. 60m is represented as all zeros. Even with the weak pull-ups enabled on the PIC, it wasn't enough to overcome the loading of the connected but powered-down K3.
The same problem was evident on the disconnected port -- it was registering 60m, which selected the dipole.
Fixing
The first fix was hardware. I added 2.2k pull-up resistors to the BAND0-3 pins on both ports. After that, the relays deactivated when the K3 was powered down. But, I still saw the dipole selecting coming up on 6m when switching models.
This was a software problem. One of the internal variables was initialized incorrect, which was the source of the 60m selection. When initialized correctly, single-radio Standard Mode selections worked as they should.
With that working, I'm full of new ideas for improving mode selections. Once I figure out which ideas are best, hopefully it will be a small matter of code changes....
No comments:
Post a Comment