cmd selftest

tinySA-v0.2
erikkaashoek 6 years ago
parent bbe264fb8e
commit faea96b1c9

@ -135,7 +135,7 @@ static THD_FUNCTION(Thread1, arg)
sweep_mode&=~SWEEP_ONCE;
} else if (sweep_mode & SWEEP_SELFTEST) {
// call from lowest level to save stack space
self_test();
self_test(setting_test);
sweep_mode = SWEEP_ENABLE;
} else if (sweep_mode & SWEEP_CALIBRATE) {
// call from lowest level to save stack space
@ -2236,6 +2236,17 @@ VNA_SHELL_FUNCTION(cmd_y)
}
}
VNA_SHELL_FUNCTION(cmd_selftest)
{
if (argc != 1) {
shell_printf("usage: selftest (1-3)\r\n");
return;
}
setting_test = my_atoi(argv[0]);
sweep_mode = SWEEP_SELFTEST;
}
VNA_SHELL_FUNCTION(cmd_x)
{
uint32_t reg;
@ -2465,6 +2476,7 @@ static const VNAShellCommand commands[] =
#ifdef ENABLE_COLOR_COMMAND
{"color" , cmd_color , 0},
#endif
{ "selftest", cmd_selftest, 0 },
{ "x", cmd_x, 0 },
{ "i", cmd_i, 0 },
{ "v", cmd_v, 0 },

@ -661,7 +661,8 @@ void SetScale(int);
void SetRBW(int);
void SetRX(int);
extern int setting_measurement;
void self_test(void);
void self_test(int);
extern int setting_test;
void wait_user(void);
void calibrate(void);

@ -24,6 +24,7 @@ int setting_tracking = false;
int setting_modulation = MO_NONE;
int setting_step_delay = 0;
int setting_frequency_step;
int setting_test;
int setting_harmonic;
int setting_decay;
int setting_noise;
@ -1568,14 +1569,14 @@ static const struct {
{TC_SIGNAL, TP_10MHZ, 30, 7, -32, 30, -80 }, // 4
{TC_BELOW, TP_SILENT, 200, 100, -70, 0, 0}, // 5 Wide band noise floor low mode
{TC_BELOW, TPH_SILENT, 600, 720, -65, 0, 0}, // 6 Wide band noise floor high mode
{TC_SIGNAL, TP_10MHZEXTRA, 10, 8, -13, 55, -60 }, // 7 BPF loss and stop band
{TC_SIGNAL, TP_10MHZEXTRA, 10, 8, -20, 80, -60 }, // 7 BPF loss and stop band
{TC_FLAT, TP_10MHZEXTRA, 10, 4, -18, 20, -60}, // 8 BPF pass band flatness
{TC_BELOW, TP_30MHZ, 430, 60, -65, 0, -75}, // 9 LPF cutoff
{TC_SIGNAL, TP_10MHZ_SWITCH,20, 7, -58, 30, -90 }, // 10 Switch isolation
{TC_END, 0, 0, 0, 0, 0, 0},
{TC_MEASURE, TP_30MHZ, 30, 7, -22.5, 30, -70 }, // 12 Measure power level and noise
{TC_MEASURE, TP_30MHZ, 270, 4, -50, 30, -75 }, // 13 Measure powerlevel and noise
{TC_MEASURE, TPH_30MHZ, 270, 4, -50, 30, -65 }, // 14 Calibrate power high mode
{TC_MEASURE, TPH_30MHZ, 270, 4, -40, 30, -65 }, // 14 Calibrate power high mode
{TC_END, 0, 0, 0, 0, 0, 0},
{TC_MEASURE, TP_30MHZ, 30, 1, -20, 30, -70 }, // 16 Measure RBW step time
{TC_END, 0, 0, 0, 0, 0, 0},
@ -1855,14 +1856,13 @@ int add_spur(int f)
}
void self_test(void)
void self_test(int test)
{
#if 0
if (test ==1) {
in_selftest = true; // Spur search
reset_settings(M_LOW);
test_prepare(4);
int f; // Start search at 400kHz
int f = 400000; // Start search at 400kHz
// int i = 0; // Index in spur table (temp_t)
float p2, p1, p;
@ -1899,16 +1899,12 @@ void self_test(void)
if ((int)stored_t[j] > 1)
shell_printf("%d, %d\n\r", ((int)temp_t[j])/1000, (int)stored_t[j]);
}
while(1) ;
return;
#elif 0 // Attenuator test
int local_test_status;
} else if (test == 2) {
// Attenuator test
in_selftest = true;
reset_settings(M_LOW);
int i = 15; // calibrate attenuator at 30 MHz;
float reference_peak_level;
float reference_peak_level = 0;
test_prepare(i);
for (int j= 0; j < 32; j++ ) {
test_prepare(i);
@ -1916,7 +1912,7 @@ void self_test(void)
float summed_peak_level = 0;
for (int k=0; k<10; k++) {
test_acquire(i); // Acquire test
local_test_status = test_validate(i); // Validate test
test_validate(i); // Validate test
summed_peak_level += peakLevel;
}
peakLevel = summed_peak_level / 10;
@ -1925,9 +1921,8 @@ void self_test(void)
shell_printf("Target %d, actual %f, delta %f\n\r",j, peakLevel, peakLevel - reference_peak_level);
}
return;
#elif 0
} else if (test == 3) {
// RBW step time search
int local_test_status;
in_selftest = true;
reset_settings(M_LOW);
int i = 15; // calibrate low mode power on 30 MHz;
@ -1939,7 +1934,7 @@ void self_test(void)
shell_printf("RBW = %d, ",setting_rbw);
test_prepare(i);
test_acquire(i); // Acquire test
local_test_status = test_validate(i); // Validate test
test_validate(i); // Validate test
float saved_peakLevel = peakLevel;
if (peakLevel < -30) {
shell_printf("Peak level too low, abort\n\r");
@ -1952,14 +1947,13 @@ void self_test(void)
test_prepare(i);
// shell_printf("\n\rRBW = %f",SI4432_force_RBW(j));
test_acquire(i); // Acquire test
local_test_status = test_validate(i); // Validate test
test_validate(i); // Validate test
// shell_printf(" Step %f, %d",peakLevel, setting_step_delay);
}
setting_step_delay = setting_step_delay * 4 / 3;
shell_printf("End level = %f, step time = %d\n\r",peakLevel, setting_step_delay);
}
return;
#else
} else if (test == 0) {
int old_IF = frequency_IF;
in_selftest = true;
menu_autosettings_cb(0);
@ -1992,7 +1986,7 @@ void self_test(void)
set_refer_output(0);
reset_settings(M_LOW);
in_selftest = false;
#endif
}
}
void reset_calibration(void)

@ -46,7 +46,7 @@ void MenuDirty(void);
void ToggleLNA(void);
void ToggleAGC(void);
void redrawHisto(void);
void self_test(void);
void self_test(int);
void set_decay(int);
void set_noise(int);
void toggle_tracking_output(void);
@ -567,6 +567,7 @@ static void menu_config_cb(int item, uint8_t data)
sweep_mode = 0; // Suspend sweep to save time
menu_move_back();
ui_mode_normal();
setting_test = 0;
sweep_mode = SWEEP_SELFTEST;
break;
case 4:

Loading…
Cancel
Save

Powered by TurnKey Linux.