Modulation working

Removed_REF_marker
erikkaashoek 5 years ago
parent 238b60093e
commit 0fdb646c0f

@ -841,15 +841,15 @@ VNA_SHELL_FUNCTION(cmd_release)
VNA_SHELL_FUNCTION(cmd_capture)
{
// read pixel count at one time (PART*2 bytes required for read buffer)
// read pixel count at one time (PART*2 bytes required for read buffer)
int i, y;
#if 0
int m = generic_option_cmd("capture", "off|on", argc, argv[0]);
if (m>=0) {
auto_capture = m;
return;
if (argc == 1) {
int m = generic_option_cmd("capture", "off|on", argc, argv[0]);
if (m>=0) {
auto_capture = m;
return;
}
}
#endif
#if SPI_BUFFER_SIZE < (2*LCD_WIDTH)
#error "Low size of spi_buffer for cmd_capture"
#endif
@ -959,9 +959,9 @@ config_t config = {
// .correction_value = { 0, 0, 0, 0, 0.0, 1.5, 3, 6, 10, 10 },
#endif
.setting_frequency_30mhz = 30000000,
.cor_am = -14,
.cor_wfm = -17,
.cor_nfm = -17,
.cor_am = -5,
.cor_wfm = -55,
.cor_nfm = -55,
.ultra = false,
};

@ -221,6 +221,7 @@ extern const char *info_about[];
#define SI_DRIVE_STEP 0.5 // Power step per step in drive level
#define SWITCH_ATTENUATION 34
#define POWER_OFFSET -18 // Max level with all enabled
#define POWER_RANGE 70
#define MAX_DRIVE 16
#define MIN_DRIVE 8
#else

@ -313,7 +313,6 @@ VNA_SHELL_FUNCTION(cmd_if)
VNA_SHELL_FUNCTION(cmd_ultra_start)
{
if (argc != 1) {
usage:
shell_printf("usage: ultra_start {0..4290M}\r\n%qHz\r\n", config.ultra_threshold);
return;
} else {

@ -1011,7 +1011,7 @@ void set_offset(float offset)
setting.offset = offset;
int min,max;
if (setting.mode == M_GENLOW) {
min = -76; max = -6;
min = POWER_OFFSET - POWER_RANGE; max = POWER_OFFSET;
} else {
min = -38; max = +13;
}
@ -1181,7 +1181,7 @@ void calculate_correction(void)
pureRSSI_t get_frequency_correction(uint32_t f) // Frequency dependent RSSI correction to compensate for imperfect LPF
{
pureRSSI_t cv;
pureRSSI_t cv = 0;
if (setting.extra_lna) {
if (f > 2100000000U) {
cv = float_TO_PURE_RSSI(+13);
@ -1854,6 +1854,8 @@ static int modulation_counter = 0;
#define MODULATION_STEPS 8
static const int am_modulation[MODULATION_STEPS] = { 5, 1, 0, 1, 5, 9, 11, 9 }; // AM modulation
#ifdef TINYSA3
//
// Offset is 156.25Hz when below 600MHz and 312.5 when above.
//
@ -1861,6 +1863,17 @@ static const int am_modulation[MODULATION_STEPS] = { 5, 1, 0, 1, 5, 9, 11, 9 };
#define HND 8
#define LWD 96 // Total WFM deviation is LWD * 4 * 156.25 = 30kHz when below 600MHz
#define HWD 48
#endif
#ifdef TINYSA4
//
// Offset is 14.4Hz when below 600MHz and 28.8 when above.
//
#define LND 96
#define HND 48
#define LWD 512
#define HWD 256
#endif
static const int fm_modulation[4][MODULATION_STEPS] = // Avoid sign changes in NFM
{
{ 2*LND,(int)( 3.5*LND ), 4*LND, (int)(3.5*LND), 2*LND, (int)(0.5*LND), 0, (int)(0.5*LND)}, // Low range, NFM
@ -1871,10 +1884,10 @@ static const int fm_modulation[4][MODULATION_STEPS] = // Avoid sign changes in
static const int fm_modulation_offset[4] =
{
85000,
80000,
165000,
160000
5000, //85000,
0, //80000,
-2700, //165000,
0, //160000
};
@ -2035,7 +2048,7 @@ pureRSSI_t perform(bool break_on_operation, int i, uint32_t f, int tracking)
modulation_delay += config.cor_nfm; // -17 default
// modulation_index = 0; // default value
}
if ((setting.mode == M_GENLOW && f > ((uint32_t)480000000) - config.frequency_IF1) ||
if ((setting.mode == M_GENLOW) ||
(setting.mode == M_GENHIGH && f > ((uint32_t)480000000) ) )
modulation_index += 2;
current_fm_modulation = (int *)fm_modulation[modulation_index];
@ -2060,6 +2073,9 @@ modulation_again:
int offset = current_fm_modulation[modulation_counter];
SI4432_Write_2_Byte(SI4432_FREQ_OFFSET1, (offset & 0xff ), ((offset >> 8) & 0x03 )); // Use frequency hopping channel for FM modulation
// SI4432_Write_Byte(SI4432_FREQ_OFFSET2, ); // Use frequency hopping channel for FM modulation
#endif
#ifdef __SI4468__
si_fm_offset(current_fm_modulation[modulation_counter]);
#endif
}
modulation_counter++;
@ -2253,7 +2269,7 @@ modulation_again:
ADF4351_R_counter(setting.R);
if (true) { // Avoid 72MHz spur
if (false) { // Avoid 72MHz spur
#define SPUR 2 * 72000000
uint32_t tf = ((lf + actual_rbw_x10*100) / SPUR) * SPUR;
#undef STM32_USBPRE
@ -2874,7 +2890,7 @@ sweep_again: // stay in sweep loop when output mo
#endif
#endif
// -------------------------- auto attenuate ----------------------------------
#define AUTO_TARGET_LEVEL -25
#define AUTO_TARGET_LEVEL -30
#define AUTO_TARGET_WINDOW 2
if (!in_selftest && setting.mode == M_LOW && setting.auto_attenuation && max_index[0] > 0) { // calculate and apply auto attenuate

@ -44,8 +44,13 @@
#ifdef USE_HARDWARE_SPI_MODE
#define SI4432_SPI SPI1
//#define SI4432_SPI_SPEED SPI_BR_DIV64
#define SI4432_SPI_SPEED SPI_BR_DIV32
//#define SI4432_SPI_SPEED SPI_BR_DIV16
//#define SI4432_SPI_SPEED SPI_BR_DIV32
#define SI4432_SPI_SPEED SPI_BR_DIV8
//#define ADF_SPI_SPEED SPI_BR_DIV64
//#define ADF_SPI_SPEED SPI_BR_DIV32
#define ADF_SPI_SPEED SPI_BR_DIV8
static uint32_t old_spi_settings;
#else
static uint32_t old_port_moder;
@ -692,7 +697,7 @@ pureRSSI_t SI4432_RSSI(uint32_t i, int s)
do{
RSSI_RAW += DEVICE_TO_PURE_RSSI((deviceRSSI_t)SI4432_Read_Byte(SI4432_REG_RSSI));
if (--i == 0) break;
my_microsecond_delay(100);
// my_microsecond_delay(100);
}while(1);
if (setting.repeat > 1)
@ -1075,6 +1080,7 @@ void ADF4351_WriteRegister32(int channel, const uint32_t value)
void ADF4351_Set(int channel)
{
set_SPI_mode(SPI_MODE_SI);
SPI_BR_SET(SI4432_SPI, ADF_SPI_SPEED);
// my_microsecond_delay(1);
palClearLine(ADF4351_LE[channel]);
// my_microsecond_delay(1);
@ -1351,6 +1357,7 @@ void ADF4351_enable_out(int s)
int SI4463_frequency_changed = false;
int SI4463_offset_changed = false;
int SI4463_offset_value = 0;
static int SI4463_band = -1;
static int64_t SI4463_outdiv = -1;
@ -1866,7 +1873,33 @@ void si_set_offset(int16_t offset)
// MODEM_FREQ_OFFSET2 - Low byte of the offset
//
// #define RF_MODEM_RSSI_COMP_1 0x11, 0x20, 0x01, 0x4E, 0x40
SI4463_offset_value = offset;
uint8_t data[] = {
0x11,
0x20,
0x02,
0x0d,
(uint8_t) ((offset>>8) & 0xff),
(uint8_t) ((offset) & 0xff)
};
SI4463_do_api(data, sizeof(data), NULL, 0);
SI4463_offset_changed = true;
SI4463_offset_active = (offset != 0);
}
void si_fm_offset(int16_t offset)
{
// Set properties: MODEM_FREQ_OFFSET
// Number of properties: 2
// Group ID: 0x20
// Start ID: 0x0d
// Default values: 0x00, 0x00
// Descriptions:
// MODEM_FREQ_OFFSET1 - High byte of the offset
// MODEM_FREQ_OFFSET2 - Low byte of the offset
//
// #define RF_MODEM_RSSI_COMP_1 0x11, 0x20, 0x01, 0x4E, 0x40
offset = SI4463_offset_value + offset;
uint8_t data[] = {
0x11,
0x20,
@ -1975,7 +2008,7 @@ int16_t Si446x_RSSI(void)
#endif
RSSI_RAW_ARRAY[--j] = data[2];
if (j == 0) break;
my_microsecond_delay(20);
// my_microsecond_delay(20);
}while(1);
#if SAMPLE_COUNT == 3
int t;
@ -2000,7 +2033,7 @@ int16_t Si446x_RSSI(void)
RSSI_RAW += DEVICE_TO_PURE_RSSI(RSSI_RAW_ARRAY[0]);
#endif
if (--i <= 0) break;
my_microsecond_delay(100);
// my_microsecond_delay(100);
}while(1);
if (setting.repeat > 1)

@ -1883,7 +1883,7 @@ draw_menu_buttons(const menuitem_t *menu)
}
goto draw_divider;
} else if (menu[i].data == KM_LOWOUTLEVEL) {
local_slider_positions = ((get_attenuation() + 76 ) * (MENU_FORM_WIDTH-8)) / 70 + OFFSETX+4;
local_slider_positions = ((get_attenuation() - POWER_OFFSET + POWER_RANGE ) * (MENU_FORM_WIDTH-8)) / POWER_RANGE + OFFSETX+4;
for (int i=0; i <= 4; i++) {
ili9341_drawstring(step_text[i], button_start+12 + i * MENU_FORM_WIDTH/5, y+button_height-9);
}
@ -2060,7 +2060,7 @@ menu_select_touch(int i, int pos)
check_frequency_slider(slider_freq);
}
} else if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && keypad == KM_LOWOUTLEVEL) {
uistat.value = setting.offset + (touch_x - OFFSETX+4) *( -6 - -76) / (MENU_FORM_WIDTH-8) + -76;
uistat.value = setting.offset + (touch_x - OFFSETX+4) *( POWER_RANGE) / (MENU_FORM_WIDTH-8) + POWER_OFFSET - POWER_RANGE;
apply_step:
set_keypad_value(keypad);
apply:

@ -408,7 +408,7 @@ enum {
KM_30MHZ, KM_REPEAT, KM_OFFSET, KM_TRIGGER, KM_LEVELSWEEP, KM_SWEEP_TIME, KM_OFFSET_DELAY,
KM_FAST_SPEEDUP, KM_GRIDLINES, KM_MARKER, KM_MODULATION, KM_HIGHOUTLEVEL,
KM_R,KM_MOD,KM_CP,
#if 0
#if 1
KM_COR_AM,KM_COR_WFM, KM_COR_NFM,
#endif
KM_ATTACK,
@ -448,7 +448,7 @@ static const struct {
{keypads_freq , "MARKER\nFREQ"}, // KM_MARKER
{keypads_freq , "MODULATION\nFREQ"}, // KM_MODULATION
{keypads_plusmin , "LEVEL"}, // KM_HIGHOUTLEVEL
#if 0
#if 1
{keypads_plusmin , "COR\nAM"}, // KM_COR_AM
{keypads_plusmin , "COR\nWFM"}, // KM_COR_WFM
{keypads_plusmin , "COR\nNFM"}, // KM_COR_NFM
@ -747,7 +747,7 @@ const int8_t menu_drive_value[]={-38,-35,-33,-30,-27,-24,-21,-19, -7,-4,-2,1,4,7
#else
const int8_t menu_drive_value[]={-38,-35,-33,-30,-27,-24,-21,-19, -7,-4,-2,1,4,7,10,13};
#endif
#if 0
static UI_FUNCTION_ADV_CALLBACK(menu_lo_drive_acb)
{
(void)item;
@ -766,7 +766,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_lo_drive_acb)
// ui_mode_normal();
// draw_cal_status();
}
#endif
static UI_FUNCTION_ADV_CALLBACK(menu_mixer_drive_acb)
{
(void)item;
@ -1860,17 +1860,27 @@ static const menuitem_t menu_sweep_speed[] =
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_settings3[] =
static const menuitem_t menu_settings4[] =
{
// { MT_KEYPAD, KM_GRIDLINES, "MINIMUM\nGRIDLINES", "Enter minimum horizontal grid divisions"},
{ MT_ADV_CALLBACK, 0, "DEBUG\nFREQ", menu_debug_freq_acb},
{ MT_ADV_CALLBACK, 0, "ADF OUT", menu_adf_out_acb},
{ MT_KEYPAD, KM_LPF, "ULTRA\nSTART", "Enter ULTRA mode start freq"},
#if 0 // only used during development
#if 1 // 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"},
{ MT_KEYPAD, KM_COR_NFM, "COR\nNFM", "Enter NFM modulation correction"},
#endif
#ifdef __HARMONIC__
{ MT_SUBMENU,0, "HARMONIC", menu_harmonic},
#endif
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_settings3},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_settings3[] =
{
// { MT_KEYPAD, KM_GRIDLINES, "MINIMUM\nGRIDLINES", "Enter minimum horizontal grid divisions"},
{ MT_ADV_CALLBACK, 0, "ADF OUT", menu_adf_out_acb},
{ MT_KEYPAD, KM_LPF, "ULTRA\nSTART", "Enter ULTRA mode start freq"},
// { MT_KEYPAD | MT_LOW, KM_IF2, "IF2 FREQ", "Set to zero for no IF2"},
{ MT_KEYPAD, KM_R, "R", "Set R"},
{ MT_KEYPAD, KM_MOD, "MODULO", "Set MODULO"},
@ -1880,10 +1890,8 @@ static const menuitem_t menu_settings3[] =
#ifdef __HAM_BAND__
{ MT_ADV_CALLBACK, 0, "HAM\nBANDS", menu_settings_ham_bands},
#endif
#ifdef __HARMONIC__
{ MT_SUBMENU,0, "HARMONIC", menu_harmonic},
#endif
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_settings4},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
@ -2445,18 +2453,21 @@ set_numeric_value(void)
case KM_MODULATION:
set_modulation_frequency((int)uistat.value);
break;
#if 0
#if 1
case KM_COR_AM:
config.cor_am =(int)uistat.value;
config.cor_am = -(int)uistat.value;
config_save();
dirty = true;
break;
case KM_COR_WFM:
config.cor_wfm =(int)uistat.value;
config.cor_wfm = -(int)uistat.value;
config_save();
dirty = true;
break;
case KM_COR_NFM:
config.cor_nfm =(int)uistat.value;
config.cor_nfm = -(int)uistat.value;
config_save();
dirty = true;
break;
#endif
}

Loading…
Cancel
Save

Powered by TurnKey Linux.