RBW power calibration table added and calibration completed

tinySA
erikkaashoek 6 years ago
parent 7d64766513
commit 85e17da3bf

@ -642,6 +642,9 @@ void SetScale(int);
void SetRBW(int);
void SetRX(int);
extern int setting_measurement;
void self_test(void);
void wait_user(void);
void calibrate(void);
enum {
M_OFF, M_IMD, M_OIP3

@ -13,7 +13,7 @@ int setting_rbw = 0;
int setting_average = 0;
int setting_show_stored = 0;
int setting_subtract_stored = 0;
int setting_drive=0; // 0-3 , 3=+20dBm
int setting_drive=1; // 0-3 , 3=+20dBm
int setting_agc = true;
int setting_lna = false;
int setting_tracking = false;
@ -24,6 +24,7 @@ int setting_decay;
int setting_noise;
float actual_rbw = 0;
float setting_vbw = 0;
int setting_measurement;
int vbwSteps = 1;
@ -55,6 +56,9 @@ void reset_settings(int m)
setting_vbw = 0;
setting_decay=20;
setting_noise=20;
trace[TRACE_STORED].enabled = false;
trace[TRACE_TEMP].enabled = false;
setting_measurement = M_OFF;
// setting_spur = 0;
switch(m) {
@ -1076,7 +1080,7 @@ static const struct {
{TC_END, 0, 0, 0, 0, 0, 0},
{TC_MEASURE, TP_30MHZ, 30, 7, -25, 30, -80 }, // 11 Measure power level and noise
{TC_MEASURE, TP_30MHZ, 270, 4, -50, 30, -85 }, // 13 Measure powerlevel and noise
{TC_MEASURE, TPH_30MHZ, 270, 4, -50, 30, -85 }, // 14 Calibrate power high mode
{TC_MEASURE, TPH_30MHZ, 270, 4, -35, 30, -50 }, // 14 Calibrate power high mode
{TC_END, 0, 0, 0, 0, 0, 0},
};
@ -1367,13 +1371,10 @@ void self_test(void)
ili9341_drawstring_7x13("Self test complete", 30, 120);
ili9341_drawstring_7x13("Touch screen to continue", 30, 140);
wait_user();
ili9341_clear_screen();
sweep_mode = SWEEP_ENABLE;
show_test_info = FALSE;
trace[TRACE_STORED].enabled = false;
set_trace_refpos(0, NGRIDY - (-10) / get_trace_scale(0));
set_trace_refpos(1, NGRIDY - (-10) / get_trace_scale(0));
set_trace_refpos(2, NGRIDY - (-10) / get_trace_scale(0));
set_refer_output(0);
reset_settings(M_LOW);
in_selftest = false;
@ -1384,7 +1385,7 @@ void reset_calibration(void)
SetPowerLevel(100);
}
#define CALIBRATE_RBWS 5
#define CALIBRATE_RBWS 1
const int power_rbw [5] = { 100, 300, 30, 10, 3 };
void calibrate(void)
@ -1405,9 +1406,10 @@ void calibrate(void)
ili9341_set_foreground(BRIGHT_COLOR_RED);
ili9341_drawstring_7x13("Calibration failed", 30, 120);
goto quit;
} else
SetPowerLevel(-25);
goto done;
} else {
SetPowerLevel(-23);
chThdSleepMilliseconds(1000);
}
}
i = 11; // Measure 270MHz in low mode
SetRBW(100);
@ -1417,10 +1419,10 @@ void calibrate(void)
local_test_status = test_validate(i); // Validate test
chThdSleepMilliseconds(1000);
config.high_level_offset = -20; /// Preliminary setting
config.high_level_offset = 0; /// Preliminary setting
i = 12; // Calibrate 270MHz in high mode
for (int j = 0; j < CALIBRATE_RBWS-1; j++) {
for (int j = 0; j < CALIBRATE_RBWS; j++) {
SetRBW(power_rbw[j]);
test_prepare(i);
test_acquire(i); // Acquire test
@ -1431,20 +1433,17 @@ void calibrate(void)
goto quit;
} else
SetPowerLevel(last_peak_level);
chThdSleepMilliseconds(1000);
}
done:
ili9341_set_foreground(BRIGHT_COLOR_GREEN);
ili9341_drawstring_7x13("Calibration complete", 30, 120);
quit:
ili9341_drawstring_7x13("Touch screen to continue", 30, 140);
wait_user();
ili9341_clear_screen();
in_selftest = false;
sweep_mode = SWEEP_ENABLE;
trace[TRACE_STORED].enabled = false;
set_trace_refpos(0, NGRIDY - (-10) / get_trace_scale(0));
set_trace_refpos(1, NGRIDY - (-10) / get_trace_scale(0));
set_trace_refpos(2, NGRIDY - (-10) / get_trace_scale(0));
set_refer_output(0);
reset_settings(M_LOW);
}

@ -168,39 +168,49 @@ void SI4432_Receive(void)
}
// First entry of each triple is RBW in khz times 10, so 377 = 37.7khz
// User asks for an RBW of WISH, go through table finding the last triple
// for which WISH is greater than the first entry, use those values,
// Return the first entry of the following triple for the RBW actually achieved
static const short RBW_choices[] = { // Each triple is: ndec, fils, WISH*10
0, 5,1,26, 5,2,28, 5,3,31, 5,4,32, 5,5,37, 5,6,42, 5,7,
45,4,1, 49,4,2, 54,4,3, 59,4,4, 61,4,5, 72,4,6, 82,4,7,
88,3,1, 95,3,2, 106,3,3, 115,3,4, 121,3,5, 142,3,6, 162,3,7,
175,2,1, 189,2,2, 210,2,3, 227,2,4, 240,2,5, 282,2,6, 322,2,7,
347,1,1, 377,1,2, 417,1,3, 452,1,4, 479,1,5, 562,1,6, 641,1,7,
692,0,1, 752,0,2, 832,0,3, 900,0,4, 953,0,5, 1121,0,6, 1279,0,7,
1379,1,4, 1428,1,5, 1678,1,9, 1811,0,15, 1915,0,1, 2251,0,2, 2488,0,3,
2693,0,4, 2849,0,8, 3355,0,9, 3618,0,10, 4202,0,11, 4684,0,12, 5188,0,13,
5770,0,14, 6207
static const short RBW_choices[] = { // Each quadrupple is: ndec, fils, WISH*10, corr*10
5,1,26,5, 5,2,28,5, 5,3,31,5, 5,4,32,5, 5,5,37,5, 5,6,42,5,
5,7,45,5, 4,1,49,5,
4,2,54,5, 4,3,59,5, 4,4,61,5, 4,5,72,5, 4,6,82,5, 4,7,88,5,
3,1,95,5, 3,2,106,5, 3,3,115,5, 3,4,121,5, 3,5,142,5, 3,6,162,5,
3,7,175,5, 2,1,189,5, 2,2,210,5, 2,3,227,5, 2,4,240,5, 2,5,282,5,
2,6,322,5, 2,7,347,5, 1,1,377,5, 1,2,417,5, 1,3,452,5, 1,4,479,5,
1,5,562,5, 1,6,641,5, 1,7,692,5, 0,1,752,5, 0,2,832,5, 0,3,900,5,
0,4,953,5, 0,5,1121,5, 0,6,1279,5, 0,7,1379,5, 1,4,1428,5, 1,5,1678,5,
1,9,1811,5, 0,15,1915,5, 0,1,2251,5, 0,2,2488,5, 0,3,2693,5,
0,4,2849,5, 0,8,3355,5, 0,9,3618,5, 0,10,4202,5, 0,11,4684,5, 0,12,5188,5,
0,13,5770,5, 0,14,6207,5
};
static float SI4432_RSSI_correction = 0;
float SI4432_SET_RBW(float w) {
uint8_t dwn3=0;
int32_t WISH = (uint32_t)(w * 10.0);
uint8_t ndec, fils, i;
if (WISH > 6207) WISH=6207; // Final value in RBW_choices[]
if (WISH > 1379) dwn3 = 1 ;
for (i=3; i<sizeof(RBW_choices)/sizeof(RBW_choices[0]); i+=3)
if (WISH <= RBW_choices[i]) break;
ndec = RBW_choices[i-2];
fils = RBW_choices[i-1];
WISH = RBW_choices[i]; // RBW achieved by Si4432 in Hz
for (i=3; i<sizeof(RBW_choices)/sizeof(RBW_choices[0]); i+=4)
if (WISH <= RBW_choices[i-1]) break;
ndec = RBW_choices[i-3];
fils = RBW_choices[i-2];
WISH = RBW_choices[i-1]; // RBW achieved by Si4432 in Hz
SI4432_RSSI_correction = RBW_choices[i]/10.0;
uint8_t BW = (dwn3 << 7) | (ndec << 4) | fils ;
SI4432_Write_Byte(0x1C , BW ) ;
return ((float)WISH / 10.0) ;
}
float SI4432_RBW_table(int i){
if (i < 0)
return 0;
if (i * 4 >= (sizeof RBW_choices) / 2 )
return 0;
return(RBW_choices[i*4-1]);
}
void SI4432_Set_Frequency ( long Freq ) {
int hbsel;

Loading…
Cancel
Save

Powered by TurnKey Linux.