diff --git a/nanovna.h b/nanovna.h index 647fa53..4f84bd0 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1190,6 +1190,7 @@ void clear_all_config_prop_data(void); extern void ui_init(void); extern void ui_process(void); int current_menu_is_form(void); +extern float nf_gain; void ui_mode_normal(void); void ui_mode_menu(void); diff --git a/plot.c b/plot.c index 83bd992..5a63cec 100644 --- a/plot.c +++ b/plot.c @@ -1602,10 +1602,10 @@ static void cell_draw_marker_info(int x0, int y0) aNP = marker_to_value(0); #endif float mNF = aNP - logf(actual_rbw_x10*100.0) * (10.0/logf(10.0)) + 173.93 + SI4463_noise_correction_x10/10.0; // measured noise figure at 20C - if (setting.external_gain != 0) { - float mnf = expf(mNF/10 * logf(10)); // measure noise factor + if (nf_gain != 0) { + float mnf = expf((mNF - nf_gain)/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 amp_gain = expf(nf_gain/10 * logf(10)); float anf = mnf - (tnf - 1.0)/amp_gain; mNF = 10*logf(anf)/logf(10); } @@ -1617,7 +1617,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", mNF); + cell_printf(xpos, ypos, FONT_b"GAIN: %4.1fdB NF: %4.1f", nf_gain, mNF); break; #endif } else diff --git a/sa_core.c b/sa_core.c index c73c695..a401b37 100644 --- a/sa_core.c +++ b/sa_core.c @@ -4780,7 +4780,7 @@ enum { #ifdef TINYSA4 //#define CAL_LEVEL -23.5 -#define CAL_LEVEL -23 +#define CAL_LEVEL -23.1 #else #define CAL_LEVEL (has_esd ? -26.2 : -25) #endif @@ -4833,8 +4833,8 @@ const test_case_t test_case [] = #define TEST_SPUR 23 TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 144, 8, -95, 0, 0), // 22 Measure 48MHz spur #define TEST_LEVEL 24 - TEST_CASE_STRUCT(TC_LEVEL, TP_30MHZ, 30, 0, CAL_LEVEL, 145, -55), // 23 Measure level - TEST_CASE_STRUCT(TC_LEVEL, TP_30MHZ_LNA, 30, 0, CAL_LEVEL, 145, -55), // 23 Measure level + TEST_CASE_STRUCT(TC_LEVEL, TP_30MHZ, 30.01, 0, CAL_LEVEL, 145, -55), // 23 Measure level + TEST_CASE_STRUCT(TC_LEVEL, TP_30MHZ_LNA, 30.01, 0, CAL_LEVEL, 145, -55), // 23 Measure level TEST_CASE_STRUCT(TC_LEVEL, TPH_30MHZ, 150, 0, CAL_LEVEL-30, 145, -55), // 23 Measure level }; diff --git a/si4468.c b/si4468.c index cca7a1a..8da173b 100644 --- a/si4468.c +++ b/si4468.c @@ -1524,14 +1524,14 @@ static const RBW_t RBW_choices[] = { // BW register corr freq {SI4463_RBW_02kHz, 18,3,42}, - {SI4463_RBW_1kHz, 18,10,22}, - {SI4463_RBW_3kHz, 12,30,21}, - {SI4463_RBW_10kHz, 7,100,20}, - {SI4463_RBW_30kHz, 10,300,20}, - {SI4463_RBW_100kHz,2,1000,26}, - {SI4463_RBW_300kHz,2,3000,19}, - {SI4463_RBW_600kHz,3,6000,18}, - {SI4463_RBW_850kHz,12,8500,15}, + {SI4463_RBW_1kHz, 18,10,29}, + {SI4463_RBW_3kHz, 12,30,28}, + {SI4463_RBW_10kHz, 7,100,26}, + {SI4463_RBW_30kHz, 10,300,22}, + {SI4463_RBW_100kHz,2,1000,19}, + {SI4463_RBW_300kHz,2,3000,7}, + {SI4463_RBW_600kHz,3,6000,-1}, + {SI4463_RBW_850kHz,12,8500,-9}, }; const uint8_t SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t))); diff --git a/ui_sa.c b/ui_sa.c index 4e48454..23c9c30 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1151,6 +1151,7 @@ static UI_FUNCTION_CALLBACK(menu_clearconfig_cb) ui_mode_normal(); } +float nf_gain; const char * const averageText[] = { "OFF", "MIN", "MAX", "MAXD", " A 4", "A 16", "AVER", "QUASI", "DECONV"}; static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) @@ -1348,13 +1349,17 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) markers[0].mtype = M_NOISE; // Not tracking set_extra_lna(true); kp_help_text = "Amplifier Gain "; + float old_gain = setting.external_gain; ui_mode_keypad(KM_EXT_GAIN); - kp_help_text = "Noise frequency"; + nf_gain = setting.external_gain; + setting.external_gain = old_gain; + kp_help_text = "Noise center frequency"; ui_mode_keypad(KM_CENTER); set_marker_frequency(0, uistat.value); -// kp_help_text = "Noise width"; -// ui_mode_keypad(KM_SPAN); - set_sweep_frequency(ST_SPAN, 0); + kp_help_text = "Noise span"; + ui_mode_keypad(KM_SPAN); + set_RBW(get_sweep_frequency(ST_SPAN)/100 / 100); +// set_sweep_frequency(ST_SPAN, 0); set_average(AV_100); break; #endif