Sweep speed improvement and better sweep time calculation

tinySA-v0.2
erikkaashoek 6 years ago
parent 7a616786ca
commit be66fab7f6

@ -594,6 +594,9 @@ void reset_settings(int m);
#define S_IS_AUTO(x) ((x)&2) #define S_IS_AUTO(x) ((x)&2)
#define S_STATE(X) ((X)&1) #define S_STATE(X) ((X)&1)
enum { S_OFF=0, S_ON=1, S_AUTO_OFF=2, S_AUTO_ON=3 }; enum { S_OFF=0, S_ON=1, S_AUTO_OFF=2, S_AUTO_ON=3 };
#define MINIMUM_SWEEP_TIME 15 // Minimum sweep time on zero span in miliseconds
#define REPEAT_TIME 34.0 // Time per extra repeat in uS
#define MEASURE_TIME 175.0 // Time per vbwstep without stepdelay in uS
extern uint32_t frequencies[POINTS_COUNT]; extern uint32_t frequencies[POINTS_COUNT];
@ -827,6 +830,7 @@ void self_test(int);
void wait_user(void); void wait_user(void);
void calibrate(void); void calibrate(void);
float to_dBm(float); float to_dBm(float);
float calc_min_sweep_time(void);
enum { enum {
M_OFF, M_IMD, M_OIP3, M_PHASE_NOISE, M_STOP_BAND, M_PASS_BAND, M_LINEARITY M_OFF, M_IMD, M_OIP3, M_PHASE_NOISE, M_STOP_BAND, M_PASS_BAND, M_LINEARITY

@ -66,7 +66,7 @@ void reset_settings(int m)
set_sweep_frequency(ST_START, (uint32_t) 0); set_sweep_frequency(ST_START, (uint32_t) 0);
set_sweep_frequency(ST_STOP, (uint32_t) 350000000); set_sweep_frequency(ST_STOP, (uint32_t) 350000000);
setting.attenuate = 30; setting.attenuate = 30;
setting.sweep_time = 0.0; setting.sweep_time = 0;
break; break;
#ifdef __ULTRA__ #ifdef __ULTRA__
case M_ULTRA: case M_ULTRA:
@ -84,7 +84,7 @@ void reset_settings(int m)
maxFreq = 520000000; maxFreq = 520000000;
set_sweep_frequency(ST_CENTER, (int32_t) 10000000); set_sweep_frequency(ST_CENTER, (int32_t) 10000000);
set_sweep_frequency(ST_SPAN, 0); set_sweep_frequency(ST_SPAN, 0);
setting.sweep_time = 10.0; setting.sweep_time = 10000.0;
break; break;
case M_HIGH: case M_HIGH:
#ifdef __ULTRA_SA__ #ifdef __ULTRA_SA__
@ -96,7 +96,7 @@ void reset_settings(int m)
#endif #endif
set_sweep_frequency(ST_START, (int32_t) minFreq); set_sweep_frequency(ST_START, (int32_t) minFreq);
set_sweep_frequency(ST_STOP, (int32_t) maxFreq); set_sweep_frequency(ST_STOP, (int32_t) maxFreq);
setting.sweep_time = 0.0; setting.sweep_time = 0;
break; break;
case M_GENHIGH: case M_GENHIGH:
setting.drive=8; setting.drive=8;
@ -104,7 +104,7 @@ void reset_settings(int m)
maxFreq = 960000000; maxFreq = 960000000;
set_sweep_frequency(ST_CENTER, (int32_t) 300000000); set_sweep_frequency(ST_CENTER, (int32_t) 300000000);
set_sweep_frequency(ST_SPAN, 0); set_sweep_frequency(ST_SPAN, 0);
setting.sweep_time = 10.0; setting.sweep_time = 10000.0;
break; break;
} }
for (int i = 0; i< MARKERS_MAX; i++) { for (int i = 0; i< MARKERS_MAX; i++) {
@ -117,6 +117,18 @@ void reset_settings(int m)
dirty = true; dirty = true;
} }
float calc_min_sweep_time(void) // Calculate minimum sweep time in mS
{
float t;
float a = actualStepDelay + MEASURE_TIME;
if (FREQ_IS_CW())
a = MINIMUM_SWEEP_TIME / 290; // time per step in CW mode
t = vbwSteps * sweep_points * (setting.spur ? 2 : 1) * ( (a + (setting.repeat - 1)* REPEAT_TIME) / 1000.0);
return t;
}
void set_refer_output(int v) void set_refer_output(int v)
{ {
setting.refer = v; setting.refer = v;
@ -171,10 +183,10 @@ void set_level_sweep(float l)
void set_sweep_time(float t) void set_sweep_time(float t)
{ {
if (t < 0.0) if (t < MINIMUM_SWEEP_TIME)
t = 0.0; t = MINIMUM_SWEEP_TIME;
if (t > 600.0) if (t > 600000.0)
t = 600.0; t = 600000.0;
setting.sweep_time = t; setting.sweep_time = t;
dirty = true; dirty = true;
} }
@ -455,6 +467,13 @@ void toggle_LNA(void)
void toggle_tracking(void) void toggle_tracking(void)
{ {
setting.tracking = !setting.tracking; setting.tracking = !setting.tracking;
if (setting.tracking) {
set_refer_output(2);
set_sweep_frequency(ST_CENTER, 10000000);
set_sweep_frequency(ST_SPAN, 5000000);
} else {
set_refer_output(-1);
}
dirty = true; dirty = true;
} }
@ -602,12 +621,18 @@ void set_offset(float offset)
dirty = true; dirty = true;
} }
void show_stored_trace_at(float v)
{
for (int j = 0; j < setting._sweep_points; j++)
stored_t[j] = v;
trace[TRACE_STORED].enabled = true;
}
void set_trigger_level(float trigger_level) void set_trigger_level(float trigger_level)
{ {
setting.trigger_level = trigger_level; setting.trigger_level = trigger_level;
if (setting.trigger != T_AUTO) { if (setting.trigger != T_AUTO) {
for (int j = 0; j < setting._sweep_points; j++) show_stored_trace_at(setting.trigger_level);
stored_t[j] = trigger_level;
} }
dirty = true; dirty = true;
} }
@ -618,9 +643,7 @@ void set_trigger(int trigger)
if (trigger == T_AUTO) { if (trigger == T_AUTO) {
trace[TRACE_STORED].enabled = false; trace[TRACE_STORED].enabled = false;
} else { } else {
for (int j = 0; j < setting._sweep_points; j++) show_stored_trace_at(setting.trigger_level);
stored_t[j] = setting.trigger_level;
trace[TRACE_STORED].enabled = true;
} }
sweep_mode = SWEEP_ENABLE; sweep_mode = SWEEP_ENABLE;
dirty = true; dirty = true;
@ -1188,7 +1211,7 @@ again:
#endif #endif
if (MODE_INPUT(setting.mode) && i > 0 && FREQ_IS_CW()) if (MODE_INPUT(setting.mode) && i > 0 && FREQ_IS_CW())
goto skip_LO_setting; goto skip_LO_setting; // No LO changes during CW loop
if (setting.mode == M_LOW && tracking) { // Measure BPF if (setting.mode == M_LOW && tracking) { // Measure BPF
set_freq (0, setting.frequency_IF + lf - reffer_freq[setting.refer]); // Offset so fundamental of reffer is visible set_freq (0, setting.frequency_IF + lf - reffer_freq[setting.refer]); // Offset so fundamental of reffer is visible
@ -1288,7 +1311,10 @@ again:
actualStepDelay = 0; // fastest possible in zero span trigger mode actualStepDelay = 0; // fastest possible in zero span trigger mode
} }
float subRSSI; float subRSSI;
float correct_RSSI = get_level_offset()+ setting.attenuate - signal_path_loss - setting.offset + get_frequency_correction(f);
static float correct_RSSI = 0;
if (i == 0 || setting.frequency_step != 0 )
correct_RSSI = get_level_offset()+ setting.attenuate - signal_path_loss - setting.offset + get_frequency_correction(f);
wait: wait:
subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)) + correct_RSSI ; subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)) + correct_RSSI ;
// if ( i < 3) // if ( i < 3)
@ -1348,13 +1374,13 @@ again:
repeats = 1000; // to avoid interrupting the tone during UI processing repeats = 1000; // to avoid interrupting the tone during UI processing
modulation_counter = 0; modulation_counter = 0;
} }
float t = calc_min_sweep_time();
while (repeats--) { while (repeats--) {
for (int i = 0; i < sweep_points; i++) { for (int i = 0; i < sweep_points; i++) {
RSSI = perform(break_on_operation, i, frequencies[i], setting.tracking); RSSI = perform(break_on_operation, i, frequencies[i], setting.tracking);
if ( setting.sweep_time > t && !(MODE_OUTPUT(setting.mode) && setting.modulation != MO_NONE)) {
if ( setting.sweep_time > 0.0 && !(MODE_OUTPUT(setting.mode) && setting.modulation != MO_NONE)) { float s = (setting.sweep_time - t) * (1000.0 / 290.0);
float s = setting.sweep_time * (1000000.0 / 290.0);
if (s < 30000) if (s < 30000)
my_microsecond_delay((int)s); my_microsecond_delay((int)s);
else else
@ -1932,11 +1958,9 @@ void draw_cal_status(void)
ili9341_drawstring("Scan:", x, y); ili9341_drawstring("Scan:", x, y);
y += YSTEP; y += YSTEP;
float t = setting.sweep_time*1000.0 + 25.0 + (float)((2* vbwSteps * sweep_points * ( actualStepDelay / 100) )) /10 float t = calc_min_sweep_time();
#ifdef __SPUR__ if (t < setting.sweep_time)
* (setting.spur ? 2 : 1) t = setting.sweep_time;
#endif
; // in mS
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)

@ -365,7 +365,7 @@ static const short RBW_choices[] =
#endif #endif
}; };
static float SI4432_RSSI_correction = 0; static float SI4432_RSSI_correction = -120.0;
float SI4432_SET_RBW(float w) { float SI4432_SET_RBW(float w) {
uint8_t dwn3=0; uint8_t dwn3=0;
@ -378,7 +378,7 @@ float SI4432_SET_RBW(float w) {
ndec = RBW_choices[i-3]; ndec = RBW_choices[i-3];
fils = RBW_choices[i-2]; fils = RBW_choices[i-2];
WISH = RBW_choices[i-1]; // RBW achieved by Si4432 in Hz WISH = RBW_choices[i-1]; // RBW achieved by Si4432 in Hz
SI4432_RSSI_correction = RBW_choices[i]/10.0; SI4432_RSSI_correction = RBW_choices[i]/10.0 - 120.0;
uint8_t BW = (dwn3 << 7) | (ndec << 4) | fils ; uint8_t BW = (dwn3 << 7) | (ndec << 4) | fils ;
SI4432_Write_Byte(0x1C , BW ) ; SI4432_Write_Byte(0x1C , BW ) ;
return (((float)WISH) / 10.0) ; return (((float)WISH) / 10.0) ;
@ -453,7 +453,7 @@ float SI4432_RSSI(uint32_t i, int s)
RSSI_RAW = RSSI_RAW / setting.repeat; RSSI_RAW = RSSI_RAW / setting.repeat;
// if (MODE_INPUT(setting.mode) && RSSI_RAW == 0) // if (MODE_INPUT(setting.mode) && RSSI_RAW == 0)
// SI4432_Init(); // SI4432_Init();
float dBm = ((float)RSSI_RAW)/32.0 - 120.0 + SI4432_RSSI_correction; float dBm = ((float)RSSI_RAW)/32.0 + SI4432_RSSI_correction;
#ifdef __SIMULATION__ #ifdef __SIMULATION__
dBm = Simulated_SI4432_RSSI(i,s); dBm = Simulated_SI4432_RSSI(i,s);
#endif #endif

@ -278,7 +278,7 @@ const uint16_t right_icons [] =
}; };
enum { enum {
KM_START=1, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFPOS, KM_SCALE, KM_ATTENUATION, KM_START=1, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFLEVEL, KM_SCALE, KM_ATTENUATION,
KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE,
KM_10MHZ, KM_REPEAT, KM_OFFSET, KM_TRIGGER, KM_LEVELSWEEP, KM_SWEEP_TIME, KM_10MHZ, KM_REPEAT, KM_OFFSET, KM_TRIGGER, KM_LEVELSWEEP, KM_SWEEP_TIME,
}; };
@ -422,7 +422,7 @@ static const char * const keypad_mode_label[] = {
#ifdef __SA__ #ifdef __SA__
static const char * const keypad_mode_label[] = { static const char * const keypad_mode_label[] = {
"error", "START", "STOP", "CENTER", "SPAN", "FREQ", "REFPOS", "\2SCALE\0 5/2/1", // 0-7 "error", "START", "STOP", "CENTER", "SPAN", "FREQ", "REFPOS", "\2SCALE\0 5/2/1", // 0-7
"\2ATTENUATE\0 0-31dB", "\2ACTUAL\0POWER", "IF", "\2SAMPLE\0TIME", "DRIVE", "LEVEL", "LEVEL", "LEVEL", // 8-15 "\2ATTENUATE\0 0-31dB", "\2ACTUAL\0POWER", "IF", "\2SAMPLE\0TIME", "DRIVE", "LEVEL", "SCANS", "LEVEL", // 8-15
"OFFSET" , "REPEATS", "OFFSET", "\2TRIGGER\0LEVEL", "\2LEVEL\0SWEEP", "\2SWEEP\0SECONDS"// 16- "OFFSET" , "REPEATS", "OFFSET", "\2TRIGGER\0LEVEL", "\2LEVEL\0SWEEP", "\2SWEEP\0SECONDS"// 16-
}; };
#endif #endif
@ -1179,7 +1179,7 @@ static const menuitem_t menu_atten[] = {
static const menuitem_t menu_reflevel[] = { static const menuitem_t menu_reflevel[] = {
{ MT_CALLBACK,0, "AUTO", menu_reflevel_cb}, { MT_CALLBACK,0, "AUTO", menu_reflevel_cb},
{ MT_KEYPAD, KM_REFPOS, "MANUAL", NULL}, { MT_KEYPAD, KM_REFLEVEL, "MANUAL", NULL},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -1461,7 +1461,7 @@ static const menuitem_t menu_mode[] = {
#ifdef __ULTRA__ #ifdef __ULTRA__
{ MT_FORM | MT_CALLBACK | MT_ICON, I_LOW_INPUT+I_SA, "ULTRA HIGH INPUT",menu_mode_cb}, { MT_FORM | MT_CALLBACK | MT_ICON, I_LOW_INPUT+I_SA, "ULTRA HIGH INPUT",menu_mode_cb},
#endif #endif
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, // { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
}; };
@ -1703,7 +1703,7 @@ static void fetch_numeric_target(void)
uistat.value = setting.scale; uistat.value = setting.scale;
plot_printf(uistat.text, sizeof uistat.text, "%f/", uistat.value); plot_printf(uistat.text, sizeof uistat.text, "%f/", uistat.value);
break; break;
case KM_REFPOS: case KM_REFLEVEL:
uistat.value = setting.reflevel; uistat.value = setting.reflevel;
plot_printf(uistat.text, sizeof uistat.text, "%f", uistat.value); plot_printf(uistat.text, sizeof uistat.text, "%f", uistat.value);
break; break;
@ -1756,7 +1756,11 @@ static void fetch_numeric_target(void)
plot_printf(uistat.text, sizeof uistat.text, "%.1fdB", uistat.value); plot_printf(uistat.text, sizeof uistat.text, "%.1fdB", uistat.value);
break; break;
case KM_SWEEP_TIME: case KM_SWEEP_TIME:
uistat.value = setting.sweep_time; if (setting.sweep_time < calc_min_sweep_time())
uistat.value = calc_min_sweep_time();
else
uistat.value = setting.sweep_time;
uistat.value /= 1000.0;
plot_printf(uistat.text, sizeof uistat.text, "%.1fS", uistat.value); plot_printf(uistat.text, sizeof uistat.text, "%.1fS", uistat.value);
break; break;
case KM_TRIGGER: case KM_TRIGGER:
@ -1800,7 +1804,7 @@ set_numeric_value(void)
set_auto_reflevel(false); set_auto_reflevel(false);
set_scale(uistat.value); set_scale(uistat.value);
break; break;
case KM_REFPOS: case KM_REFLEVEL:
set_auto_reflevel(false); set_auto_reflevel(false);
set_reflevel(uistat.value); set_reflevel(uistat.value);
break; break;
@ -1849,10 +1853,12 @@ set_numeric_value(void)
set_level_sweep(uistat.value); set_level_sweep(uistat.value);
break; break;
case KM_SWEEP_TIME: case KM_SWEEP_TIME:
set_sweep_time(uistat.value); set_sweep_time(uistat.value*1000.0);
update_grid(); update_grid();
break; break;
case KM_TRIGGER: case KM_TRIGGER:
if (setting.trigger == T_AUTO )
set_trigger(T_NORMAL);
set_trigger_level(to_dBm(uistat.value)); set_trigger_level(to_dBm(uistat.value));
break; break;
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.