Use ENBW in noise measurement

multi_trace
erikkaashoek 5 years ago
parent 37d1a3eafc
commit 3bd6159abe

@ -1443,7 +1443,12 @@ extern void si_fm_offset(int16_t offset);
extern bool ADF4351_frequency_changed;
extern bool SI4463_frequency_changed;
extern bool SI4463_offset_changed;
extern int32_t SI4463_ENBW_Hz;
extern int old_R;
extern float Si446x_get_temp(void);
#define ENBW_Hz SI4463_ENBW_Hz
#endif
#ifdef TINYSA3
#define ENBW_Hz actual_rbw_x10*100;
#endif
/*EOF*/

@ -1430,8 +1430,8 @@ static void trace_print_value_string( // Only used at one place
// *ptr2++ = 'N';
*ptr2++ = ' ';
if (mtype & M_NOISE){
// v-= log10f(actual_rbw_x10*100.0) * 10.0;
v-= logf(actual_rbw_x10*100.0) * (10.0/logf(10.0));
// v-= log10f(ENBW_Hz) * 10.0;
v-= logf(ENBW_Hz) * (10.0/logf(10.0));
}
// Not possible ???
if (v == -INFINITY){
@ -1546,7 +1546,7 @@ static void cell_draw_marker_info(int x0, int y0)
int ypos = 1 + (j/2)*(16) - y0;
cell_printf(xpos, ypos, FONT_b"DEPTH: %3d%%", depth);
} else if (setting.measurement == M_FM){
freq_t dev = markers[1].frequency + actual_rbw_x10 * 100; // Temp value to prevent calculation of negative deviation
freq_t dev = markers[1].frequency + ENBW_Hz; // Temp value to prevent calculation of negative deviation
if ( markers[2].frequency < dev)
break;
dev = ( markers[2].frequency - dev ) >> 1;
@ -1588,13 +1588,24 @@ static void cell_draw_marker_info(int x0, int y0)
break;
}
#ifdef __NOISE_FIGURE__
} else if (i>=2 && setting.measurement == M_NF && markers[0].enabled && setting.external_gain != 0 ) {
float mNF = marker_to_value(0) - logf(actual_rbw_x10*100.0) * (10.0/logf(10.0)) + 174; // measured noise figure at 18C
} else if (i>=2 && setting.measurement == M_NF && markers[0].enabled) {
float aNP = 0;
#if 1
for (int i =0; i < sweep_points; i++) {
aNP += actual_t[i];
}
aNP /= sweep_points;
#else
aNP = marker_to_value(0);
#endif
float mNF = aNP - logf(ENBW_Hz) * (10.0/logf(10.0)) + 173.93; // measured noise figure at 20C
if (setting.external_gain != 0) {
float mnf = expf(mNF/10 * logf(10)); // measure noise factor
float tnf = expf(config.noise_figure/10 * logf(10)); // tinySA noise factor
float amp_gain = expf(setting.external_gain/10 * logf(10));
float anf = mnf - (tnf - 1.0)/amp_gain;
float aNF = 10*logf(anf)/logf(10);
mNF = 10*logf(anf)/logf(10);
}
// powf(10,x) = expf(x * logf(10))
// log10f(x) = logf(x)/logf(10)
@ -1603,7 +1614,7 @@ static void cell_draw_marker_info(int x0, int y0)
// j = 1;
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
int ypos = 1 + (j/2)*(16) - y0;
cell_printf(xpos, ypos, FONT_b"NF: %4.1f", aNF);
cell_printf(xpos, ypos, FONT_b"NF: %4.1f", mNF);
break;
#endif
} else

@ -374,7 +374,7 @@ VNA_SHELL_FUNCTION(cmd_sweep_voltage)
VNA_SHELL_FUNCTION(cmd_nf)
{
if (argc != 1) {
shell_printf("usage: nr {value}\r\n"\
shell_printf("usage: nf {value}\r\n"\
"%f\r\n", config.noise_figure);
return;
}

@ -4493,7 +4493,7 @@ static volatile int dummy;
#endif
}
#ifdef __CHANNEL_POWER__
} else if (setting.measurement == M_CP || setting.measurement == M_SNR) { // ----------------CHANNEL_POWER measurement
} else if (setting.measurement == M_CP || setting.measurement == M_SNR || setting.measurement == M_NF) { // ----------------CHANNEL_POWER measurement
freq_t bw = get_sweep_frequency(ST_SPAN)/3;
int old_unit = setting.unit;
setting.unit = U_WATT;

@ -1517,25 +1517,27 @@ typedef struct {
const uint8_t *reg; // IF_BW(dwn3, ndec, filset)
int16_t RSSI_correction_x_10; // Correction * 10
int16_t RBWx10; // RBW in kHz
int32_t ENBW_Hz;
}RBW_t; // sizeof(RBW_t) = 8 bytes
static const RBW_t RBW_choices[] =
{
// BW register corr freq
{SI4463_RBW_02kHz, 15,3},
{SI4463_RBW_1kHz, 14,10},
{SI4463_RBW_3kHz, 10,30},
{SI4463_RBW_10kHz, 14,100},
{SI4463_RBW_30kHz, 0,300},
{SI4463_RBW_100kHz,0,1000},
{SI4463_RBW_300kHz,1,3000},
{SI4463_RBW_600kHz,11,6000},
{SI4463_RBW_850kHz,11,8500},
{SI4463_RBW_02kHz, 15,3,188},
{SI4463_RBW_1kHz, 14,10,1100},
{SI4463_RBW_3kHz, 10,30,3341},
{SI4463_RBW_10kHz, 14,100,10910},
{SI4463_RBW_30kHz, 0,300,32500},
{SI4463_RBW_100kHz,0,1000,106900},
{SI4463_RBW_300kHz,1,3000,342000},
{SI4463_RBW_600kHz,11,6000,640000},
{SI4463_RBW_850kHz,11,8500,877000},
};
const uint8_t SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t)));
static pureRSSI_t SI4463_RSSI_correction = float_TO_PURE_RSSI(-120);
int32_t SI4463_ENBW_Hz;
static int prev_band = -1;
pureRSSI_t getSI4463_RSSI_correction(void){
@ -1561,6 +1563,7 @@ uint16_t force_rbw(int f)
set_RSSI_comp();
// prev_band = -1;
SI4463_RSSI_correction = float_TO_PURE_RSSI(RBW_choices[f].RSSI_correction_x_10 - 1200)/10; // Set RSSI correction
SI4463_ENBW_Hz = RBW_choices[f].ENBW_Hz;
return RBW_choices[f].RBWx10; // RBW achieved by SI4463 in kHz * 10
}

@ -1346,10 +1346,15 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
case M_NF: // noise figure
// reset_settings(setting.mode);
markers[0].enabled = M_ENABLED;
markers[0].mtype = M_NOISE;
markers[0].mtype = M_NOISE; // Not tracking
set_extra_lna(true);
kp_help_text = "Amplifier Gain ";
ui_mode_keypad(KM_EXT_GAIN);
kp_help_text = "Noise frequency";
ui_mode_keypad(KM_CENTER);
set_marker_frequency(0, uistat.value);
kp_help_text = "Noise width";
ui_mode_keypad(KM_SPAN);
set_average(AV_100);
break;
#endif

Loading…
Cancel
Save

Powered by TurnKey Linux.