Merge branch 'master' into tinySA-V4-SI4463

Removed_REF_marker
erikkaashoek 5 years ago
commit 07370dff10

@ -3105,14 +3105,14 @@ void draw_cal_status(void)
// -------------------- Self testing ------------------------------------------------- // -------------------- Self testing -------------------------------------------------
enum { enum {
TC_SIGNAL, TC_BELOW, TC_ABOVE, TC_FLAT, TC_MEASURE, TC_SET, TC_END, TC_SIGNAL, TC_BELOW, TC_ABOVE, TC_FLAT, TC_MEASURE, TC_SET, TC_END, TC_ATTEN,
}; };
enum { enum {
TP_SILENT, TPH_SILENT, TP_10MHZ, TP_10MHZEXTRA, TP_10MHZ_SWITCH, TP_30MHZ, TPH_30MHZ, TPH_30MHZ_SWITCH TP_SILENT, TPH_SILENT, TP_10MHZ, TP_10MHZEXTRA, TP_10MHZ_SWITCH, TP_30MHZ, TPH_30MHZ, TPH_30MHZ_SWITCH
}; };
#define TEST_COUNT 19 #define TEST_COUNT 21
#define W2P(w) (sweep_points * w / 100) // convert width in % to actual sweep points #define W2P(w) (sweep_points * w / 100) // convert width in % to actual sweep points
@ -3137,17 +3137,20 @@ static const struct {
{TC_FLAT, TP_10MHZEXTRA, 10, 4, -18, 7, -60}, // 8 BPF pass band flatness {TC_FLAT, TP_10MHZEXTRA, 10, 4, -18, 7, -60}, // 8 BPF pass band flatness
{TC_BELOW, TP_30MHZ, 430, 60, -75, 0, -75}, // 9 LPF cutoff {TC_BELOW, TP_30MHZ, 430, 60, -75, 0, -75}, // 9 LPF cutoff
{TC_SIGNAL, TP_10MHZ_SWITCH,20, 7, -39, 10, -60 }, // 10 Switch isolation using high attenuation {TC_SIGNAL, TP_10MHZ_SWITCH,20, 7, -39, 10, -60 }, // 10 Switch isolation using high attenuation
{TC_ATTEN, TP_30MHZ, 30, 0, -25, 145, -60 }, // 11 Measure atten step accuracy
{TC_END, 0, 0, 0, 0, 0, 0}, {TC_END, 0, 0, 0, 0, 0, 0},
#define TEST_POWER 11 #define TEST_POWER 12
{TC_MEASURE, TP_30MHZ, 30, 7, -25, 10, -55 }, // 12 Measure power level and noise {TC_MEASURE, TP_30MHZ, 30, 7, -25, 10, -55 }, // 12 Measure power level and noise
{TC_MEASURE, TP_30MHZ, 270, 4, -50, 10, -75 }, // 13 Measure powerlevel and noise {TC_MEASURE, TP_30MHZ, 270, 4, -50, 10, -75 }, // 13 Measure powerlevel and noise
{TC_MEASURE, TPH_30MHZ, 270, 4, -40, 10, -65 }, // 14 Calibrate power high mode {TC_MEASURE, TPH_30MHZ, 270, 4, -40, 10, -65 }, // 14 Calibrate power high mode
{TC_END, 0, 0, 0, 0, 0, 0}, {TC_END, 0, 0, 0, 0, 0, 0},
#define TEST_RBW 15 #define TEST_RBW 16
{TC_MEASURE, TP_30MHZ, 30, 1, -20, 10, -60 }, // 16 Measure RBW step time {TC_MEASURE, TP_30MHZ, 30, 1, -20, 10, -60 }, // 16 Measure RBW step time
{TC_END, 0, 0, 0, 0, 0, 0}, {TC_END, 0, 0, 0, 0, 0, 0},
{TC_MEASURE, TPH_30MHZ, 300, 4, -48, 10, -65 }, // 14 Calibrate power high mode {TC_MEASURE, TPH_30MHZ, 300, 4, -48, 10, -65 }, // 14 Calibrate power high mode
{TC_MEASURE, TPH_30MHZ_SWITCH,300, 4, -40, 10, -65 }, // 14 Calibrate power high mode {TC_MEASURE, TPH_30MHZ_SWITCH,300, 4, -40, 10, -65 }, // 14 Calibrate power high mode
#define TEST_ATTEN 20
{TC_ATTEN, TP_30MHZ, 30, 0, -25, 145, -60 } // 20 Measure atten step accuracy
}; };
@ -3279,6 +3282,43 @@ int validate_flatness(int i) {
return(TS_PASS); return(TS_PASS);
} }
const float atten_step[7] = { 0.0, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0 };
int validate_atten(int i) {
float reference_peak_level = 0.0;
test_fail_cause[i] = "Attenuator ";
// for (int j= 0; j < 64; j++ ) {
for (int j= 0; j < 7; j++ ) {
// set_attenuation(((float)j)/2.0);
set_attenuation(atten_step[j]);
float summed_peak_level = 0;
#define ATTEN_TEST_SWEEPS 5
for (int k=0; k<ATTEN_TEST_SWEEPS; k++) {
// setting.sweep_time_us = 1000000;
test_acquire(TEST_ATTEN); // Acquire test
// test_validate(TEST_ATTEN); // Validate test
float peaklevel = 0.0;
for (int k = 0 ; k < sweep_points; k++)
peaklevel += actual_t[k];
peaklevel /= sweep_points;
summed_peak_level += peakLevel;
}
summed_peak_level /= ATTEN_TEST_SWEEPS;
if (j == 0)
reference_peak_level = summed_peak_level;
else {
// shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",((float)j)/2.0, summed_peak_level, summed_peak_level - reference_peak_level);
// shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",atten_step[j], summed_peak_level, summed_peak_level - reference_peak_level);
#define ATTEN_TEST_CRITERIA 3.0
if (summed_peak_level - reference_peak_level <= -ATTEN_TEST_CRITERIA || summed_peak_level - reference_peak_level >= ATTEN_TEST_CRITERIA)
return(TS_FAIL);
}
}
test_fail_cause[i] = "";
return(TS_PASS);
}
int validate_above(int tc) { int validate_above(int tc) {
int status = TS_PASS; int status = TS_PASS;
for (int j = 0; j < setting._sweep_points; j++) { for (int j = 0; j < setting._sweep_points; j++) {
@ -3332,7 +3372,9 @@ int test_validate(int i)
case TC_FLAT: // Validate passband flatness case TC_FLAT: // Validate passband flatness
current_test_status = validate_flatness(i); current_test_status = validate_flatness(i);
break; break;
case TC_ATTEN:
current_test_status = validate_atten(i);
break;
} }
// Report status // Report status
@ -3540,23 +3582,28 @@ void self_test(int test)
in_selftest = true; in_selftest = true;
reset_settings(M_LOW); reset_settings(M_LOW);
float reference_peak_level = 0; float reference_peak_level = 0;
test_prepare(TEST_RBW); test_prepare(TEST_ATTEN);
for (int j= 0; j < 50; j++ ) { test_acquire(TEST_ATTEN); // Acquire test
test_prepare(TEST_RBW); test_validate(TEST_ATTEN); // Validate test
set_RBW(300); #if 0
for (int j= 0; j < 64; j++ ) {
set_attenuation((float)j); // test_prepare(TEST_ATTEN);
set_attenuation(((float)j)/2.0);
float summed_peak_level = 0; float summed_peak_level = 0;
for (int k=0; k<10; k++) { // for (int k=0; k<10; k++) {
test_acquire(TEST_RBW); // Acquire test test_acquire(TEST_ATTEN); // Acquire test
test_validate(TEST_RBW); // Validate test test_validate(TEST_ATTEN); // Validate test
summed_peak_level += peakLevel; // summed_peak_level += peakLevel;
} // }
peakLevel = summed_peak_level / 10; float peaklevel = 0.0;
for (int k = 0 ; k < sweep_points; k++)
peaklevel += actual_t[k];
peaklevel /= sweep_points;
if (j == 0) if (j == 0)
reference_peak_level = peakLevel; reference_peak_level = peakLevel;
shell_printf("Attenuation %ddB, measured level %.2fdBm, delta %.2fdB\n\r",j, peakLevel, peakLevel - reference_peak_level); shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",((float)j)/2.0, peakLevel, peakLevel - reference_peak_level);
} }
#endif
reset_settings(M_LOW); reset_settings(M_LOW);
} else if (test == 3) { // RBW step time search } else if (test == 3) { // RBW step time search
in_selftest = true; in_selftest = true;

Loading…
Cancel
Save

Powered by TurnKey Linux.