NanoVNA setup for common antenna system measurement tasks – scripting the setup

NanoVNA setup for common antenna system measurement tasks showed a display configuration better suited to those tasks.

It is tedious to set the display up using the device menu, and setups may vary with different NanoVNA hardware and firmware.

The firmware I used was NanoVNA.H.v1.2.20 which allows some setup using serial port commands. This article describes the technique.

The command used is the trace command

trace {0|1|2|3|all} [logmag|phase|delay|smith|polar|linear|swr|real|imag|r|x|z|zp|g|b|y|rp|xp|sc|sl|pc|pl|q|rser|xser|zser|rsh|xsh|zsh|q21] [src]
trace {0|1|2|3} [lin|log|ri|rx|rlc|gb|glc|rpxp|rplc|rxsh|rxser]
trace {0|1|2|3} {scale|refpos} {value}

For this exercise, I used Teraterm5 which allows setting delays after each character and after each line so that the NanoVNA is not overrun.

Above, the Teraterm serial port setup.

The commands to perform the setup follow, they can be pasted into teraterm in one go,

trace 0 swr s11
trace 0 scale 0.2
trace 0 refpos 0
trace 1 smith s11
trace 1 rx
trace 1 scale 1
trace 1 refpos 0
trace 2 r s11
trace 2 scale 20
trace 2 refpos 0
trace 3 x s11
trace 3 scale 20
trace 3 refpos 4

Here is capture of the console session.

NanoVNA Shell
ch> trace 0 swr s11
ch> trace 0 scale 0.2
ch> trace 0 refpos 0
ch> trace 1 smith s11
ch> trace 1 rx
ch> trace 1 scale 1
ch> trace 1 refpos 0
ch> trace 2 r s11
ch> trace 2 scale 20
ch> trace 2 refpos 0
ch> trace 3 x s11
ch> trace 3 scale 20
ch> trace 3 refpos 4
ch> trace
0 SWR S11 0.200000000 0.000000000
1 SMITH S11 1.000000000 0.000000000
2 R S11 20.000000000 0.000000000
3 X S11 20.000000000 4.000000000

In this firmware, display settings are saved as part of the calibration data, so if the instrument is setup full (incl calibration) when you run the above script, you could save it to slot 6 with the “save 6” command.

The original / default trace setup follows.

ch> trace
0 LOGMAG S11 10.000000000 7.000000000
1 LOGMAG S21 10.000000000 7.000000000
2 SMITH S11 1.000000000 0.000000000
3 PHASE S21 90.000000000 4.000000000

This may or may not work on other versions of hardware and firmware, try it entirely at your own risk.