#### Re: Quick compare with HP 8753C...

Jerry Gaffke

Fun puzzles.
Casual users just wanting to check an antenna or measure a filter
with their nanoVNA need not worry about these inner workings.

I mentioned the script from Jeff in posts 1307 and 1311, but scattering the conversation
across a bunch of threads is not going to help those making sense of it later.
I'll restate my questions from that other thread here, and add some stuff.

First off, exactly how does the Matlab script get used?
My best guess is than we record four Gamma measurements, one for each
of the three calibration standards plus one for our device under test (DUT).
These four vector quantities (magnitude and phase) go into the script
as arguments, the script returns the corrected Gamma (named Gcor) for the DUT.
The function consists of these three lines, everything else is comments:
function Gcor = Cal_Function(Goc,Gsc,Gzo,Gm)
Gcor = ((Goc - Gsc).*(Gm - Gzo))./(Gm.*Goc + Gm.*Gsc - 2*Goc.*Gsc -
2*Gm.*Gzo + Goc.*Gzo + Gsc.*Gzo);

If so, then that should be quite straightforward to implement.

I'm not familiar with matlab notaiton. This help page
https://www.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html
states that the ".*" operator is an element-wise multiply vs a matrix multiply.
My assumption was that the operators in the script are all operating on two
vector quantities meant to be used at a single frequency.
Is there more going on in that script, and each variable is an array of vectors?
Perhaps each position in those arrays corresponds to a specific frequency?
That would make perfect sense.

For those wishing to touch bottom in physical reality with a circuit analysis of the bridge,
https://www.mwrf.com/test-measurement/wheatstone-bridge-how-does-it-impact-vna-measurements
Equation 6 at the bottom of the second page shows how to find Gamma.

The next question is, how do we correct an S21 measurement?
My guess is that we would take a "Through" (S21) measurement
with a short cable from the TX port to the RX port of the VNA by finding
the vector ratio of the nanoVNA's reading at mixer U8 divided by
the reading at mixer U6. And then simply divide that calibration vector
into any subsequent S21 measurement of a DUT at that frequency.
(If constrained by hardware, better to multiply by the reciprocal.)

S21 measurements are probably not quite that simple, we are interested
in power measurements, and those mixers are reporting voltage (and phase).
And perhaps an S21 measurement involves both the U6 and U7 mixer readings
to find the power of the signal going out through the TX port, not just U6.
I have not yet figured that stuff out completely, though a basic circuit analysis

Jerry, KE7ER

On Fri, Aug 23, 2019 at 07:57 AM, Jeff Anderson wrote:
Thanks very much, Roger,

Dick Benson, my go-to VNA guru, just sent me the following Matlab script for a
single-port correction:

function Gcor = Cal_Function(Goc,Gsc,Gzo,Gm)
Gcor = ((Goc - Gsc).*(Gm - Gzo))./(Gm.*Goc + Gm.*Gsc - 2*Goc.*Gsc -
2*Gm.*Gzo + Goc.*Gzo + Gsc.*Gzo);

Gxyz = Gamma ( s11 )

Gcor = Corrected Gamma (function output)

Goc = Open Circuit Cal measurement
Gsc = Short Circuit Cal measurement
Gzo = Zo (50 ohm) Cal measurement

Gm = Uncorrected Measured Gamma (input)

Although looking significantly different from your equations, I wonder if
yours collapse down to the matlab equation if assuming A1, A2, and A3 are -1,
1, and 0, respectively. Will look at it further when I return.

- Jeff
I

Join nanovna-users@groups.io to automatically receive all group messages.