SETUP magic update

pull/94/head
erikkaashoek 2 years ago
parent f753dbf736
commit e5dbf7024b

@ -1114,6 +1114,7 @@ config_t config = {
.high_level_output_offset = 0, // Uncalibrated, but checking code is not yet present .high_level_output_offset = 0, // Uncalibrated, but checking code is not yet present
.harmonic_level_offset = 0, // 10.5, should be in correction table now .harmonic_level_offset = 0, // 10.5, should be in correction table now
.harmonic_lna_level_offset = 0, // 10.5, should be in correction table now .harmonic_lna_level_offset = 0, // 10.5, should be in correction table now
.shift_level_offset = 0,
.shift1_level_offset = 0.5, .shift1_level_offset = 0.5,
.shift2_level_offset = 3, .shift2_level_offset = 3,
.shift3_level_offset = 0, .shift3_level_offset = 0,
@ -1721,6 +1722,7 @@ VNA_SHELL_FUNCTION(cmd_sweep)
int type = get_str_index(argv[0], sweep_cmd); int type = get_str_index(argv[0], sweep_cmd);
if (type >=0) { if (type >=0) {
set_sweep_frequency(type, value1); set_sweep_frequency(type, value1);
dirty = true;
return; return;
} }
// Parse sweep {go|abort} // Parse sweep {go|abort}
@ -1735,6 +1737,7 @@ VNA_SHELL_FUNCTION(cmd_sweep)
set_sweep_frequency(ST_STOP, value1); set_sweep_frequency(ST_STOP, value1);
if (value2) if (value2)
set_sweep_points(value2); set_sweep_points(value2);
dirty = true;
return; return;
usage: usage:
usage_printf("sweep {start(Hz)} [stop(Hz)] [points]\r\n"\ usage_printf("sweep {start(Hz)} [stop(Hz)] [points]\r\n"\

@ -804,6 +804,7 @@ typedef struct config {
float lna_level_offset; float lna_level_offset;
float harmonic_level_offset; float harmonic_level_offset;
float harmonic_lna_level_offset; float harmonic_lna_level_offset;
float shift_level_offset;
float shift1_level_offset; float shift1_level_offset;
float shift2_level_offset; float shift2_level_offset;
float shift3_level_offset; float shift3_level_offset;
@ -1471,8 +1472,8 @@ typedef struct properties {
//sizeof(properties_t) == 0x1200 //sizeof(properties_t) == 0x1200
#define CONFIG_MAGIC 0x434f4e66 /* 'CONF' */ #define CONFIG_MAGIC 0x434f4e67
#define SETTING_MAGIC 0x434f4e65 #define SETTING_MAGIC 0x434f4e66
extern int16_t lastsaveid; extern int16_t lastsaveid;
//extern properties_t *active_props; //extern properties_t *active_props;

@ -408,7 +408,7 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
{ {
// 0 1 2 // 0 1 2
#ifdef TINYSA4 #ifdef TINYSA4
static const char cmd_mode_list[] = "low|switch|receive_switch|out_switch|lna|harmonic|shift1|shift2|shift3|drive1|drive2|drive3|direct|direct_lna|ultra|ultra_lna|harmonic_lna|adf"; static const char cmd_mode_list[] = "low|switch|receive_switch|out_switch|lna|harmonic|shift|shift1|shift2|shift3|drive1|drive2|drive3|direct|direct_lna|ultra|ultra_lna|harmonic_lna|adf";
#else #else
static const char cmd_mode_list[] = "low|high|switch|receive_switch"; static const char cmd_mode_list[] = "low|high|switch|receive_switch";
#endif #endif
@ -431,6 +431,7 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
shell_printf(p, "lna", config.lna_level_offset); shell_printf(p, "lna", config.lna_level_offset);
shell_printf(p, "harmonic", config.harmonic_level_offset); shell_printf(p, "harmonic", config.harmonic_level_offset);
shell_printf(p, "harmonic_lna", config.harmonic_lna_level_offset); shell_printf(p, "harmonic_lna", config.harmonic_lna_level_offset);
shell_printf(p, "shift", config.shift_level_offset);
shell_printf(p, "shift1", config.shift1_level_offset); shell_printf(p, "shift1", config.shift1_level_offset);
shell_printf(p, "shift2", config.shift2_level_offset); shell_printf(p, "shift2", config.shift2_level_offset);
shell_printf(p, "shift3", config.shift3_level_offset); shell_printf(p, "shift3", config.shift3_level_offset);
@ -468,18 +469,19 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
case 3: config.out_switch_offset = v; break; case 3: config.out_switch_offset = v; break;
case 4: config.lna_level_offset = v; break; case 4: config.lna_level_offset = v; break;
case 5: config.harmonic_level_offset = v; break; case 5: config.harmonic_level_offset = v; break;
case 6: config.shift1_level_offset = v; break; case 6: config.shift_level_offset = v; break;
case 7: config.shift2_level_offset = v; break; case 7: config.shift1_level_offset = v; break;
case 8: config.shift3_level_offset = v; break; case 8: config.shift2_level_offset = v; break;
case 9: config.drive1_level_offset = v; break; case 9: config.shift3_level_offset = v; break;
case 10: config.drive2_level_offset = v; break; case 10: config.drive1_level_offset = v; break;
case 11: config.drive3_level_offset = v; break; case 11: config.drive2_level_offset = v; break;
case 12: config.direct_level_offset = v; break; case 12: config.drive3_level_offset = v; break;
case 13: config.direct_lna_level_offset = v; break; case 13: config.direct_level_offset = v; break;
case 14: config.ultra_level_offset = v; break; case 14: config.direct_lna_level_offset = v; break;
case 15: config.ultra_lna_level_offset = v; break; case 15: config.ultra_level_offset = v; break;
case 16: config.harmonic_lna_level_offset = v; break; case 16: config.ultra_lna_level_offset = v; break;
case 17: config.adf_level_offset = v; break; case 17: config.harmonic_lna_level_offset = v; break;
case 18: config.adf_level_offset = v; break;
#endif #endif
default: goto usage; default: goto usage;
} }
@ -492,7 +494,7 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
case 0: config.low_level_output_offset = v; config.output_is_calibrated = true; break; case 0: config.low_level_output_offset = v; config.output_is_calibrated = true; break;
case 1: config.high_level_output_offset = v; break; case 1: config.high_level_output_offset = v; break;
#ifdef TINYSA4 #ifdef TINYSA4
case 12: config.direct_level_output_offset = v; break; case 19: config.direct_level_output_offset = v; break;
#endif #endif
default: goto usage; default: goto usage;
} }

@ -4867,8 +4867,12 @@ again: // Spur redu
pureRSSI = 0; pureRSSI = 0;
else { else {
pureRSSI = Si446x_RSSI(break_on_operation); pureRSSI = Si446x_RSSI(break_on_operation);
if (LO_shifting && signal_path != PATH_DIRECT) if (LO_shifting && (signal_path != PATH_DIRECT)) {
pureRSSI += float_TO_PURE_RSSI(actual_rbw_x10>USE_SHIFT2_RBW ? config.shift2_level_offset : (lf < LOW_SHIFT_FREQ ? config.shift1_level_offset: 0.0)); if (f < 5000000)
pureRSSI += float_TO_PURE_RSSI(actual_rbw_x10>USE_SHIFT2_RBW ? config.shift2_level_offset : (lf < LOW_SHIFT_FREQ ? config.shift1_level_offset: 0.0));
else
pureRSSI += float_TO_PURE_RSSI(config.shift_level_offset);
}
} }
if (setting.unit == U_RAW) if (setting.unit == U_RAW)
pureRSSI += - float_TO_PURE_RSSI(120); // don't add correction; pureRSSI += - float_TO_PURE_RSSI(120); // don't add correction;
@ -6218,9 +6222,7 @@ enum {
#ifdef TINYSA4 #ifdef TINYSA4
freq_t test_freq = 0; freq_t test_freq = 0;
//#define CAL_LEVEL -23.5 #define CAL_LEVEL -35.30
//#define CAL_LEVEL -24.2
#define CAL_LEVEL -35.60
#else #else
#define CAL_LEVEL (has_esd ? -26.2 : -25) #define CAL_LEVEL (has_esd ? -26.2 : -25)
#endif #endif
@ -6338,7 +6340,9 @@ static volatile int test_wait = false;
static float test_value; static float test_value;
#ifdef TINYSA4 #ifdef TINYSA4
static freq_t direct_test_freq = 900000000; static freq_t spur_test_freq = 900000000;
static freq_t direct_test_freq = 180000000;
void determine_direct_test_freq(void) { void determine_direct_test_freq(void) {
return; return;
int old_ultra = config.ultra; int old_ultra = config.ultra;
@ -7705,7 +7709,7 @@ float get_jump_config(int i) {
return 0; return 0;
} }
enum {CS_NORMAL, CS_LNA, CS_SWITCH, CS_ULTRA, CS_ULTRA_LNA, CS_DIRECT_REF, CS_DIRECT, CS_DIRECT_LNA, CS_HARMONIC, CS_HARMONIC_LNA, /* CS_BPF_REF, CS_BPF, */ CS_CORRECTION_REF, CS_CORRECTION_LNA, CS_MAX }; enum {CS_NORMAL, CS_LNA, CS_SWITCH, CS_ULTRA, CS_ULTRA_LNA, CS_DIRECT_REF, /* CS_DIRECT,*/ CS_DIRECT_LNA, CS_SPUR_REF, CS_SPUR_ERROR, CS_HARMONIC, CS_HARMONIC_LNA, /* CS_BPF_REF, CS_BPF, */ CS_CORRECTION_REF, CS_CORRECTION_LNA, CS_MAX };
#define ULTRA_HARMONIC_CAL_FREQ 5340000000 #define ULTRA_HARMONIC_CAL_FREQ 5340000000
#else #else
enum {CS_NORMAL, CS_SWITCH, CS_MAX }; enum {CS_NORMAL, CS_SWITCH, CS_MAX };
@ -7826,6 +7830,7 @@ void calibrate(void)
// setting.rbw_x10 = 3; // setting.rbw_x10 = 3;
test_path = 3; // Ultra lna path test_path = 3; // Ultra lna path
force_signal_path = true; force_signal_path = true;
setting.spur_removal = S_OFF;
// set_reflevel(-95); // set_reflevel(-95);
} else if (i <= 1) { } else if (i <= 1) {
if (i == 1) if (i == 1)
@ -7837,6 +7842,7 @@ void calibrate(void)
set_refer_output(0); // 30MHz set_refer_output(0); // 30MHz
setting.spur_removal = S_AUTO_OFF; setting.spur_removal = S_AUTO_OFF;
} }
test_acquire(TEST_JUMP); // Acquire test test_acquire(TEST_JUMP); // Acquire test
set_reflevel(actual_t[sweep_points/3]+5); set_reflevel(actual_t[sweep_points/3]+5);
plot_into_index(measured); plot_into_index(measured);
@ -7914,23 +7920,33 @@ void calibrate(void)
test_path = 1; // Normal lna path test_path = 1; // Normal lna path
force_signal_path = true; force_signal_path = true;
break; break;
case CS_DIRECT_REF:
set_sweep_frequency(ST_CENTER, direct_test_freq); case CS_SPUR_REF:
setting.spur_removal = S_OFF;
goto spur_common;
case CS_SPUR_ERROR:
setting.spur_removal = S_AUTO_OFF;
config.shift_level_offset = 0;
spur_common:
set_sweep_frequency(ST_CENTER, spur_test_freq);
test_path = 2; // Ultra test_path = 2; // Ultra
force_signal_path = true; force_signal_path = true;
break; break;
case CS_DIRECT: case CS_DIRECT_REF:
test_path = 0; // Normal
setting.spur_removal = S_OFF;
direct_common:
set_sweep_frequency(ST_CENTER, direct_test_freq); set_sweep_frequency(ST_CENTER, direct_test_freq);
test_path = 4; // Direct path at 900MHz
force_signal_path = true; force_signal_path = true;
// config.direct_level_offset -= 1.0;
break; break;
#if 0
case CS_DIRECT:
test_path = 4; // Direct path at 900MHz
goto direct_common;
#endif
case CS_DIRECT_LNA: case CS_DIRECT_LNA:
set_sweep_frequency(ST_CENTER, direct_test_freq);
test_path = 5; // Direct lna path at 900MHz test_path = 5; // Direct lna path at 900MHz
force_signal_path = true; goto direct_common;
// config.direct_lna_level_offset += 1.0;
break;
case CS_HARMONIC: case CS_HARMONIC:
test_path = 6; // harmonic path test_path = 6; // harmonic path
force_signal_path = true; force_signal_path = true;
@ -8005,7 +8021,7 @@ void calibrate(void)
#ifdef TINYSA4 #ifdef TINYSA4
|| (calibration_stage == CS_LNA && peakLevel < -40) || (calibration_stage == CS_LNA && peakLevel < -40)
|| (calibration_stage == CS_ULTRA && peakLevel < -40) || (calibration_stage == CS_ULTRA && peakLevel < -40)
|| (calibration_stage == CS_DIRECT && peakLevel < direct_level - 10) || (calibration_stage == CS_DIRECT_LNA && peakLevel < direct_level - 10)
#endif #endif
) { ) {
#ifdef TINYSA4 #ifdef TINYSA4
@ -8033,14 +8049,17 @@ low_level:
calibration_stage -= 2; // skip back to REF measurement calibration_stage -= 2; // skip back to REF measurement
} }
} }
else if (calibration_stage == CS_SPUR_REF)
direct_level = marker_to_value(0); // Re-use direct_level;
else if (calibration_stage == CS_SPUR_ERROR)
config.shift_level_offset = direct_level - marker_to_value(0);
else if (calibration_stage == CS_DIRECT_REF) else if (calibration_stage == CS_DIRECT_REF)
direct_level = marker_to_value(0); direct_level = marker_to_value(0);
else if (calibration_stage == CS_DIRECT){ // else if (calibration_stage == CS_DIRECT)
// config.direct_level_offset += 1.0; // offset = set_actual_power(direct_level);
offset = set_actual_power(direct_level); else if (calibration_stage == CS_DIRECT_LNA){
} else if (calibration_stage == CS_DIRECT_LNA){
// config.direct_lna_level_offset -= 1.0;
offset = set_actual_power(direct_level); offset = set_actual_power(direct_level);
config.direct_level_offset = config.direct_lna_level_offset - (config.low_level_offset - config.lna_level_offset);
} }
else else
#endif #endif

@ -5150,7 +5150,9 @@ static const menuitem_t menu_trigger[] = {
#ifdef __BEEP__ #ifdef __BEEP__
{ MT_ADV_CALLBACK, T_BEEP, "BEEP", menu_trigger_acb}, { MT_ADV_CALLBACK, T_BEEP, "BEEP", menu_trigger_acb},
#endif #endif
#ifdef TINYSA4
{ MT_ADV_CALLBACK, T_AUTO_SAVE, "AUTO SAVE", menu_trigger_acb}, { MT_ADV_CALLBACK, T_AUTO_SAVE, "AUTO SAVE", menu_trigger_acb},
#endif
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back { MT_NONE, 0, NULL, menu_back} // next-> menu_back
}; };
@ -5204,7 +5206,7 @@ static const menuitem_t menu_storage[] = {
{ MT_CALLBACK, FMT_CFG_FILE, "SAVE\nCONFIG", menu_sdcard_cb}, { MT_CALLBACK, FMT_CFG_FILE, "SAVE\nCONFIG", menu_sdcard_cb},
{ MT_ADV_CALLBACK, 0, "MHz\nCSV", menu_mhz_csv_acb }, { MT_ADV_CALLBACK, 0, "MHz\nCSV", menu_mhz_csv_acb },
{ MT_CALLBACK, FMT_CSV_FILE, "SAVE\nTRACES", menu_save_traces_cb}, { MT_CALLBACK, FMT_CSV_FILE, "SAVE\nTRACES", menu_save_traces_cb},
{ MT_KEYPAD, KM_INTERVAL, "INTERVAL\n\b%s", NULL }, // { MT_KEYPAD, KM_INTERVAL, "INTERVAL\n\b%s", NULL },
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back { MT_NONE, 0, NULL, menu_back} // next-> menu_back
}; };
#endif #endif

Loading…
Cancel
Save

Powered by TurnKey Linux.