DiSlord / NanoVNA-D

Firmware for NanoVNA, NanoVNA-H, NanoVNA-H4. Support SD Card, external Serial connection, fast measure, fast exchange vs CPU
277 stars 63 forks source link

Raw s21 phase at low frequencies #81

Open owenduffy opened 1 month ago

owenduffy commented 1 month ago

I am using NanoVVNA-H4 v4.3 and firmware v1.2.30. I expected that raw (ie uncorrected) s21 phase would be close to 0°.

nanovnah4_20240608_132439i

Instead, it is close to 180°.

Looking at the schematic:

Screenshot-240528110137

The polarity of Port 2 connection to the mixer is opposite to Port 1 which I assume needs to be undone in the firmware... but is it?

Owen

DiSlord commented 1 month ago

Yes, measure S21 L/R pins swapped on AIC codec input, not possible change this by software Need swap RAW data, but this need more processor time Anyway this fixed by calibration

owenduffy commented 1 month ago

... Looking at the schematic: ... The polarity of Port 2 connection to the mixer is opposite to Port 1 which I assume needs to be undone in the firmware... but is it?

Rechecking the schematic, the polarity of the signal path for mixers U6 and U8 appear correct, yet measurement of raw s21 saved by the firmware is of opposite phase to that expected as in the screenshot.

Nevertheless, raw s21 is opposite phase to expected as show in the screenshot.

Yes, correction masks the problem... but if one wants to extract raw measurements to correct elsewhere, then all the s21 figures have to been inverted to make sense.

So the question is why is s21 inverted, and it seems as I understand it, the fix involves multiplying the raw Port 2 measurement complex value by -1, so real and imaginary parts each *-1... or undoing where they are incorrectly inverted in the current firmware?

The discussion at An experiment with NanoVNA and series through impedance measurement shows that the 'corrected s21' from the firmware is flawed which leads to the reported values of series through R and X being wrong.

Owen

DiSlord commented 1 month ago

I double-checked everything and didn't find any errors. Measurements of S11 and S21 take place along the same path, the inputs are switched in the audio codec. Reference channel IN2 is always connected to the left channel of the codec, and IN1 (reflected signal) to the right, alternately with IN3 (THRU)

At the same time, when changing channel 1, there are no problems with the phase, but in channel 3 it is rotated 180 degrees, as if the differential inputs R and L were reversed. There is no way to programmatically connect them differently

owenduffy commented 1 month ago

Thanks for the checking.

Let me try to explain the schematic given earlier.

Let's look at the AC voltage applied to mixer U6 (call it Vs), pin A is high, pin B is low so Va-Vb is approximately in phase with the CLK1 voltage.

Let's put a short on the TX jack, so the AC voltage on mixer U7 (call it Vr) pin B is low and pin A is high... so Va-Vb is approximately in phase with the CLK1 voltage.

Now this Vr is in phase with Vs, so to correctly calculate s11 (which is -ve for a short), the code must calculate -Vr/Vs. (The raw s11 saved to a .s1p file for short is correctly a -ve value.) Somewhere s11 calculation must include an inversion, as you note it is not in the schematic.

Now look at mixer U8 used for s21. Va-Vb is approximately in phase with RX voltage, and in phase with TX voltage and CLK1 if Port 1 is connected to Port 2 with a very short cable... so no inversion is required to calculate s21.

Perhaps what is happening is that both s11 and s21 calcs invert when only the s11 should invert (ie multiply by -1) and s21 should be non-inverting?

owenduffy commented 1 month ago

It appears that this is fixed in v1.2.32???

Thanks.

Owen

franciscosalvat commented 3 weeks ago

where do I download version 1.32? I only see 1.2.29, thanks

Ho-Ro commented 2 weeks ago

The latest released version from April 8th is still at 1.2.29.

To get the very latest version you should build it on your own. Just follow the instructions of the README.md. The current GitHub version, i.e. at the time of writing this comment, is

#define VERSION "1.2.36"

If you do not need the bleeding edge you can download the FW from my repo where I provide quite recent builds from DiSlord's original FW, you can get e.g. NanoVNA-H.bin and NanoVNA-H4.bin as well as *.hex. and *.dfu files - on the main page left click on the file name

image

and select Download on the next page

image

Currently at 1.2.33, will be updated during the next few days.

And if you have an older -H without SD card you can use my modified FW that supports 8 calibration slots instead of the 5 original ones - current build is from DiSlord's latest version 1.2.36.

franciscosalvat commented 2 weeks ago

thank you