K4cal by N6TV

Change Log:
   2020-11-07 - 0.94 - Initial release of compiled Windows .exe version
   2020-11-12 - 0.95 - Save report to file with S/N and Date Timestamp (tnx N6XI)
   2020-11-20 - 0.96 - Use SN; command to get 5-digit radio serial no. instead of ME33;
                       (tnx W6FVI)
   2020-02-05 - 0.97 - Hold TUNE for 4 seconds instead of 1.25 seconds to allow more time
                       for power to settle
                     - Increase read timeouts
                     - Use new PCX; command (Ksrv 1146 or later) to query current
                       power level
                     - Calibration frequency changes
                       1850 kHz instead of 1900 kHz
                       28500 kHz insteads of 29000 kHz
   2021-03-19 - 0.98 - Instead of 4 second fixed tune, Sample power every 400 ms after
                       key down, up to 20 samples, stopping
                       when there are four consecutive identical samples in range.
                     - Bypass ATU during tune, restore upon completion.
                     - Test SWR after every band change.  Terminate calibration if
                       SWR higher than 1.5:1.


This Zip file contains a both a Windows.exe file and the Python source code.  Extract
to create or update a directory named K4Cal below the target, with all required files.

K4Cal will perform a 5W and 50W TX Gain Calibration on any K4 attached to the LAN, 
for all bands 160m to 6m.

When complete, it generates a report showing the old and new TX Gain Cal values, similar
to this:

TX Gain Calibration report for K4 S/N 00008 - 2021-03-19 07:50 UTC

  Freq   Old 5W Gain   New 5W Gain      5W Delta  Old 50W Gain  New 50W Gain     50W Delta
  1850           334           333            -1           107           107             0
  3750           229           228            -1            58            58             0
  5336           209           210             1            48            48             0
  7150           206           206             0            45            45             0
 10125           212           213             1            45            46             1
 14200           239           240             1            57            57             0
 18110           259           259             0            14            14             0
 21200           378           380             2            21            21             0
 24930           704           706             2            26            26             0
 28500           666           665            -1            36            36             0
 52000          1824          1824             0           344           347             3

k4cal.py version 0.98 by N6TV

The report is written to a file named:

   K4 xxxxx Gain Cal YYYYMMDD HHMMz.txt

where "xxxxx" is the K4 serial no. and "YYMMDD HHMM" is the UTC timestamp.

The executable version will run on Windows without requiring further prerequisites.

The Python version (source code supplied) will run on Windows, Mac, or Linux if Python 2.7
is available.  It will NOT run with Python 3.x.  Type

   python -V

at a command prompt to display the current version of Python installed on your system.

To install the Python 2.7 intpreter (optional on Windows), go to

   https://www.python.org/downloads/release/python-2716/

and download and run the appropriate installer:

   "Windows x86-64 MSI Installer"  (64-bit Windows)
   "Windows x86 MSI installer" (32-bit Window)
   "macOS 64-bit installer"
   "macOS 64-bit/32-bit installer"

Syntax to run Windows executable:
   k4cal [IP-address] [Dummy-Ant-Port] [debug]

Windows exectuable example:
   k4cal ?
   k4cal 10.0.0.44
   k4cal 10.0.0.44 2                    
   k4cal 10.0.0.44 2 debug              

You can double-click on k4cal.exe in Windows Explorer, and this will open a command
window and prompt for the K4 IP address and dummy load port number, or you can create
a Windows shortcut with or without arguments.

Syntax to run from Python source if Python 2.7 interpretor installed:
   python k4cal.py [IP-address] [Dummy-Ant-Port] [debug]

Mac or Linux example:
   python k4cal.py ?
   python k4cal.py 10.0.0.44
   python k4cal.py 10.0.0.44 2
   python k4cal.py 10.0.0.44 2 debug

- or -

Open a Windows command prompt:
  Windows Key + R (run):  cmd.exe

Windows command line examples:

   k4cal.py ?
   k4cal.py 10.0.0.44
   k4cal.py 10.0.0.44 2
   k4cal.py 10.0.0.44 2 debug

These arguments can also be added to a Windows shortcut.

73,
Bob, N6TV
n6tv@arrl.net
19 March 2021 07:54 UTC
