Sweep time calculation and delayed scale increase

tinySA-v0.2
erikkaashoek 6 years ago
parent be66fab7f6
commit 87555f8c3e

@ -580,6 +580,7 @@ typedef struct setting
float level; float level;
float level_sweep; float level_sweep;
float sweep_time; float sweep_time;
float actual_sweep_time;
int test_argument; int test_argument;
int auto_IF; int auto_IF;
uint32_t checksum; uint32_t checksum;

@ -117,7 +117,8 @@ void update_grid(void)
uint32_t grid; uint32_t grid;
if (fspan == 0) { if (fspan == 0) {
fspan = setting.sweep_time*1000000 + 25000; // Time in uS fspan = setting.actual_sweep_time; // Time in uS
fspan *= 1000;
fstart = 0; fstart = 0;
} }
@ -869,7 +870,7 @@ static void trace_get_value_string(
dfreq = frequencies[i]; dfreq = frequencies[i];
} }
if (FREQ_IS_CW()) { if (FREQ_IS_CW()) {
float t = ii*(setting.sweep_time*1000000 + 25000)/290; float t = ii*(setting.actual_sweep_time)*1000.0/290.0;
if (t>1000000.0){ if (t>1000000.0){
plot_printf(&buf2[1], sizeof(buf2) -1, "%4f" , t/1000000.0); plot_printf(&buf2[1], sizeof(buf2) -1, "%4f" , t/1000000.0);
buf2[5] = 'S'; buf2[5] = 'S';
@ -2147,7 +2148,7 @@ draw_frequencies(void)
#endif #endif
if (FREQ_IS_CW()) { if (FREQ_IS_CW()) {
plot_printf(buf1, sizeof(buf1), " CW %qHz", get_sweep_frequency(ST_CW)); plot_printf(buf1, sizeof(buf1), " CW %qHz", get_sweep_frequency(ST_CW));
float t = setting.sweep_time*1000.0 + 25.0; // in mS float t = setting.actual_sweep_time; // in mS
; // in mS ; // in mS
if (t>=1000) if (t>=1000)
plot_printf(buf2, sizeof(buf2), "%.2fS",t/1000.0); plot_printf(buf2, sizeof(buf2), "%.2fS",t/1000.0);
@ -2174,8 +2175,12 @@ draw_frequencies(void)
buf1[0] = S_SARROW[0]; buf1[0] = S_SARROW[0];
if (uistat.lever_mode == LM_SPAN) if (uistat.lever_mode == LM_SPAN)
buf2[0] = S_SARROW[0]; buf2[0] = S_SARROW[0];
int p2 = FREQUENCIES_XPOS2;
if (FREQ_IS_CW()) {
p2 = 320 - 7*strlen(buf2);
}
ili9341_drawstring(buf1, FREQUENCIES_XPOS1, FREQUENCIES_YPOS); ili9341_drawstring(buf1, FREQUENCIES_XPOS1, FREQUENCIES_YPOS);
ili9341_drawstring(buf2, FREQUENCIES_XPOS2, FREQUENCIES_YPOS); ili9341_drawstring(buf2, p2, FREQUENCIES_YPOS);
} }
#ifdef __VNA__ #ifdef __VNA__
void void

@ -123,8 +123,8 @@ float calc_min_sweep_time(void) // Calculate minimum sweep time in mS
float a = actualStepDelay + MEASURE_TIME; float a = actualStepDelay + MEASURE_TIME;
if (FREQ_IS_CW()) if (FREQ_IS_CW())
a = MINIMUM_SWEEP_TIME / 290; // time per step in CW mode a = (float)MINIMUM_SWEEP_TIME / 290.0; // time per step in CW mode
t = vbwSteps * sweep_points * (setting.spur ? 2 : 1) * ( (a + (setting.repeat - 1)* REPEAT_TIME) / 1000.0); t = vbwSteps * sweep_points * (setting.spur ? 2 : 1) * ( (a + (setting.repeat - 1)* REPEAT_TIME));
return t; return t;
} }
@ -1522,7 +1522,16 @@ again:
float r = value(temppeakLevel); float r = value(temppeakLevel);
if (!in_selftest && MODE_INPUT(setting.mode) && setting.auto_reflevel) { // Auto reflevel if (!in_selftest && MODE_INPUT(setting.mode) && setting.auto_reflevel) { // Auto reflevel
if (UNIT_IS_LINEAR(setting.unit)) { // Linear scales can not have negative values if (UNIT_IS_LINEAR(setting.unit)) { // Linear scales can not have negative values
if ((setting.reflevel > REFLEVEL_MIN && r < setting.reflevel / 2.5 ) || (setting.reflevel < REFLEVEL_MAX && r > setting.reflevel) ) { // ensure minimum and maximum reflevel static int low_count = 0;
if (setting.reflevel > REFLEVEL_MIN) {
if (r < setting.reflevel / 5)
low_count = 5;
else if (r < setting.reflevel / 2.5)
low_count++;
else
low_count = 0;
}
if ((low_count > 4) || (setting.reflevel < REFLEVEL_MAX && r > setting.reflevel) ) { // ensure minimum and maximum reflevel
// r = setting.scale * (floor(r / setting.scale) + 1); // r = setting.scale * (floor(r / setting.scale) + 1);
#if 0 #if 0
float m = 1; float m = 1;
@ -1855,13 +1864,14 @@ void draw_cal_status(void)
ili9341_set_foreground(color); ili9341_set_foreground(color);
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
#if 0
color = DEFAULT_FG_COLOR; color = DEFAULT_FG_COLOR;
ili9341_set_foreground(color); ili9341_set_foreground(color);
if (setting.auto_reflevel){ if (setting.auto_reflevel){
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
ili9341_drawstring("AUTO", x, y); ili9341_drawstring("AUTO", x, y);
} }
#endif
y += YSTEP + YSTEP/2 ; y += YSTEP + YSTEP/2 ;
plot_printf(buf, BLEN, "%s",unit); plot_printf(buf, BLEN, "%s",unit);
ili9341_drawstring(buf, x, y); ili9341_drawstring(buf, x, y);
@ -1961,6 +1971,7 @@ void draw_cal_status(void)
float t = calc_min_sweep_time(); float t = calc_min_sweep_time();
if (t < setting.sweep_time) if (t < setting.sweep_time)
t = setting.sweep_time; t = setting.sweep_time;
setting.actual_sweep_time = t;
if (t>=10000.0) if (t>=10000.0)
plot_printf(buf, BLEN, "%5d",(int)(t/1000)); plot_printf(buf, BLEN, "%5d",(int)(t/1000));
else if (t>=1000) else if (t>=1000)

@ -1806,7 +1806,11 @@ set_numeric_value(void)
break; break;
case KM_REFLEVEL: case KM_REFLEVEL:
set_auto_reflevel(false); set_auto_reflevel(false);
set_reflevel(uistat.value); if (uistat.value < setting.scale*NGRIDY) {
set_scale(uistat.value/NGRIDY);
set_reflevel(setting.scale*NGRIDY);
} else
set_reflevel(uistat.value);
break; break;
case KM_ATTENUATION: case KM_ATTENUATION:
setting.auto_attenuation = false; setting.auto_attenuation = false;

Loading…
Cancel
Save

Powered by TurnKey Linux.