21MHz spur elimination added

pull/34/head
erikkaashoek 3 years ago
parent 9f817fb289
commit 77268080f2

@ -1051,6 +1051,7 @@ config_t config = {
#ifdef TINYSA4
.direct_start = 965000000UL,
.direct_stop = 985000000UL,
.hide_21MHz = false,
#endif
};

@ -789,6 +789,9 @@ typedef struct config {
uint8_t flip;
#ifdef __ULTRA__
uint8_t direct;
#endif
#ifdef TINYSA4
uint8_t hide_21MHz;
#endif
float sweep_voltage;
float switch_offset;

@ -3045,6 +3045,45 @@ int binary_search(freq_t f)
return false;
}
#ifdef TINYSA4
#define ADDITIONAL_SPUR_TABLE_SIZE 8
static const freq_t additional_spur_table[ADDITIONAL_SPUR_TABLE_SIZE] =
{
132000000,
153000000,
174600000,
197000000,
219000000,
242000000,
266000000,
289600000,
};
//binary_search_table(f, additional_spur_table, ADDITIONAL_SPUR_TABLE_SIZE, ADDITIONAL_SPUR_TABE_GATE)
#define ADDITIONAL_SPUR_TABE_GATE 1000000
int binary_search_table(freq_t f, const freq_t *table, int table_size, int gate)
{
int L = 0;
int R = table_size - 1;
freq_t fmin = f - gate;
freq_t fplus = f + gate;
while (L <= R) {
int m = (L + R) / 2;
if (table[m] < fmin)
L = m + 1;
else if (table[m] > fplus)
R = m - 1;
else
return true; // index is m
}
return false;
}
#endif
#ifdef TINYSA4
//static const uint8_t spur_div[] = {3, 3, 5, 2, 3, 4}; // 4/1 removed
//static const uint8_t spur_mul[] = {1, 1, 2, 1, 2, 3};
@ -3073,7 +3112,12 @@ void fill_spur_table(void)
corr_IF = config.frequency_IF1;
}
dynamic_spur_table_size = 0;
// dynamic_spur_table[dynamic_spur_table_size++] = 132000000;
// dynamic_spur_table[dynamic_spur_table_size++] = 153000000;
// dynamic_spur_table[dynamic_spur_table_size++] = 174600000;
// dynamic_spur_table[dynamic_spur_table_size++] = 219000000;
dynamic_spur_table[dynamic_spur_table_size++] = corr_IF/4 -SPUR_FACTOR/2;
// dynamic_spur_table[dynamic_spur_table_size++] = 266000000;
dynamic_spur_table[dynamic_spur_table_size++] = corr_IF/2 -SPUR_FACTOR;
dynamic_spur_table[dynamic_spur_table_size++] = corr_IF*2/3 -SPUR_FACTOR*2/3;
spur_table = dynamic_spur_table;
@ -3927,6 +3971,7 @@ again: // Spur redu
}
}
#endif
#ifdef __ULTRA__
if (S_IS_AUTO(setting.below_IF)) {
if ((freq_t)lf > MAX_ABOVE_IF_FREQ && lf <= ULTRA_MAX_FREQ )
@ -4040,6 +4085,15 @@ again: // Spur redu
local_IF += DEFAULT_SPUR_OFFSET-(actual_rbw_x10 > 1000 ? 200000 : 0); // Shift to avoid zero Hz peak
LO_shifting = true;
}
if (config.hide_21MHz && S_IS_AUTO(setting.below_IF)) {
if (binary_search_table(lf, additional_spur_table, ADDITIONAL_SPUR_TABLE_SIZE, ADDITIONAL_SPUR_TABE_GATE))
{
setting.below_IF= S_AUTO_ON;
} else {
setting.below_IF= S_AUTO_OFF;
}
}
#else
local_IF = local_IF; // + DEFAULT_SPUR_OFFSET/2; // No spure removal and no spur, center in IF
#endif
@ -4204,7 +4258,7 @@ again: // Spur redu
setting.increased_R = true;
freq_t tf = ((lf + actual_rbw_x10*1000) / TXCO_DIV3) * TXCO_DIV3;
if (tf + actual_rbw_x10*1000 >= lf && tf < lf + actual_rbw_x10*1000) // 10MHz
ADF4351_R_counter(2); // To avoid PLL Loop shoulders at multiple of 10MHz
ADF4351_R_counter(-4); // To avoid PLL Loop shoulders at multiple of 10MHz
else
ADF4351_R_counter(3); // To avoid PLL Loop shoulders
} else

@ -1345,6 +1345,19 @@ static UI_FUNCTION_ADV_CALLBACK(menu_debug_spur_acb)
#endif
#ifdef TINYSA4
static UI_FUNCTION_ADV_CALLBACK(menu_hide_21MHz_acb)
{
(void)data;
(void)item;
if (b){
b->icon = config.hide_21MHz == 0 ? BUTTON_ICON_NOCHECK : BUTTON_ICON_CHECK;
return;
}
config.hide_21MHz = ! config.hide_21MHz;
// menu_move_back();
ui_mode_normal();
}
static UI_FUNCTION_ADV_CALLBACK(menu_progress_bar_acb)
{
(void)data;
@ -3056,6 +3069,7 @@ static const menuitem_t menu_settings4[] =
{ MT_ADV_CALLBACK, 0, "DEBUG\nFREQ", menu_debug_freq_acb},
{ MT_ADV_CALLBACK, 0, "DEBUG\nAVOID", menu_debug_avoid_acb},
{ MT_ADV_CALLBACK, 0, "DEBUG\nSPUR", menu_debug_spur_acb},
{ MT_ADV_CALLBACK, 0, "HIDE\n21MHz", menu_hide_21MHz_acb},
#if 0 // only used during development
{ MT_KEYPAD, KM_COR_AM, "COR\nAM", "Enter AM modulation correction"},
{ MT_KEYPAD, KM_COR_WFM, "COR\nWFM", "Enter WFM modulation correction"},

Loading…
Cancel
Save

Powered by TurnKey Linux.