From e0a6e9cb43a98544753ce87c04bcacf1719e1377 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 10 Mar 2021 17:33:51 +0100 Subject: [PATCH] Updated M_AM, auto calc of .cor factors and reduced autolevel for 300Hz --- main.c | 44 +++++++++++++++++++++++++++++++++++++++++--- sa_core.c | 2 +- ui_sa.c | 4 ++-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index d8baa66..67cd44d 100644 --- a/main.c +++ b/main.c @@ -1012,9 +1012,9 @@ config_t config = { .high_correction_frequency = { 10000, 100000, 200000, 500000, 50000000, 140000000, 200000000, 300000000, 330000000, 350000000 }, .high_correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 }, .setting_frequency_30mhz = 30000000, - .cor_am = -14, - .cor_wfm = -55, - .cor_nfm = -55, + .cor_am = 0, + .cor_wfm = 0, + .cor_nfm = 0, .ultra = false, .high_out_adf4350 = true, .ext_zero_level = 174, @@ -2966,6 +2966,44 @@ int main(void) chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL); +#ifdef TINYSA4 + reset_settings(M_LOW); + set_mode(M_GENLOW); + set_sweep_frequency(ST_CENTER, (freq_t)30000000); + set_sweep_frequency(ST_SPAN, (freq_t)0); + in_selftest = true; + + if (config.cor_am == 0) { + setting.modulation = MO_AM; + setting.modulation_frequency = 5000; + config.cor_am = 0; + perform(false,0, 30000000, false); + perform(false,1, 30000000, false); + config.cor_am = -(start_of_sweep_timestamp - (ONE_SECOND_TIME / setting.modulation_frequency))/8; + } + + if (config.cor_nfm == 0) { + setting.modulation = MO_NFM; + setting.modulation_frequency = 5000; + config.cor_nfm = 0; + perform(false,0, 30000000, false); + perform(false,1, 30000000, false); + config.cor_nfm = -(start_of_sweep_timestamp - (ONE_SECOND_TIME / setting.modulation_frequency))/8; + } + + if (config.cor_wfm == 0) { + setting.modulation = MO_WFM; + setting.modulation_frequency = 5000; + config.cor_wfm = 0; + perform(false,0, 30000000, false); + perform(false,1, 30000000, false); + config.cor_wfm = -(start_of_sweep_timestamp - (ONE_SECOND_TIME / setting.modulation_frequency))/8; + } + in_selftest = false; + reset_settings(M_LOW); +#endif + + while (1) { if (SDU1.config->usbp->state == USB_ACTIVE) { #ifdef VNA_SHELL_THREAD diff --git a/sa_core.c b/sa_core.c index 612ab10..148251b 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3374,7 +3374,7 @@ sweep_again: // stay in sweep loop when output mo #endif // -------------------------- auto attenuate ---------------------------------- #ifdef TINYSA4 -#define AUTO_TARGET_LEVEL -30 +#define AUTO_TARGET_LEVEL (actual_rbw_x10 >= 10 ? -30 : -40) #else #define AUTO_TARGET_LEVEL -25 #endif diff --git a/ui_sa.c b/ui_sa.c index c6dc22d..e625f36 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -987,7 +987,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) // break; span = uistat.value; #ifdef TINYSA4 -// set_RBW(span/300); + set_RBW((span * 5 / 50) / 100); #endif set_sweep_frequency(ST_SPAN, span * 5); // update_frequencies(); // To ensure markers are positioned right!!!!!! @@ -1014,7 +1014,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) ui_mode_keypad(KM_SPAN); if (uistat.value < 1000 || uistat.value > 10000) goto no_measurement; - set_RBW(uistat.value/100); + set_RBW(uistat.value/300); #else kp_help_text = "Modulation frequency: 1 .. 2.5kHz"; ui_mode_keypad(KM_SPAN);