From c61f9d46d1f7bca3561c058f87fba23a659f43e6 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Thu, 2 Jul 2020 21:30:42 +0300 Subject: [PATCH 1/5] Fix apply additional delays twice in some cases --- sa_core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sa_core.c b/sa_core.c index e29cf17..8b2d862 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1642,13 +1642,14 @@ sweep_again: // stay in sweep loop when output mo RSSI = perform(break_on_operation, i, frequencies[i], setting.tracking); // Measure RSSI for one of the frequencies - // ----------------- delay between points if needed ---------------- - - if (setting.additional_step_delay_us && (MODE_INPUT(setting.mode) || setting.modulation == MO_NONE)) { // No delay when modulation is active - if (setting.additional_step_delay_us < 30*ONE_MS_TIME) // Maximum delay time using my_microsecond_delay - my_microsecond_delay(setting.additional_step_delay_us); - else - osalThreadSleepMilliseconds(setting.additional_step_delay_us / ONE_MS_TIME); + // Delay between points if needed, (all delays can apply in SI4432 fill) + if (setting.measure_sweep_time_us == 0){ + if (setting.additional_step_delay_us && (MODE_INPUT(setting.mode) || setting.modulation == MO_NONE)) { // No delay when modulation is active + if (setting.additional_step_delay_us < 30*ONE_MS_TIME) // Maximum delay time using my_microsecond_delay + my_microsecond_delay(setting.additional_step_delay_us); + else + osalThreadSleepMilliseconds(setting.additional_step_delay_us / ONE_MS_TIME); + } } // if break back to top level to handle ui operation From b0611b4951e4385fb4289f28d9f77614039040d4 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Thu, 2 Jul 2020 22:58:54 +0300 Subject: [PATCH 2/5] Improved responsiveness of the UI interface. Now if the scan time is more than 100ms, a cycle is used in which you can interrupt the processing of user input --- sa_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sa_core.c b/sa_core.c index 8b2d862..1322aa0 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1497,7 +1497,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M skip_LO_setting: // jump here if in zero span mode and all HW frequency setup is done. #ifdef __FAST_SWEEP__ - if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && setting.spur == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < ONE_SECOND_TIME) { + if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && setting.spur == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) { // if ultra fast scanning is needed prefill the SI4432 RSSI read buffer SI4432_Fill(MODE_SELECT(setting.mode), 0); } From 9e44a08b3fa184ab0494a72719dc5257e42a6270 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Thu, 2 Jul 2020 23:58:16 +0300 Subject: [PATCH 3/5] Fixes for time calculation at 1 step, now in most cases correct timings found after 1 sweep (skip start init delays) Sweep time start calculate at 1 data get Correction delays apply for every point so need divide on sweep_points (fix my mistake) --- sa_core.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sa_core.c b/sa_core.c index 1322aa0..4713e3b 100644 --- a/sa_core.c +++ b/sa_core.c @@ -172,14 +172,14 @@ uint32_t calc_min_sweep_time_us(void) // Estimate minimum sweep time in if (MODE_OUTPUT(setting.mode)) t = 100; else { - uint32_t bare_sweep_time = (SI4432_step_delay + MEASURE_TIME) * (sweep_points - 1); // Single RSSI delay and measurement time in uS while scanning + uint32_t bare_sweep_time = (SI4432_step_delay + MEASURE_TIME) * (sweep_points); // Single RSSI delay and measurement time in uS while scanning if (FREQ_IS_CW()) { bare_sweep_time = MINIMUM_SWEEP_TIME; // minimum sweep time in fast CW mode - if (setting.repeat != 1 || setting.sweep_time_us >= ONE_SECOND_TIME || setting.spur != 0) // if no fast CW sweep possible + if (setting.repeat != 1 || setting.sweep_time_us >= 100*ONE_MS_TIME || setting.spur != 0) // if no fast CW sweep possible bare_sweep_time = 15000; // minimum CW sweep time when not in fast CW mode } t = vbwSteps * (setting.spur ? 2 : 1) * bare_sweep_time ; // factor in vbwSteps and spur impact - t += (setting.repeat - 1)* REPEAT_TIME * (sweep_points - 1); // Add time required for repeats + t += (setting.repeat - 1)* REPEAT_TIME * (sweep_points); // Add time required for repeats } return t; } @@ -1285,7 +1285,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M dirty = false; if (setting.spur) // if in spur avoidance mode setting.spur = 1; // resync spur in case of previous abort - start_of_sweep_timestamp = chVTGetSystemTimeX(); // initialize again to eliminate time spend in apply_settings +// start_of_sweep_timestamp = chVTGetSystemTimeX(); // initialize again to eliminate time spend in apply_settings } if (setting.mode == M_GENLOW && setting.level_sweep != 0.0) { // if in low output mode and level sweep is active @@ -1526,6 +1526,9 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M correct_RSSI = get_level_offset()+ get_attenuation() - signal_path_loss - setting.offset + get_frequency_correction(f); // calcuate the RSSI correction for later use wait: + if (i == 0) // if first point in scan (here is get 1 point data) + start_of_sweep_timestamp = chVTGetSystemTimeX(); // initialize start sweep time + subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)) + correct_RSSI ; // Get RSSI, either from pre-filled buffer or by reading SI4432 RSSI // if ( i < 3) // shell_printf("%d %.3f %.3f %.1f\r\n", i, local_IF/1000000.0, lf/1000000.0, subRSSI); @@ -1535,7 +1538,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M break; // abort if (subRSSI < setting.trigger_level) // trigger level not yet reached goto wait; // get next rssi - start_of_sweep_timestamp = chVTGetSystemTimeX(); // Actually one sample to late +// start_of_sweep_timestamp = chVTGetSystemTimeX(); // Actually one sample to late #ifdef __FAST_SWEEP__ if (i == 0 && setting.frequency_step == 0 /* && setting.trigger == T_AUTO */&& setting.spur == 0 && old_actual_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < ONE_SECOND_TIME) { @@ -1597,12 +1600,10 @@ again: // Waiting for a trigger jumps back to here calculate_step_delay(); // Set for actual time pre calculated value (update after sweep) setting.actual_sweep_time_us = calc_min_sweep_time_us(); - // Possible situation then old time > recommend time, i don`t know user input this value or this is old value - // Need add flag for auto time set? - // Fix me here | - // V + // Change actual sweep time as user input if it greater minimum + // And set start delays for 1 run if (setting.sweep_time_us > setting.actual_sweep_time_us){ - setting.additional_step_delay_us = (setting.sweep_time_us - setting.actual_sweep_time_us)/(sweep_points-1); + setting.additional_step_delay_us = (setting.sweep_time_us - setting.actual_sweep_time_us)/(sweep_points); setting.actual_sweep_time_us = setting.sweep_time_us; } else{ // not add additional correction, apply recommend time @@ -1795,14 +1796,14 @@ sweep_again: // stay in sweep loop when output mo static uint32_t last_dt = 0; // selected time less then actual, need reduce delay if (setting.sweep_time_us < setting.actual_sweep_time_us){ - dt = (setting.actual_sweep_time_us - setting.sweep_time_us)/(sweep_points - 1); + dt = (setting.actual_sweep_time_us - setting.sweep_time_us)/(sweep_points); if (setting.additional_step_delay_us > dt) setting.additional_step_delay_us-=dt; else setting.additional_step_delay_us = 0; }// selected time greater then actual, need increase delay else if (setting.sweep_time_us > setting.actual_sweep_time_us){ - dt = (setting.sweep_time_us - setting.actual_sweep_time_us)/(sweep_points - 1); + dt = (setting.sweep_time_us - setting.actual_sweep_time_us)/(sweep_points); setting.additional_step_delay_us+=dt; } // Update info on correction on next step, after apply . Always show when changed From 9fad7306645e2d9d0ca35a10a454b558cd2449dc Mon Sep 17 00:00:00 2001 From: DiSlord Date: Fri, 3 Jul 2020 00:28:25 +0300 Subject: [PATCH 4/5] More correct detect start time (for vbw) --- sa_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sa_core.c b/sa_core.c index 4713e3b..d806ee6 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1526,7 +1526,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M correct_RSSI = get_level_offset()+ get_attenuation() - signal_path_loss - setting.offset + get_frequency_correction(f); // calcuate the RSSI correction for later use wait: - if (i == 0) // if first point in scan (here is get 1 point data) + if (i == 0 && t == 0) // if first point in scan (here is get 1 point data) start_of_sweep_timestamp = chVTGetSystemTimeX(); // initialize start sweep time subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)) + correct_RSSI ; // Get RSSI, either from pre-filled buffer or by reading SI4432 RSSI From 2073ae18b32e94138a231d24405c9a10b8fa800d Mon Sep 17 00:00:00 2001 From: DiSlord Date: Fri, 3 Jul 2020 07:13:44 +0300 Subject: [PATCH 5/5] Prevent scan data twice if trigger option set (1 scan - normal scan, second is trigger wait, amd new scan before) --- sa_core.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/sa_core.c b/sa_core.c index d806ee6..514ba33 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1496,8 +1496,15 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M skip_LO_setting: // jump here if in zero span mode and all HW frequency setup is done. + int wait_for_trigger = false; + int old_actual_step_delay = SI4432_step_delay; + if (i == 0 && setting.frequency_step == 0 && setting.trigger != T_AUTO) { // if in zero span mode and wait for trigger to happen and NOT in trigger mode + wait_for_trigger = true; // signal the wait for trigger + SI4432_step_delay = 0; // and ignore requested sweep time to be as fast as possible + } + #ifdef __FAST_SWEEP__ - if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && setting.spur == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) { + if (i == 0 && wait_for_trigger == 0 && setting.spur == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) { // if ultra fast scanning is needed prefill the SI4432 RSSI read buffer SI4432_Fill(MODE_SELECT(setting.mode), 0); } @@ -1513,22 +1520,18 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M else signal_path_loss = +7; // Loss in dB (+ is gain) - int wait_for_trigger = false; - int old_actual_step_delay = SI4432_step_delay; - if (i == 0 && setting.frequency_step == 0 && setting.trigger != T_AUTO) { // if in zero span mode and wait for trigger to happen and NOT in trigger mode - wait_for_trigger = true; // signal the wait for trigger - SI4432_step_delay = 0; // and ignore requested sweep time to be as fast as possible - } + float subRSSI; static float correct_RSSI; // This is re-used between calls if (i == 0 || setting.frequency_step != 0 ) // only cases where the value can change correct_RSSI = get_level_offset()+ get_attenuation() - signal_path_loss - setting.offset + get_frequency_correction(f); // calcuate the RSSI correction for later use - wait: - if (i == 0 && t == 0) // if first point in scan (here is get 1 point data) + // Start time after 1 data get and triggered + if (i == 0 && t == 0) // if first point in scan (here is get 1 point data) start_of_sweep_timestamp = chVTGetSystemTimeX(); // initialize start sweep time + wait: subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)) + correct_RSSI ; // Get RSSI, either from pre-filled buffer or by reading SI4432 RSSI // if ( i < 3) // shell_printf("%d %.3f %.3f %.1f\r\n", i, local_IF/1000000.0, lf/1000000.0, subRSSI); @@ -1538,10 +1541,12 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M break; // abort if (subRSSI < setting.trigger_level) // trigger level not yet reached goto wait; // get next rssi -// start_of_sweep_timestamp = chVTGetSystemTimeX(); // Actually one sample to late + + if (i == 0 && t == 0) // if first point in scan (here is get 1 point data) + start_of_sweep_timestamp = chVTGetSystemTimeX(); // update time after triggered #ifdef __FAST_SWEEP__ - if (i == 0 && setting.frequency_step == 0 /* && setting.trigger == T_AUTO */&& setting.spur == 0 && old_actual_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < ONE_SECOND_TIME) { + if (i == 0 && /* setting.frequency_step == 0 && setting.trigger == T_AUTO */&& setting.spur == 0 && old_actual_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) { SI4432_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer } #endif