diff --git a/nanovna.h b/nanovna.h index a915f55..9e7dba2 100644 --- a/nanovna.h +++ b/nanovna.h @@ -676,6 +676,7 @@ float get_level_offset(void); extern uint8_t in_selftest; extern int display_test(void); +extern void clear_marker_cache(void); // // Shell config functions and macros diff --git a/plot.c b/plot.c index 54b8698..f93b756 100644 --- a/plot.c +++ b/plot.c @@ -280,9 +280,20 @@ index_to_value(const int i) return(value(actual_t[i])); } #endif + +float marker_cache[MARKERS_MAX]; +bool marker_cache_valid[MARKERS_MAX]; +void +clear_marker_cache(void) +{ + for (int i = 0; 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(actual_rbw_x10*100.0) * (10.0/logf(10.0)) + 173.93 + SI4463_noise_correction_x10/10.0; // measured noise figure at 20C + float mNF = aNP + 173.93 - nf_gain; // measured noise figure at 20C 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(nf_gain/10 * logf(10)); + float mnf = expf(mNF/10.0 * logf(10)); // measure noise factor + float tnf = expf(config.noise_figure/10.0 * logf(10.0)); // tinySA noise factor + float amp_gain = expf(nf_gain/10.0 * logf(10.0)); float anf = mnf - (tnf - 1.0)/amp_gain; - mNF = 10*logf(anf)/logf(10); + mNF = 10.0*logf(anf)/logf(10.0); } // powf(10,x) = expf(x * logf(10)) // log10f(x) = logf(x)/logf(10) diff --git a/sa_core.c b/sa_core.c index a65e3a2..8be6432 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3320,7 +3320,7 @@ again: // Spur redu } set_freq(ADF4351_LO, target_f); #if 1 // Compensate frequency ADF4350 error with SI4468 - if (actual_rbw_x10 < 3000 || setting.frequency_step < 100000) { + if (actual_rbw_x10 < 10000 || setting.frequency_step < 100000) { int32_t error_f = 0; if (real_old_freq[ADF4351_LO] > target_f) { error_f = real_old_freq[ADF4351_LO] - target_f; @@ -3588,11 +3588,13 @@ again: // Spur redu my_step_delay = my_step_delay * 2; // if (LO_shifted) // || SI4463_offset_changed) // my_step_delay = my_step_delay * 2; +#if 0 // Always have some delay before measuring RSSI if (old_R < 4 && actual_rbw_x10 >= 1000 && SI4463_frequency_changed && ADF4351_frequency_changed) { my_step_delay -= 200; // compensate for additional delay of setting SI4463 if (my_step_delay < 0) my_step_delay = 0; } +#endif my_microsecond_delay(my_step_delay * (old_R > 5 ? 8 : (old_R > 3 ? 2 : 1))); ADF4351_frequency_changed = false; SI4463_frequency_changed = false; @@ -3738,7 +3740,7 @@ static bool sweep(bool break_on_operation) float vbw_rssi; #endif #endif - + clear_marker_cache(); again: // Waiting for a trigger jumps back to here setting.measure_sweep_time_us = 0; // start measure sweep time // start_of_sweep_timestamp = chVTGetSystemTimeX(); // Will be set in perform diff --git a/ui_sa.c b/ui_sa.c index ba7b1ec..530f399 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1347,7 +1347,7 @@ 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; // Not tracking + markers[0].mtype = M_NOISE | M_AVER; // Not tracking set_extra_lna(true); kp_help_text = "Amplifier Gain "; float old_gain = setting.external_gain;