Serial Commands for AVNA
28 April 2017, updated 12 April 2018.  Still needs more information, in places.

Commands are entered by the USB serial link to the Teensy 3.6 board. The Teensy appears to the Host computer as a "Serial Device."  As such, it can be controlled by an external progtram for graphing and the like.  For manual control, the "Arduino Serial Monitor" that is accessed from the Arduino IDE under the menu “Tools” is useful.  This monitor (terminal) supports CTRL-C copy and data can be gathered that way.

The format for all commands going to the AVNA is 
    CMD param1 param2 …
where CMD is 1 or more characters, and the number of parameters varies.  Only capital letters are valid for the CMD field. Error checking is not done on parameters.  If 5 parameters are allowed, and only the first two are to be set, the last 3 do not need to be sent.  Also the delimiter is shown as a space, but commas can be used as well.   For common commands used for manual entry, there are single character short cuts.  For instance FREQ and F are equivalent.  Available commands:

ZMEAS refR
Z refR              Both set the measurement to Impedance, and the reference resistor value to refR.  Valid refR values are 50 and 5000.

TRANSMISSION refR
T refR             Both set the measurement to Transmission, and the reference resistor value to refR.  Valid refR values are 50 and 5000.

FREQ  f
F f                 Both set the measurements to a single (non-sweep) frequency. The frequency is set to f which can be either a integer or decimal number from 10 to 40000.   The parameter f regards 100.0 and 100 as the same.  The achieved frequency may be slightly different than f to provide proper averaging of the multiplier outputs. 

SWEEP   No parameters are used.  The 13 frequency sweep is set up, but not run (see RUN command).

CAL
C    No parameters are required.  This is an immediate calibrate of either Z or T measurements at either a single frequency or all 13 sweep frequencies.  This must follow FREQ-or-SWEEP and ZMEAS-or-TRANSMISSION to do the proper calibrate.  It must precede RUN.  Note that component connections can be left in place for CAL of impedance measurements, but transmission measurements need a reference path for Cal.

RUN nRun
R nRun        Both cause the selected measurement to occur, either single frequency or a full set of swept measurements.  The parameter, nRun, is the number of measurement sets made.  An nRun value of 0 causes a continuous set of measurements to be made.  That is, “R 1” is a single measurement set,  “R 27” does 27 sets and stops.  Any new command will break the R command, so “R 0” is not really forever.

POWER No parameters are required.  This is a power sweep of transmission measurements at a single frequency.  Implementation is in place, although not thoroughly tested.  Documentation is coming.

SAVE   No parameters are required.  This saves the current state to EEPROM for the next power down.  This is seldom needed, as it is automatic if a parameter, such as the reference impedance is changed.

LOAD   No parameters are required.  Complements SAVE and retrieves settings from EEPROM.  Also seldom needed.

DELAY msDelay   sets a delay between repeated runs (see RUN command).  The parameter msDelay is the amount of delay in milliseconds.  This applies to measurements over the serial link and not the touch display.

CALDAT  Not used at this time.

SERPAR ser par   Sets type of output data for Z meas
    ser sets serial output, par sets parallel output choice     see the .INO



TEST  rys sws     Sets the three relays and switches .  This is not normally used for measurements, as the proper relay settings will be made by a measurement command, such as ZMEAS.  see TestCommand()  in the .INO

PARAM1 num refR50 refR5K
An example is  "PARAM1 0 50.22 5017.3" where the '0' means "no default."  Set to the number 99 and ALL EEPROM values will be set to the  defaults.  For this reset, the next two parameters are ignored, and are not required.   A value 0 causes the reference resistor values to be set to the two parameter values.   PARAM1 with no following parameters  returns the current two reference resistor values.

PARAM2 capInput resInput capCouple seriesR seriesL  
Serves the changing of correction factors for the impedance measurements.
 For instance,
             "PARAM2 37.0  1000000.0    0.22    0.07   20.0"
 With units              pF      Ohm        uF      Ohm    nH
 sets the input shunt capacity, the shunt resistance, the coupling cap, lead resistance and lead inductance.
Note capInput is the most likely item to change, and it can be changed with simply "PARAM2 34.8"
To obtain current values, type  PARAM2  with no parameters
 
TUNEUP// Tuneup is used at setup time, or whenever parameters need to be checked.  These are
// the values that correct for circuit "stray" components to improve the accuracies at
// impedances near the extreme values.  This is available only over the serial port and
// is directed manually, since components, opens and shorts need to be connected.
// NOTE:  This is EXPERIMENTAL. In general, the results are better by using externally
// calculated values, except especially Cin.  Use this command with care and remember that
// default values are available from "PARAM1 99".

BAUD   Do not use.  All USB communications on USB is at 12 MBits/sec

ANNOTATE 0 or 1.  Responses can have annotation (1) or not (0), over the serial communication.

VERBOSE 0 or 1.  For (1), extra information is transmitted.

EXAMPLE of COMMANDS
As an example, a swept measurement of transmission data, as commanded for non-manual use, might look like following.  This does 1 Hz steps from 950 to 1050 Hz.  Obviously, the F xxx R 1 repetition would be done by a loop in a control program.

T 50
SWEEP
CAL
(Connect device to be measured for transmission)
F 950
R 1
F 951
R 1
F 952
R 1
. . .
F 1049
R 1
F 1050
R 1



