Merge branch 'master' of https://github.com/erikkaashoek/tinySA into DiSlord_test_branch

pull/4/head
DiSlord 5 years ago
commit 2df60e3020

@ -21,7 +21,7 @@
* Board identifier.
*/
#define BOARD_NANOVNA_STM32_F072
#define BOARD_NAME "tinySA v0.2"
#define BOARD_NAME "tinySA v0.3"
#define BOARD_VERSION 0
/*
* Board frequencies.

@ -1210,29 +1210,30 @@ VNA_SHELL_FUNCTION(cmd_sweep)
}
uint32_t value0 = 0;
uint32_t value1 = 0;
uint32_t value2 = 0;
if (argc >= 1) value0 = my_atoui(argv[0]);
if (argc >= 2) value1 = my_atoui(argv[1]);
if (argc >= 3) value2 = my_atoui(argv[2]);
#if MAX_FREQ_TYPE != 5
#error "Sweep mode possibly changed, check cmd_sweep function"
#endif
// Parse sweep {start|stop|center|span|cw} {freq(Hz)}
// get enum ST_START, ST_STOP, ST_CENTER, ST_SPAN, ST_CW
static const char sweep_cmd[] = "start|stop|center|span|cw";
if (argc == 2 && value0 == 0) {
int type = get_str_index(argv[0], sweep_cmd);
if (type == -1)
goto usage;
if (type >=0) {
set_sweep_frequency(type, value1);
return;
}
// Parse sweep {start(Hz)} [stop(Hz)]
if (value0)
set_sweep_frequency(ST_START, value0);
if (value1)
set_sweep_frequency(ST_STOP, value1);
if (value2)
set_sweep_points(value2);
return;
usage:
shell_printf("usage: sweep {start(Hz)} [stop(Hz)]\r\n"\
shell_printf("usage: sweep {start(Hz)} [stop(Hz)] [points]\r\n"\
"\tsweep {%s} {freq(Hz)}\r\n", sweep_cmd);
}

@ -112,7 +112,7 @@ void reset_settings(int m)
switch(m) {
case M_LOW:
minFreq = 0;
maxFreq = 520000000;
maxFreq = 350000000;
set_sweep_frequency(ST_START, (uint32_t) 0);
set_sweep_frequency(ST_STOP, (uint32_t) 350000000);
setting.attenuate = 30.0;
@ -132,7 +132,7 @@ void reset_settings(int m)
case M_GENLOW:
setting.drive=8;
minFreq = 0;
maxFreq = 520000000;
maxFreq = 350000000;
set_sweep_frequency(ST_CENTER, 10000000);
set_sweep_frequency(ST_SPAN, 0);
setting.sweep_time_us = 10*ONE_SECOND_TIME;
@ -895,9 +895,9 @@ pureRSSI_t get_frequency_correction(uint32_t f) // Frequency dependent RSSI
while (f > config.correction_frequency[i] && i < CORRECTION_POINTS)
i++;
if (i >= CORRECTION_POINTS)
return(config.correction_value[CORRECTION_POINTS-1]);
return(scaled_correction_value[CORRECTION_POINTS-1] >> (SCALE_FACTOR - 5) );
if (i == 0)
return(config.correction_value[0]);
return(scaled_correction_value[0] >> (SCALE_FACTOR - 5) );
f = f - config.correction_frequency[i-1];
#if 0
uint32_t m = (config.correction_frequency[i] - config.correction_frequency[i-1]) >> SCALE_FACTOR ;
@ -2457,33 +2457,34 @@ void draw_cal_status(void)
y += YSTEP + YSTEP/2 ;
buf[0] = ' ';
strcpy(&buf[1],"Scan:");
if (setting.step_delay_mode == SD_PRECISE)
buf[0] = 'P';
if (setting.step_delay_mode == SD_FAST)
else if (setting.step_delay_mode == SD_FAST)
buf[0] = 'F';
strcpy(&buf[1],"Scan:");
else
strcpy(&buf[0],"Scan:");
ili9341_drawstring(buf, x, y);
#if 0 // Activate for sweep time debugging
y += YSTEP;
plot_printf(buf, BLEN, "%5.3Fs", (float)setting.sweep_time_us/ONE_SECOND_TIME);
ili9341_drawstring(buf, x, y);
#endif
y += YSTEP;
plot_printf(buf, BLEN, "%5.3Fs", (float)setting.actual_sweep_time_us/ONE_SECOND_TIME);
ili9341_drawstring(buf, x, y);
#if 1
#if 0 // Activate for sweep time debugging
y += YSTEP;
update_rbw(); // To ensure the calc_min_sweep time shown takes the latest delay into account
calculate_step_delay();
uint32_t t = calc_min_sweep_time_us();
// if (t < setting.sweep_time_us)
// t = setting.sweep_time_us;
// setting.actual_sweep_time_us = t;
plot_printf(buf, BLEN, "%5.3Fs", (float)t/ONE_SECOND_TIME);
ili9341_drawstring(buf, x, y);
y += YSTEP;
plot_printf(buf, BLEN, "%5.3Fs", (float)setting.additional_step_delay_us/ONE_SECOND_TIME);
ili9341_drawstring(buf, x, y);
#endif
// Cal output
@ -2724,7 +2725,7 @@ int validate_signal_within(int i, float margin)
return TS_CRITICAL;
}
test_fail_cause[i] = "Frequency ";
if (peakFreq < test_case[i].center * 1000000 - 200000 || test_case[i].center * 1000000 + 200000 < peakFreq )
if (peakFreq < test_case[i].center * 1000000 - 600000 || test_case[i].center * 1000000 + 600000 < peakFreq )
return TS_FAIL;
test_fail_cause[i] = "";
return TS_PASS;
@ -3062,33 +3063,42 @@ void self_test(int test)
for (int j= 0; j < 57; j++ ) {
if (setting.test_argument != 0)
j = setting.test_argument;
do_again:
// do_again:
test_prepare(i);
setting.spur = 0;
#if 1 // Disable for offset baseline scanning
setting.step_delay_mode = SD_NORMAL;
setting.repeat = 1;
#else
setting.step_delay_mode = SD_FAST;
setting.repeat = 20;
#endif
setting.step_delay = setting.step_delay * 5 / 4;
setting.offset_delay = setting.step_delay / 2;
setting.rbw_x10 = SI4432_force_RBW(j);
shell_printf("RBW = %f, ",setting.rbw_x10/10.0);
#if 0
set_sweep_frequency(ST_SPAN, (uint32_t)(setting.rbw_x10 * 1000)); // Wide
#else
if (setting.rbw_x10 < 1000)
set_sweep_frequency(ST_SPAN, (uint32_t)(setting.rbw_x10 * 5000));
set_sweep_frequency(ST_SPAN, (uint32_t)(setting.rbw_x10 * 5000)); // Narrow
else
set_sweep_frequency(ST_SPAN, (uint32_t)(18000000));
// setting.repeat = 10;
#endif
test_acquire(i); // Acquire test
test_validate(i); // Validate test
if (test_value == 0) {
setting.step_delay = setting.step_delay * 4 / 5;
goto do_again;
}
// if (test_value == 0) {
// setting.step_delay = setting.step_delay * 4 / 5;
// goto do_again;
// }
float saved_peakLevel = peakLevel;
// if (peakLevel < -35) {
// shell_printf("Peak level too low, abort\n\r");
// return;
// }
#if 1
shell_printf("Start level = %f, ",peakLevel);
#if 1 // Enable for step delay tuning
while (setting.step_delay > 10 && test_value != 0 && test_value > saved_peakLevel - 0.5) {
test_prepare(i);
setting.spur = 0;
@ -3111,6 +3121,7 @@ do_again:
#endif
setting.offset_delay = 1600;
#if 1 // Enable for offset tuning stepping
test_value = saved_peakLevel;
if ((uint32_t)(setting.rbw_x10 * 1000) / (sweep_points) < 8000) { // fast mode possible
while (setting.offset_delay > 0 && test_value != 0 && test_value > saved_peakLevel - 1.5) {
@ -3128,7 +3139,7 @@ do_again:
// shell_printf(" Step %f, %d",peakLevel, setting.step_delay);
}
}
#endif
shell_printf("End level = %f, step time = %d, fast delay = %d\n\r",peakLevel, setting.step_delay, setting.offset_delay*2);
if (setting.test_argument != 0)
break;

@ -243,63 +243,65 @@ typedef struct {
static RBW_t RBW_choices[] = {
// BW register corr freq
{IF_BW(0,5, 1), -5, 26}, // RBW 2.6 kHz
{IF_BW(0,5, 2), -5, 28},
{IF_BW(0,5, 3), 0, 31},
{IF_BW(0,5, 4), 0, 32},
{IF_BW(0,5, 5), 0, 37},
{IF_BW(0,5, 6), 0, 42},
{IF_BW(0,5,1),0,26},
{IF_BW(0,5,2),0,28},
{IF_BW(0,5,3),3,31},
{IF_BW(0,5,4),-3,32},
{IF_BW(0,5,5),6,37},
{IF_BW(0,5,6),5,42},
{IF_BW(0,5,7),5,45},
{IF_BW(0,4, 1), 5, 49},
{IF_BW(0,4, 2), -5, 54},
{IF_BW(0,4, 3), -5, 59},
{IF_BW(0,4, 4), -5, 61},
{IF_BW(0,4, 5), 0, 72},
{IF_BW(0,4, 6), 0, 82},
{IF_BW(0,4, 7), -5, 88},
{IF_BW(0,4,1),0,49},
{IF_BW(0,4,2),0,54},
{IF_BW(0,4,3),0,59},
{IF_BW(0,4,4),0,61},
{IF_BW(0,4,5),5,72},
{IF_BW(0,4,6),5,82},
{IF_BW(0,4,7),5,88},
{IF_BW(0,3,1),0,95},
{IF_BW(0,3,2),0,106},
{IF_BW(0,3, 3), 0, 115},
{IF_BW(0,3, 4), -5, 121},
{IF_BW(0,3, 5), 0, 142},
{IF_BW(0,3, 6), 0, 162},
{IF_BW(0,3, 7), 0, 175},
{IF_BW(0,3,3),2,115},
{IF_BW(0,3,4),0,121},
{IF_BW(0,3,5),5,142},
{IF_BW(0,3,6),5,162},
{IF_BW(0,3,7),5,175},
{IF_BW(0,2,1),0,189},
{IF_BW(0,2, 2), -5, 210},
{IF_BW(0,2, 3), 0, 227},
{IF_BW(0,2, 4), -5, 240},
{IF_BW(0,2, 5), 0, 282},
{IF_BW(0,2, 6), 0, 322},
{IF_BW(0,2, 7), 0, 347},
{IF_BW(0,2,2),0,210},
{IF_BW(0,2,3),3,227},
{IF_BW(0,2,4),0,240},
{IF_BW(0,2,5),5,282},
{IF_BW(0,2,6),5,322},
{IF_BW(0,2,7),5,347},
{IF_BW(0,1,1),0,377},
{IF_BW(0,1, 2), -5, 417},
{IF_BW(0,1, 3), 0, 452},
{IF_BW(0,1, 4), -5, 479},
{IF_BW(0,1, 5), 0, 562},
{IF_BW(0,1, 6), 0, 641},
{IF_BW(0,1, 7), 0, 692},
{IF_BW(0,0, 1), -5, 752},
{IF_BW(0,0, 2), -5, 832},
{IF_BW(0,1,2),0,417},
{IF_BW(0,1,3),1,452},
{IF_BW(0,1,4),0,479},
{IF_BW(0,1,5),5,562},
{IF_BW(0,1,6),5,641},
{IF_BW(0,1,7),5,692},
{IF_BW(0,0,1),0,752},
{IF_BW(0,0,2),0,832},
{IF_BW(0,0,3),0,900},
{IF_BW(0,0, 4), -5, 953},
{IF_BW(0,0, 5), 0, 1121},
{IF_BW(0,0, 6), 0, 1279},
{IF_BW(0,0, 7), 0, 1379},
{IF_BW(1,1, 4), 15, 1428},
{IF_BW(1,1, 5), 20, 1678},
{IF_BW(1,1, 9), -55, 1811},
{IF_BW(1,0,15), -105, 1915},
{IF_BW(1,0, 1), 15, 2251},
{IF_BW(1,0, 2), 20, 2488},
{IF_BW(1,0, 3), 20, 2693},
{IF_BW(0,0,4),-1,953},
{IF_BW(0,0,5),9,1121},
{IF_BW(0,0,6),2,1279},
{IF_BW(0,0,7),5,1379},
{IF_BW(1,1,4),20,1428},
{IF_BW(1,1,5),26,1678},
{IF_BW(1,1,9),-50,1811},
{IF_BW(1,0,15),-100,1915},
{IF_BW(1,0,1),20,2251},
{IF_BW(1,0,2),22,2488},
{IF_BW(1,0,3),21,2693},
{IF_BW(1,0,4),15,2849},
{IF_BW(1,0,8),-15,3355},
{IF_BW(1,0, 9), -55, 3618},
{IF_BW(1,0,9),-53,3618},
{IF_BW(1,0,10),-15,4202},
{IF_BW(1,0,11), -15, 4684},
{IF_BW(1,0,11),-13,4684},
{IF_BW(1,0,12),-20,5188},
{IF_BW(1,0,13), -15, 5770},
{IF_BW(1,0,14), -10, 6207}
{IF_BW(1,0,13),-14,5770},
{IF_BW(1,0,14),-9,6207},
};
static pureRSSI_t SI4432_RSSI_correction = float_TO_PURE_RSSI(-120);
@ -308,6 +310,7 @@ uint16_t SI4432_force_RBW(int i)
{
SI4432_Write_Byte(SI4432_IF_FILTER_BW, RBW_choices[i].reg); // Write RBW settings to Si4432
SI4432_RSSI_correction = float_TO_PURE_RSSI(RBW_choices[i].RSSI_correction_x_10 - 1200)/10; // Set RSSI correction
// SI4432_RSSI_correction = float_TO_PURE_RSSI( - 1200)/10; // Set RSSI correction
return RBW_choices[i].RBWx10; // RBW achieved by Si4432 in kHz * 10
}

@ -1263,7 +1263,7 @@ static const menuitem_t menu_atten[] = {
{ MT_CALLBACK | MT_LOW, 0, "AUTO", menu_atten_cb},
{ MT_KEYPAD | MT_LOW, KM_ATTENUATION, "MANUAL", "0..30"},
{ MT_CALLBACK | MT_HIGH,0, "0dB", menu_atten_high_cb},
{ MT_CALLBACK | MT_HIGH,30, "\n0225..40dB", menu_atten_high_cb},
{ MT_CALLBACK | MT_HIGH,30, "22.5dB..\n40dB", menu_atten_high_cb},
{ MT_CANCEL, 0, "\032 BACK", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
};
@ -1364,10 +1364,10 @@ static const menuitem_t menu_harmonic[] =
static const menuitem_t menu_scanning_speed[] =
{
{ MT_CALLBACK, SD_NORMAL, "NORMAL", menu_scanning_speed_cb}, // order must match definition of enum
{ MT_CALLBACK, SD_PRECISE, "PRECISE", menu_scanning_speed_cb},
{ MT_CALLBACK | MT_LOW,SD_FAST, "FAST", menu_scanning_speed_cb},
{ MT_KEYPAD | MT_LOW,KM_FAST_SPEEDUP, "FAST\nSPEEDUP", "2..20"},
// { MT_CALLBACK, SD_NORMAL, "NORMAL", menu_scanning_speed_cb}, // order must match definition of enum
// { MT_CALLBACK, SD_PRECISE, "PRECISE", menu_scanning_speed_cb},
// { MT_CALLBACK | MT_LOW,SD_FAST, "FAST", menu_scanning_speed_cb},
// { MT_KEYPAD | MT_LOW,KM_FAST_SPEEDUP, "FAST\nSPEEDUP", "2..20"},
{ MT_KEYPAD, KM_SAMPLETIME, "SAMPLE\nDELAY", "300..30000"}, // This must be item 4 to match highlighting
{ MT_KEYPAD, KM_OFFSET_DELAY, "OFFSET\nDELAY", "300..30000"}, // This must be item 5 to match highlighting
{ MT_CANCEL, 0, "\032 BACK", NULL },
@ -1385,7 +1385,7 @@ static const menuitem_t menu_sweep_speed[] =
{
{ MT_CALLBACK, SD_NORMAL, "NORMAL", menu_scanning_speed_cb}, // order must match definition of enum
{ MT_CALLBACK, SD_PRECISE, "PRECISE", menu_scanning_speed_cb},
{ MT_CALLBACK, SD_FAST, "FAST", menu_scanning_speed_cb},
{ MT_CALLBACK | MT_LOW,SD_FAST, "FAST", menu_scanning_speed_cb},
{ MT_KEYPAD, KM_SWEEP_TIME, "SWEEP\nTIME", "0..600s, 0=disable"}, // This must be item 3 to match highlighting
{ MT_SUBMENU, 0, "SWEEP\nPOINTS", menu_sweep_points},
{ MT_KEYPAD | MT_LOW,KM_FAST_SPEEDUP,"FAST\nSPEEDUP", "2..20, 0=disable"},
@ -1428,9 +1428,9 @@ static const menuitem_t menu_measure[] = {
{ MT_CALLBACK, M_IMD, "HARMONIC", menu_measure_cb},
{ MT_CALLBACK, M_OIP3, "OIP3", menu_measure_cb},
{ MT_CALLBACK, M_PHASE_NOISE,"PHASE\nNOISE", menu_measure_cb},
{ MT_CALLBACK, M_STOP_BAND, "STOP\nBAND", menu_measure_cb},
{ MT_CALLBACK, M_PASS_BAND, "PASS\nBAND", menu_measure_cb},
{ MT_CALLBACK | MT_LOW, M_LINEARITY, "LINEAR", menu_measure_cb},
// { MT_CALLBACK, M_STOP_BAND, "STOP\nBAND", menu_measure_cb},
// { MT_CALLBACK, M_PASS_BAND, "PASS\nBAND", menu_measure_cb},
// { MT_CALLBACK | MT_LOW, M_LINEARITY, "LINEAR", menu_measure_cb},
{ MT_CANCEL, 0, "\032 BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
@ -1501,7 +1501,7 @@ static const menuitem_t menu_level[] = {
{ MT_SUBMENU, 0, "ATTEN", menu_atten},
{ MT_SUBMENU,0, "CALC", menu_average},
{ MT_SUBMENU, 0, "UNIT", menu_unit},
{ MT_KEYPAD, KM_OFFSET, "EXTERN\nAMP",NULL},
{ MT_KEYPAD, KM_OFFSET, "EXTERNAL\nAMP",NULL},
{ MT_SUBMENU, 0, "TRIGGER", menu_trigger},
{ MT_CANCEL, 0, "\032 BACK",NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel

Loading…
Cancel
Save

Powered by TurnKey Linux.