NanoVNA code analyze


 

Hello Guys
I have admired NanoVN's design from the very beginning and found it to be a beautiful platform to learn about radio related measurements (and dsp of course). Currently I analyze the code that performs signal analysis (dsp.c). Could anyone of you explain why the values in the dsp_process function are divided by 16 (what is purpose of this) and how to treat the values calculated by calculate_gamma function. I will be grateful for any explanations.


 

divided by 16
NanoVNA-H use Cortex M0 MCU and allow only 32 bit accumulator for processing. For prevent overflow values divided
H4 use hardware DSP and 64 bit accumulator

calculate_gamma function just divide complex reflect / reference and thru / reference and calculate S11 and S21


 

Thanks a lot DiSlord. This is a very valuable information. As a beginner, I am just gaining experience in signal processing (I know stm32 processors quite well).
I would like to ask about one more issue - namely, while examining the signals entering the tlv320ai system (specifically IN2L, IN2R),
I noticed that the intermediate frequency signal contains a constant component (behind the capacitor C22, C23).
Is this a deliberate procedure for the ADC converter in the tlv320ai system? This input (IN2L, IN2R) works as single-ended or differential mode?


 

Used differential mode codec input


 

Hi again, thanks to your tips!
could You explain how to understand value gamma as array? I'm try to calculate SWR using gamma[0] with this code:

float swr_m = (1 - (gamma[0]));
float swr_l = (1 + (gamma[0]));
float vswrCalc = swr_l / swr_m;
vswr = vswrCalc;

And for load 50 OHM calculate SWR is close to 1 (1.02), so seems ok. Without load calculate SWR is different from one. Please explain what's gamma[0] and gamma[1] and my calculation code SWR is ok.


 

Not understand where you get this code.

From plot.c
//**************************************************************************************
// LINEAR = |S|
//**************************************************************************************
static float linear(int i, const float *v) {
(void) i;
return vna_sqrtf(get_l(v[0], v[1]));
}

//**************************************************************************************
// SWR = (1 + |S|)/(1 - |S|)
//**************************************************************************************
static float swr(int i, const float *v) {
(void) i;
float x = linear(i, v);
if (x > 0.99f)
return INFINITY;
return (1 + x)/(1 - x);
}