Shift modulation calibration to output modes only

Removed_REF_marker
erikkaashoek 5 years ago
parent 31d8406706
commit 3192035ff4

@ -2902,6 +2902,10 @@ int main(void)
/* restore config */
config_recall();
config.cor_am = 0; // Should be removed from config
config.cor_nfm = 0;
config.cor_wfm = 0;
if (caldata_recall(0) == -1) {
load_LCD_properties();
}
@ -2927,7 +2931,7 @@ int main(void)
setup_sa();
set_sweep_points(POINTS_COUNT);
#ifdef __AUDIO__
#ifdef __AUDIO__
/*
* I2S Initialize
*/
@ -2967,16 +2971,6 @@ int main(void)
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL);
reset_settings(M_LOW); // Calibrate the modulation frequencies
set_mode(M_GENLOW);
set_sweep_frequency(ST_SPAN, (freq_t)0);
in_selftest = true;
calibrate_modulation(MO_AM, &config.cor_am);
calibrate_modulation(MO_NFM, &config.cor_nfm);
calibrate_modulation(MO_WFM, &config.cor_wfm);
in_selftest = false;
reset_settings(M_LOW);
while (1) {
if (SDU1.config->usbp->state == USB_ACTIVE) {

@ -1277,6 +1277,7 @@ float to_dBm(float);
uint32_t calc_min_sweep_time_us(void);
pureRSSI_t perform(bool b, int i, freq_t f, int e);
void interpolate_maximum(int m);
void calibrate_modulation(int modulation, int8_t *correction);
enum {
M_OFF, M_IMD, M_OIP3, M_PHASE_NOISE, M_STOP_BAND, M_PASS_BAND, M_LINEARITY, M_AM, M_FM, M_THD

@ -1643,6 +1643,7 @@ toggle_waterfall(void)
else if (setting.waterfall == W_BIG) graph_bottom = BIG_WATERFALL;
else /*if (setting.waterfall == W_OFF)*/graph_bottom = NO_WATERFALL;
_grid_y = graph_bottom / NGRIDY;
area_height = AREA_HEIGHT_NORMAL;
if (setting.waterfall != W_OFF){
ili9341_set_background(LCD_BG_COLOR);
ili9341_fill(OFFSETX, graph_bottom, LCD_WIDTH - OFFSETX, CHART_BOTTOM - graph_bottom);

@ -1285,11 +1285,11 @@ static const struct {
uint16_t spur_div_1000;
} step_delay_table[]={
// RBWx10 step_delay offset_delay spur_gate (value divided by 1000)
{ 6000, 80, 50, 400},
{ 6000, 250, 50, 400},
{ 3000, 400, 50, 200},
{ 1000, 400, 100, 100},
{ 300, 400, 120, 100},
{ 100, 400, 120, 100},
{ 100, 700, 120, 100},
{ 30, 900, 300, 100},
{ 10, 4000, 600, 100},
{ 0, 9000, 3000, 100}
@ -2851,12 +2851,16 @@ modulation_again:
spur = '!';
}
char shifted = ( LO_shifted ? '>' : ' ');
if (SDU1.config->usbp->state == USB_ACTIVE)
shell_printf ("%d:%c%c%c%cLO=%11.6Lq:%11.6Lq\tIF=%11.6Lq:%11.6Lq\tOF=%11.6q\tF=%11.6Lq:%11.6Lq\tD=%.2f:%.2f\r\n",
i, spur, shifted,(LO_mirrored ? 'm' : ' '), (LO_harmonic ? 'h':' ' ),
old_freq[ADF4351_LO],real_old_freq[ADF4351_LO],
old_freq[SI4463_RX], real_old_freq[SI4463_RX], (int32_t)real_offset, f_low, f_high , f_error_low, f_error_high);
osalThreadSleepMilliseconds(100);
if (SDU1.config->usbp->state == USB_ACTIVE)
shell_printf ("%d:%c%c%c%cLO=%11.6Lq:%11.6Lq\tIF=%11.6Lq:%11.6Lq\tOF=%11.6d\tF=%11.6Lq:%11.6Lq\tD=%.2f:%.2f %c%c%c\r\n",
i, spur, shifted,(LO_mirrored ? 'm' : ' '), (LO_harmonic ? 'h':' ' ),
old_freq[ADF4351_LO],real_old_freq[ADF4351_LO],
old_freq[SI4463_RX], real_old_freq[SI4463_RX], (int32_t)real_offset, f_low, f_high , f_error_low, f_error_high,
(ADF4351_frequency_changed? 'A' : ' '),
(SI4463_frequency_changed? 'S' : ' '),
(SI4463_offset_changed? 'O' : ' ')
);
osalThreadSleepMilliseconds(100);
}
#endif
// ------------------------- end of processing when in output mode ------------------------------------------------
@ -2973,6 +2977,8 @@ modulation_again:
int my_step_delay = SI4432_step_delay;
if (f < 2000000 && actual_rbw_x10 == 3)
my_step_delay = my_step_delay * 2;
if (SI4463_offset_changed)
my_step_delay = my_step_delay * 2;
my_microsecond_delay(my_step_delay * ((setting.R == 0 && old_R > 5 ) ? 8 : 1));
ADF4351_frequency_changed = false;
SI4463_frequency_changed = false;
@ -3082,6 +3088,12 @@ static bool sweep(bool break_on_operation)
modulation_counter = 0; // init modulation counter in case needed
int refreshing = false;
if (MODE_OUTPUT(setting.mode) && config.cor_am == 0) { // Calibrate the modulation frequencies at first use
calibrate_modulation(MO_AM, &config.cor_am);
calibrate_modulation(MO_NFM, &config.cor_nfm);
calibrate_modulation(MO_WFM, &config.cor_wfm);
}
if (dirty) { // Calculate new scanning solution
sweep_counter = 0;
if (get_sweep_frequency(ST_SPAN) < 300000) // Check if AM signal
@ -4702,9 +4714,12 @@ void calibrate_modulation(int modulation, int8_t *correction)
if (*correction == 0) {
setting.modulation = modulation;
setting.modulation_frequency = 5000;
in_selftest = true;
perform(false,0, 30000000, false);
perform(false,1, 30000000, false);
in_selftest = false;
*correction = -(start_of_sweep_timestamp - (ONE_SECOND_TIME / setting.modulation_frequency))/8;
setting.modulation = M_OFF;
}
}

Loading…
Cancel
Save

Powered by TurnKey Linux.