From de775c2b664679645c37fb168ccd7f21e48299de Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Thu, 3 Oct 2024 12:07:07 +0200 Subject: [PATCH 1/5] Small update --- main.c | 2 +- nanovna.h | 4 ++-- sa_core.c | 43 ++++++++++++++++++++++++------------------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/main.c b/main.c index db49bba..272a7d3 100644 --- a/main.c +++ b/main.c @@ -232,7 +232,7 @@ static THD_FUNCTION(Thread1, arg) } } else if (sweep_mode & SWEEP_SELFTEST) { // call from lowest level to save stack space - self_test(setting.test); + selftest(setting.test); completed = true; // sweep_mode = SWEEP_ENABLE; #ifdef __SINGLE_LETTER__ diff --git a/nanovna.h b/nanovna.h index b707ae0..ee077d8 100644 --- a/nanovna.h +++ b/nanovna.h @@ -482,7 +482,7 @@ void MenuDirty(void); void toggle_LNA(void); void toggle_AGC(void); void redrawHisto(void); -void self_test(int); +void selftest(int); void set_decay(int); void set_attack(int); void set_noise(int); @@ -1838,7 +1838,7 @@ void update_rbw(void); void set_fast_speedup(int); void set_faster_speedup(int); //extern int setting_measurement; -void self_test(int); +void selftest(int); //extern int setting_test; void wait_user(void); void calibrate(void); diff --git a/sa_core.c b/sa_core.c index ed07505..cbede0a 100644 --- a/sa_core.c +++ b/sa_core.c @@ -405,7 +405,7 @@ void set_input_path(freq_t f) } else if (MODE_HIGH(setting.mode)) signal_path = PATH_HIGH; - else if (direct_test && f >= 900000000 && f < 1100000000) + else if (direct_test && f >= 830000000 && f < 1130000000) signal_path = PATH_DIRECT; else if (config.direct && f >= config.direct_start && f < config.direct_stop) signal_path = PATH_DIRECT; @@ -4413,7 +4413,7 @@ again: // Spur redu ADF4351_R_counter(-3); } else { if (hw_if) - ADF4351_R_counter(7); + ADF4351_R_counter(5); else ADF4351_R_counter(4); } @@ -6301,7 +6301,7 @@ const test_case_t test_case [] = TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ_ULTRA, 30, 1, CAL_LEVEL, 10, -85), // 4 Test Ultra mode #define TEST_SILENCE 4 TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 200, 100, -70, 0, 0), // 5 Wide band noise floor low mode - TEST_CASE_STRUCT(TC_ABOVE, TP_30MHZ_DIRECT,900, 10, -90, 0, -90), // 6 Direct path with harmonic + TEST_CASE_STRUCT(TC_ABOVE, TP_30MHZ_DIRECT,900, 10, -60, 0, -80), // 6 Direct path with harmonic TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZEXTRA, 30, 14, CAL_LEVEL, 26, -45), // 7 BPF loss and stop band TEST_CASE_STRUCT(TC_FLAT, TP_10MHZEXTRA, 30, 14, -28, 9, -60), // 8 BPF pass band flatness TEST_CASE_STRUCT(TC_BELOW, TP_15MHZ_LNA2, 855, 1, -80, 0, -80), // 9 LPF cutoff @@ -6391,8 +6391,8 @@ static volatile int test_wait = false; static float test_value; #ifdef TINYSA4 -static freq_t spur_test_freq = 900000000; -static freq_t direct_test_freq = 180000000; +static freq_t spur_test_freq = 930000000; +static freq_t direct_test_freq = 870000000; // 180000000; void determine_direct_test_freq(void) { if (hw_if) @@ -6415,7 +6415,10 @@ void determine_direct_test_freq(void) { } static float lpf_test_level = 0; -#define LPF_TEST_FREQ 795000000 +#define LPF_TEST_FREQ (hw_if ? 915000000 : 795000000) +#define LPF_TEST_FREQ2 (hw_if ? 1005000000 : 855000000) + + void determine_lpf_test_level(void) { int old_ultra = config.ultra; config.ultra = true; @@ -6843,6 +6846,8 @@ common_silent: break; #ifdef TINYSA4 case TP_15MHZ_LNA: + force_signal_path = true; + test_path = 1; determine_lpf_test_level(); goto simple; case TP_15MHZ_LNA2: @@ -6850,6 +6855,9 @@ common_silent: test_path = 1; goto simple; case TP_30MHZ_DIRECT: + force_signal_path = true; + test_path = 4; + goto simple; case TP_30MHZ_ULTRA: case TP_30MHZ_LNA: #endif @@ -6911,23 +6919,20 @@ common_silent: TRACE_ENABLE(TRACE_STORED_FLAG); setting.stored[TRACE_STORED] = true; set_reflevel(test_case[i].pass+10); + freq_t c_freq = (freq_t)(test_case[i].center * 1000000); #ifdef TINYSA4 if (test_case[i].kind == TC_JUMP) { - set_sweep_frequency(ST_CENTER, test_freq); + c_freq = test_freq; setting.repeat = 10; } - else -#endif - { - freq_t c_freq = (freq_t)(test_case[i].center * 1000000); -#ifdef TINYSA4 - if (test_case[i].setup == TP_30MHZ_DIRECT) + else if (test_case[i].setup == TP_15MHZ_LNA2) + c_freq = LPF_TEST_FREQ2; + else if (test_case[i].setup == TP_30MHZ_DIRECT) c_freq = direct_test_freq; - if (test_case[i].setup == TP_15MHZ_LNA) + else if (test_case[i].setup == TP_15MHZ_LNA) c_freq = LPF_TEST_FREQ; #endif - set_sweep_frequency(ST_CENTER, c_freq); - } + set_sweep_frequency(ST_CENTER, c_freq); set_sweep_frequency(ST_SPAN, (freq_t)(test_case[i].span * 1000000)); draw_cal_status(); } @@ -7019,7 +7024,7 @@ void sort_spur_count(void) { //static bool test_wait = false; static int test_step = 0; -void self_test(int test) +void selftest(int test) { bool no_wait = false; #ifdef TINYSA4 @@ -7857,7 +7862,7 @@ void calibrate(void) // setting.frequency_IF = config.frequency_IF1; // set in selftest float direct_level=0.0; setting.test_argument = -7; - self_test(0); + selftest(0); int if_error = peakFreq - 30000000; if (if_error > -1000000 && if_error < 1000000) { config.frequency_IF1 += if_error; @@ -7999,7 +8004,7 @@ void calibrate(void) force_signal_path = true; break; case CS_DIRECT_REF: - test_path = 0; // Normal + test_path = 3; // Ultra LNA setting.spur_removal = S_OFF; direct_common: set_sweep_frequency(ST_CENTER, direct_test_freq); From a85ca929b16226dbd139e856f924d0c34bb69733 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 8 Oct 2024 13:19:42 +0200 Subject: [PATCH 2/5] Updated selftest and tables --- main.c | 52 +++++++++++++++++++++++++++++----------------------- nanovna.h | 10 ++++++---- sa_core.c | 25 +++++++++++++------------ ui.c | 44 +++++++++++++++++++++++++++++++++++++++----- 4 files changed, 87 insertions(+), 44 deletions(-) diff --git a/main.c b/main.c index 272a7d3..157fb0f 100644 --- a/main.c +++ b/main.c @@ -1269,34 +1269,34 @@ const float v5_2_lna_level_offset = 7; const freq_t v4_6_correction_frequency[CORRECTION_SIZE][CORRECTION_POINTS]= { - /* low */ { 100000, 1000000, 30000000, 220000000, 420000000, 750000000, 860000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000}, - /* low lna */ { 100000, 1000000, 30000000, 220000000, 360000000, 420000000, 630000000, 750000000, 810000000, 860000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000}, + /* low */ { 100000, 1000000, 7000000, 30000000, 90000000, 220000000, 420000000, 460000000, 750000000, 860000000, 870000000, 880000000, 890000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000}, + /* low lna */ { 100000, 1000000, 30000000, 220000000, 360000000, 420000000, 630000000, 750000000, 810000000, 870000000, 880000000, 890000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000, 900000000}, /* ultra */ { 30000000, 700000000, 1270000000, 2090000000, 2620000000, 4130000000, 4710000000, 5090000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000}, - /* ultra lna */ { 30000000, 1120000000, 2400000000, 3780000000, 3930000000, 4110000000, 4360000000, 4450000000, 4970000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000}, - /* direct */ { 140000000, 180000000, 280000000, 330000000, 420000000, 560000000, 830000000, 910000000, 980000000, 1040000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000}, - /* direct lna */ { 140000000, 180000000, 280000000, 330000000, 420000000, 560000000, 830000000, 910000000, 980000000, 1040000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, }, - /* harm */ { 30000000, 4000000000, 4601336303, 5095768374, 5296213808, 5496659243, 5804008909, 6298440980, 6806236080, 7193763920, 7501113586, 7701559020, 7995545657, 8302895323, 8797327394, 9104677060, 9305122494, 9505567929, 9799554566, 10000000000, }, - /* harm lna */ { 30000000, 4000000000, 4093541203, 4200445434, 4293986637, 4400890869, 4601336303, 5296213808, 5897550111, 6405345212, 6498886414, 6806236080, 7100222717, 7594654788, 7795100223, 8102449889, 8503340757, 8997772829, 9599109131, 10000000000, }, - /* out */ { 100000, 800000, 5000000, 20000000, 100000000, 230000000, 450000000, 700000000, 850000000, 890000000, 920000000, 920000000, 920000000, 920000000, 920000000, 920000000, 920000000, 920000000, 920000000, 920000000, }, - /* direct */ { 823000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, }, - /* adf */ { 140000000, 210000000, 260000000, 290000000, 340000000, 370000000, 410000000, 460000000, 500000000, 520000000, 570000000, 700000000, 1170000000, 1370000000, 2700000000, 3000000000, 3300000000, 4300000000, 4400000000, 4400000000, }, - /* ultra */ { 100000, 600000, 3000000, 40000000, 260000000, 730000000, 1020000000, 3600000000, 4700000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000, }, + /* ultra lna */ { 30000000, 1120000000, 2400000000, 3540000000, 3780000000, 3930000000, 4110000000, 4360000000, 4450000000, 4540000000, 4700000000, 4970000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000, 5410000000}, + /* direct */ { 140000000, 180000000, 280000000, 420000000, 560000000, 830000000, 920000000, 1000000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000}, + /* direct lna */ { 140000000, 170000000, 180000000, 280000000, 330000000, 440000000, 560000000, 830000000, 900000000, 960000000, 1040000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000}, + /* harm */ { 30000000, 5000000000, 5420000000, 6790000000, 7240000000, 7650000000, 7870000000, 8220000000, 8520000000, 8810000000, 9090000000, 9240000000, 9810000000, 10000000000, 10000000000, 10000000000, 10000000000, 10000000000, 10000000000, 10000000000}, + /* harm lna */ { 30000000, 5000000000, 5440000000, 5950000000, 6420000000, 6780000000, 7200000000, 7570000000, 7780000000, 7930000000, 8230000000, 8540000000, 9610000000, 9700000000, 10000000000, 10000000000, 10000000000, 10000000000, 10000000000, 10000000000}, + /* out */ { 100000, 800000, 3000000, 8000000, 80000000, 120000000, 200000000, 250000000, 550000000, 650000000, 780000000, 850000000, 890000000, 920000000, 920000000, 920000000, 920000000, 920000000, 920000000, 920000000,}, + /* direct */ { 823000000, 970000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000, 1130000000}, + /* adf */ { 140000000, 230000000, 410000000, 510000000, 590000000, 740000000, 1150000000, 1320000000, 1390000000, 1700000000, 4500000000, 4500000000, 4500000000, 4500000000, 4500000000, 4500000000, 4500000000, 4500000000, 4500000000, 4400000000}, + /* ultra */ { 100000, 800000, 5000000, 80000000, 310000000, 700000000, 840000000, 1130000000, 2100000000, 3300000000, 4100000000, 4800000000, 5300000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000, 5400000000} }; const float v4_6_correction_value[CORRECTION_SIZE][CORRECTION_POINTS]= { - /* low */ { 4, 0.25, 0.0001, 1, 0.0001, 0.0001, 1.5, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, }, - /* low lna */ { 4.78, 0.12, 0.0001, 1, 1, 0.5, -0.5, 0.4, 0.5, 1.5, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, 2.97, }, - /* ultra */ { 0.0001, 0.22, 1.5, 1.75, 3.4, 2.97, 6.97, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, }, - /* ultra lna */ { 0.0001, 1.5, 1.5, 6, 6.5, 8.5, 16, 16.5, 16.6, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, }, - /* direct */ { 53.7, 46, 34.2, 30.5, 24.3, 17.2, 4.46, 1.2, -0.34, -0.25, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, }, - /* direct lna */ { 54.5, 47, 35, 31, 25, 17.3, 5.62, 2.12, 1.1, 0.7, 2.16, 2.16, 2.16, 2.16, 2.16, 2.16, 2.16, 2.16, 2.16, 2.16, }, - /* harm */ { 2, 18.69, 21.69, 21.69, 20.69, 20.69, 23.1, 25.19, 29.7, 26.69, 26.19, 27.69, 33.69, 37.19, 40.69, 45.69, 48.19, 49.48, 47.7, 48.7, }, - /* harm lna */ { 2.8, 22.25, 23.25, 25.75, 29.75, 32.25, 34.25, 33.25, 36.25, 42.75, 43.75, 44.7, 42.7, 42.25, 43.75, 50.25, 55.75, 61.25, 65.25, 72.75, }, - /* out */ { 0.0001, -1.82, -3, -3.16, -3.5, -2.06, -3.68, -3.7, -2.74, -1.3, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, 1.28, }, - /* direct */ { -3.14, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, }, - /* adf */ { 31.4, 17.14, 15.46, 21.6, 14.3, 18.2, 30.7, 11.04, 1.74, -1.16, 1.67, -5.96, -6.55, -11.4, -7.34, -10.7, -5.4, -0.77, 3.07, 3.07, }, - /* ultra */ { -0.5, -2.15, -3.18, -3.45, -2.33, -3.48, -2.05, -0.01, 3.48, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, 0.73, }, + /* low */ { 4, 0.1, -1, -0.6, -1, 0.5, 0.0001, -1, -0.7, 0.5, 0.3, 1, 1.5, 2.28, 2.28, 2.28, 2.28, 2.28, 2.28, 2.28}, + /* low lna */ { 4.78, -0.5, -1.1, -0.05, 0.5, -0.2, -1, -0.5, -0.4, 0.2, 0.8, 1, 1.7, 1.7, 1.7, 1.7, 1.7, 1.7, 1.7, 1.7}, + /* ultra */ { 0.0001, 0.3, 2.4, 2.34, 3.3, 4.3, 8.3, 7.8, 8.4, 8.4, 8.4, 8.4, 8.4, 8.4, 8.4, 8.4, 8.4, 8.4, 8.4, 8.4}, + /* ultra lna */ { 0.0001, 1.8, 2.1, 7.1, 7.4, 8.02, 10, 17, 17.4, 18.3, 18.3, 17.7, 21, 21, 21, 21, 21, 21, 21, 21}, + /* direct */ { 55.9, 47.83, 35.46, 24.2, 15.84, 2.47, -0.03, -0.2, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5}, + /* direct lna */ { 55, 49.54, 48, 35.46, 31, 22.6, 15.49, 2.49, 0.001, -0.5, -0.5, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47, 0.47}, + /* harm */ { 0, 15.5, 14.5, 21.5, 18, 17.5, 19.8, 27.6, 29.3, 33, 38.9, 39.4, 33.3, 31.47, 31.47, 31.47, 31.47, 31.47, 31.47, 31.47}, + /* harm lna */ { 0.01, 26.2, 25.26, 26.68, 33.02, 35.12, 32.01, 30.4, 30.87, 32.8, 40.46, 45.4, 54.47, 55.82, 68.5, 68.5, 68.5, 68.5, 68.5, 68.5}, + /* out */ { -1, -2.81, -4.11, -4.26, -5.15, -5.08, -3.57, -3.32, -5.24, -4.6, -4.88, -4.15, -3.27, -0.82, -0.82, -0.82, -0.82, -0.82, -0.82, -0.82}, + /* direct */ { -4.12, -2.58 , -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48, -0.48}, + /* adf */ { 29.57, 17, 22.88, 0.1, 2, -4.5, -3.8, -9.43, -10, -10.9, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 3.07}, + /* ultra */ { -1.4, -3, -4.46, -5, -3.8, -5, -4.56, -3.38, -3.2, 1, 0.6, 4, 5, 2.53, 2.53, 2.53, 2.53, 2.53, 2.53, 2.53}, }; const float v4_6_harmonic_lna_level_offset = 0; // should be in correction table now -7; // Depends on where the transition to harmonic is done!!!!!! TODO find best frequency to transition to harmonic @@ -2404,7 +2404,9 @@ static const VNAShellCommand commands[] = {"touchcal" , cmd_touchcal , CMD_WAIT_MUTEX}, {"touchtest" , cmd_touchtest , CMD_WAIT_MUTEX}, {"pause" , cmd_pause , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, +#ifdef TINYSA4 {"restart" , cmd_restart , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, +#endif {"resume" , cmd_resume , CMD_WAIT_MUTEX | CMD_RUN_IN_LOAD}, {"wait" , cmd_wait , CMD_RUN_IN_LOAD}, // This lets the sweep continue {"repeat" , cmd_repeat , CMD_RUN_IN_LOAD}, @@ -3143,11 +3145,15 @@ int main(void) memcpy(config.correction_value, v4_6_correction_value, sizeof(config.correction_value)); config.harmonic_level_offset = v4_6_harmonic_level_offset; config.harmonic_lna_level_offset = v4_6_harmonic_lna_level_offset; + config.low_level_output_offset = 1; + // ULTRA_MAX_FREQ = 5450000000ULL; } // else // ULTRA_MAX_FREQ = 5340000000ULL; ULTRA_MAX_FREQ = 4350000000 + config.frequency_IF1; + config.direct_start = config.frequency_IF1 - 10000000; + config.direct_stop = config.frequency_IF1 + 10000000; } set_freq_boundaries(); #endif diff --git a/nanovna.h b/nanovna.h index ee077d8..74ac9d5 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -#ifdef TINYSA_F303 +//#ifdef TINYSA_F303 #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" #endif @@ -26,7 +26,7 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -#endif +//#endif #ifdef TINYSA_F072 #ifdef TINYSA_F303 @@ -143,6 +143,7 @@ typedef uint32_t freq_t; #define DEFAULT_IF 433800000 #define DEFAULT_SPUR_IF 434000000 #define DEFAULT_MAX_FREQ 350000000 +#define NORMAL_MAX_FREQ DEFAULT_MAX_FREQ #define MAX_LO_FREQ 959800000UL #define MIN_LO_FREQ 240000000UL #define MIN_BELOW_LO 550000000UL @@ -1355,6 +1356,7 @@ typedef struct setting #define PRESET_NAME_LENGTH 10 char preset_name[PRESET_NAME_LENGTH]; #endif + bool dBuV; int64_t test_argument; // used for tests uint32_t checksum; // must be last and at 4 byte boundary }setting_t; @@ -1491,8 +1493,8 @@ typedef struct properties { //sizeof(properties_t) == 0x1200 -#define CONFIG_MAGIC 0x434f4e69 -#define SETTING_MAGIC 0x434f4e69 +#define CONFIG_MAGIC 0x434f4e6a +#define SETTING_MAGIC 0x434f4e6a extern int16_t lastsaveid; //extern properties_t *active_props; diff --git a/sa_core.c b/sa_core.c index cbede0a..c50dc46 100644 --- a/sa_core.c +++ b/sa_core.c @@ -536,7 +536,7 @@ void update_min_max_freq(void) maxFreq = MAX_LOW_OUTPUT_FREQ; #endif #else - maxFreq = NORMAL_MAX_FREQ; + maxFreq = DEFAULT_MAX_FREQ; #endif break; case M_HIGH: @@ -4413,7 +4413,7 @@ again: // Spur redu ADF4351_R_counter(-3); } else { if (hw_if) - ADF4351_R_counter(5); + ADF4351_R_counter(4); else ADF4351_R_counter(4); } @@ -4488,6 +4488,8 @@ again: // Spur redu actual_drive = 3; // else if (lf < DRIVE0_MAX_FREQ) // below 600MHz // actual_drive = 0; + else if (setting.mode == M_GENLOW && hw_if) + actual_drive = 0; else if (lf < DRIVE1_MAX_FREQ || hw_if) // below 1.2GHz actual_drive = 1; else if (lf < DRIVE2_MAX_FREQ) // below 2GHz @@ -6392,18 +6394,17 @@ static float test_value; #ifdef TINYSA4 static freq_t spur_test_freq = 930000000; -static freq_t direct_test_freq = 870000000; // 180000000; +static freq_t direct_test_freq = 990000000; // 180000000; void determine_direct_test_freq(void) { - if (hw_if) - direct_test_freq = 870000000; - return; + if (!hw_if) + return; int old_ultra = config.ultra; config.ultra = true; float max_level = -150; set_refer_output(0); - for (freq_t test_freq = 900000000UL; test_freq < 1000000000UL; test_freq += 30000000) { + for (freq_t test_freq = 1020000000UL; test_freq < 1100000000UL; test_freq += 30000000) { dirty = true; float v = PURE_TO_float(perform(false, 0, test_freq, false)); if (v > max_level) { @@ -7780,7 +7781,7 @@ float get_jump_config(int i) { return 0; } -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 }; +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 #else enum {CS_NORMAL, CS_SWITCH, CS_MAX }; @@ -8010,7 +8011,7 @@ void calibrate(void) set_sweep_frequency(ST_CENTER, direct_test_freq); force_signal_path = true; break; -#if 0 +#if 1 case CS_DIRECT: test_path = 4; // Direct path at 900MHz goto direct_common; @@ -8126,11 +8127,11 @@ low_level: config.shift_level_offset = direct_level - marker_to_value(0); else if (calibration_stage == CS_DIRECT_REF) direct_level = marker_to_value(0); -// else if (calibration_stage == CS_DIRECT) -// offset = set_actual_power(direct_level); + else if (calibration_stage == CS_DIRECT) + offset = set_actual_power(direct_level); else if (calibration_stage == CS_DIRECT_LNA){ offset = set_actual_power(direct_level); - config.direct_level_offset = config.direct_lna_level_offset - (config.low_level_offset - config.lna_level_offset); +// config.direct_level_offset = config.direct_lna_level_offset - (config.low_level_offset - config.lna_level_offset); } else #endif diff --git a/ui.c b/ui.c index 11a9217..82cb6a6 100644 --- a/ui.c +++ b/ui.c @@ -2453,6 +2453,18 @@ static UI_FUNCTION_ADV_CALLBACK(menu_modulation_acb) // menu_move_back(false); // Don't move back } +static UI_FUNCTION_ADV_CALLBACK(menu_level_in_dBuV) +{ + (void)item; + (void)data; + if (b){ + b->icon = setting.dBuV ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; + return; + } + setting.dBuV = !setting.dBuV; + menu_move_back(false); +} + static UI_FUNCTION_ADV_CALLBACK(menu_smodulation_acb){ (void)item; (void)data; @@ -4361,6 +4373,7 @@ static const menuitem_t menu_modulation[] = { { MT_FORM | MT_ADV_CALLBACK | MT_LOW, MO_EXTERNAL,MT_CUSTOM_LABEL, menu_modulation_acb}, { MT_FORM | MT_KEYPAD, KM_MODULATION, "FREQ: %s", "1Hz..5kHz"}, #endif + { MT_FORM | MT_ADV_CALLBACK, 0, "Level in dBuV", menu_level_in_dBuV}, { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back }; @@ -5435,19 +5448,31 @@ static void fetch_numeric_target(uint8_t mode) end_level = level_max(); uistat.value += setting.external_gain; end_level += setting.external_gain; + char *u = "m"; + float el = end_level; + if (setting.dBuV) { + u = "uV"; + uistat.value += 107; + el += 107; + } if (setting.level_sweep != 0) - plot_printf(uistat.text, sizeof uistat.text, "%.1f to %.1fdBm", uistat.value, end_level); + plot_printf(uistat.text, sizeof uistat.text, "%.1f to %.1fdBm", uistat.value, el); else #ifdef TINYSA4 - plot_printf(uistat.text, sizeof uistat.text, "%+.1fdBm %s", uistat.value, (setting.disable_correction?"Uncorrected":"")); + plot_printf(uistat.text, sizeof uistat.text, "%+.1fdB%s %s", uistat.value, u, (setting.disable_correction?"Uncorrected":"")); #else - plot_printf(uistat.text, sizeof uistat.text, "%+.1fdBm", uistat.value); + plot_printf(uistat.text, sizeof uistat.text, "%+.1fdB%s", uistat.value, u); #endif break; case KM_HIGHOUTLEVEL: uistat.value = get_level(); // compensation for dB offset during low output mode uistat.value += setting.external_gain; - plot_printf(uistat.text, sizeof uistat.text, "%+.1fdBm", uistat.value); + char *unit = "m"; + if (setting.dBuV) { + unit = "uV"; + uistat.value += 107; + } + plot_printf(uistat.text, sizeof uistat.text, "%+.1fdB%s", uistat.value, unit); break; case KM_DECAY: uistat.value = setting.decay; @@ -5711,9 +5736,13 @@ set_numeric_value(void) set_repeat(uistat.value); break; case KM_LOWOUTLEVEL: + if (setting.dBuV) + uistat.value -= 107; set_level(uistat.value - setting.external_gain); break; case KM_HIGHOUTLEVEL: + if (setting.dBuV) + uistat.value -= 107; set_level(uistat.value - setting.external_gain); break; case KM_DECAY: @@ -7015,7 +7044,6 @@ menu_select_touch(const menuitem_t * m, int i, int pos) while (touch_check() != EVT_TOUCH_NONE){ touch_position(&touch_x, &touch_y); if (abs(touch_x - prev_touch_x) < 2) continue; - fetch_numeric_target(keypad); int new_slider = touch_x - LCD_WIDTH/2; // Can have negative outcome if (new_slider < - (MENU_FORM_WIDTH-8)/2 - 1) @@ -7081,7 +7109,10 @@ menu_select_touch(const menuitem_t * m, int i, int pos) chThdSleepMilliseconds(100); } else if (keypad == KM_LOWOUTLEVEL) { uistat.value = setting.external_gain + ((touch_x - OFFSETX+4) * level_range() ) / (MENU_FORM_WIDTH-8) + level_min() ; + bool old_dBuV = setting.dBuV; + setting.dBuV = false; set_keypad_value(keypad); + setting.dBuV = old_dBuV;; draw_menu_mask(1< Date: Sun, 20 Oct 2024 07:56:59 +0200 Subject: [PATCH 3/5] IF updates --- nanovna.h | 4 ++-- sa_cmd.c | 10 ++++++-- sa_core.c | 68 ++++++++++++++++++------------------------------------- 3 files changed, 32 insertions(+), 50 deletions(-) diff --git a/nanovna.h b/nanovna.h index 74ac9d5..4c97526 100644 --- a/nanovna.h +++ b/nanovna.h @@ -156,8 +156,8 @@ typedef uint32_t freq_t; typedef uint64_t freq_t; #define FREQ_MULTIPLIER 100 // Multiplier of the 30MHz reference to get accurate frequency correction #define VARIANT(X,Y) (Y) -#define DEFAULT_IF ((freq_t)977400000) -#define DEFAULT_IF_PLUS ((freq_t)1069500000) +#define DEFAULT_IF ((freq_t)977900000) +#define DEFAULT_IF_PLUS ((freq_t)1070100000) extern uint16_t hw_if; #define DEFAULT_SPUR_OFFSET ((freq_t)(actual_rbw_x10 > 3000 ? 1500000 : 1000000)) #define STATIC_DEFAULT_SPUR_OFFSET ((freq_t) 1500000) diff --git a/sa_cmd.c b/sa_cmd.c index 283097c..400dd9e 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -580,17 +580,23 @@ VNA_SHELL_FUNCTION(cmd_rbw) VNA_SHELL_FUNCTION(cmd_if) { + char *t = "975M..979M"; if (argc != 1 || argv[0][0] == '?') { usage: #ifdef TINYSA4 - usage_printf("usage: if {975M..979M}\r\n%QHz\r\n", setting.frequency_IF); + if (hw_if) + t = "1067M..1073M"; + usage_printf("usage: if {%s}\r\n%QHz\r\n", t, setting.frequency_IF); #else usage_printf("usage: if {433M..435M}\r\n%QHz\r\n", setting.frequency_IF); #endif return; } freq_t a = (freq_t)my_atoi(argv[0]); - if (a!= 0 &&( a < (DEFAULT_IF - (freq_t)2000000) || a>(DEFAULT_IF + (freq_t)2000000))) + freq_t f = DEFAULT_IF; + if (hw_if) + f = DEFAULT_IF_PLUS; + if (a!= 0 &&( a < (f - (freq_t)5000000) || a>(f + (freq_t)5000000))) goto usage; setting.auto_IF = false; set_IF(a); diff --git a/sa_core.c b/sa_core.c index c50dc46..463f0f5 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3062,7 +3062,7 @@ static const freq_t spur_table[] = // Frequenci const int spur_table_size = (sizeof spur_table)/sizeof(freq_t); #endif #ifdef TINYSA4 -#define static_spur_IF DEFAULT_IF // The IF frequency for which the spur table is value +#define static_spur_IF 977400000; // DEFAULT_IF // The IF frequency for which the spur table is value #define STATIC_SPUR_TABLE_SIZE 56 static const freq_t static_spur_table[STATIC_SPUR_TABLE_SIZE] = // Valid for IF=977.4MHz { @@ -3235,12 +3235,15 @@ void fill_spur_table(void) spur_table_size = dynamic_spur_table_size; return; } - if (actual_rbw_x10 < RBW_FOR_STATIC_TABLE) { // if less then 1100kHz use static table + if (actual_rbw_x10 < RBW_FOR_STATIC_TABLE && !hw_if) { // if less then 1100kHz use static table +#if 0 if (hw_if) { spur_table = (freq_t *)static_spur_table_plus; spur_table_size = STATIC_SPUR_TABLE_SIZE_PLUS; spur_IF = static_spur_IF_plus; - } else { + } else +#endif + { spur_table = (freq_t *)static_spur_table; spur_table_size = STATIC_SPUR_TABLE_SIZE; spur_IF = static_spur_IF; @@ -3250,7 +3253,7 @@ void fill_spur_table(void) if (!setting.auto_IF) corr_IF = setting.frequency_IF; else { - corr_IF = config.frequency_IF1; + corr_IF = (hw_if? config.frequency_IF1 + 250000 : config.frequency_IF1); } dynamic_spur_table_size = 0; // dynamic_spur_table[dynamic_spur_table_size++] = 132000000; @@ -3258,8 +3261,11 @@ void fill_spur_table(void) // 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++] = corr_IF/4 -SPUR_FACTOR/2 + 60000; // dynamic_spur_table[dynamic_spur_table_size++] = 266000000; dynamic_spur_table[dynamic_spur_table_size++] = corr_IF/2 -SPUR_FACTOR; + if (actual_rbw_x10 < 3000) + dynamic_spur_table[dynamic_spur_table_size++] = corr_IF/2 -SPUR_FACTOR + 120000; dynamic_spur_table[dynamic_spur_table_size++] = corr_IF*2/3 -SPUR_FACTOR*2/3; spur_table = dynamic_spur_table; spur_table_size = dynamic_spur_table_size; @@ -4090,18 +4096,10 @@ again: // Spur redu else { #ifdef TINYSA4 - if (actual_rbw_x10 < RBW_FOR_STATIC_TABLE && setting.mode == M_LOW && lf > static_spur_table[0] - RBW_FOR_STATIC_TABLE * 100) + if (!hw_if && actual_rbw_x10 < RBW_FOR_STATIC_TABLE && setting.mode == M_LOW && lf > static_spur_table[0] - RBW_FOR_STATIC_TABLE * 100) local_IF = spur_IF; // static spur table IF else - local_IF = config.frequency_IF1; -#if 0 - if ( S_IS_AUTO(setting.below_IF)) { -// if (f < 2000000 && S_IS_AUTO(setting.spur_removal)) -// local_IF += DEFAULT_SPUR_OFFSET; -// else // if (lf > ULTRA_MAX_FREQ || lf < local_IF/2 || ( lf + (uint64_t)local_IF< MAX_LO_FREQ && lf > 136000000ULL + local_IF) ) - local_IF += DEFAULT_SPUR_OFFSET/2; - } -#endif + local_IF = (hw_if? config.frequency_IF1 + 250000 : config.frequency_IF1); #else local_IF = DEFAULT_IF; #endif @@ -4176,30 +4174,6 @@ again: // Spur redu } else { int spur_flag = avoid_spur(lf); #ifdef TINYSA4 -#if 0 - if (debug_avoid) { - if (spur_flag == F_NEAR_SPUR) { - stored_t[i] = -70.0; // Display when to do spur shift in the stored trace - // local_IF -= DEFAULT_SPUR_OFFSET/2; - } else if (spur_flag == F_AT_SPUR){ - stored_t[i] = -60.0; - // Display when to do spur shift in the stored trace - if (debug_avoid_second) { - if (S_IS_AUTO(setting.below_IF) && lf < local_IF/2 - 2000000) { - setting.below_IF = S_AUTO_ON; - local_IF = local_IF; // No spur removal and no spur, center in IF - } else if (setting.auto_IF) { - local_IF = local_IF + DEFAULT_SPUR_OFFSET/2; - // if (actual_rbw_x10 == 6000 ) - // local_IF = local_IF + 50000; - LO_spur_shifted = true; - } - } - } else { - stored_t[i] = -90.0; // Display when to do spur shift in the stored trace - } - } else -#endif if(spur_flag) { // check if alternate IF is needed to avoid spur. if (spur_flag == F_NEAR_SPUR) { if (debug_avoid) stored_t[i] = -70.0; // Display when to do spur shift in the stored trace @@ -4214,7 +4188,7 @@ again: // Spur redu } else #endif if (setting.auto_IF) { - local_IF = local_IF + (actual_rbw_x10 > 2000 ? DEFAULT_SPUR_OFFSET : DEFAULT_SPUR_OFFSET/2); // TODO find better way to shift spur away at large RBW/2; + local_IF = local_IF + (actual_rbw_x10 > 2000 || hw_if ? DEFAULT_SPUR_OFFSET : DEFAULT_SPUR_OFFSET/2); // TODO find better way to shift spur away at large RBW/2; // if (actual_rbw_x10 == 6000 ) // local_IF = local_IF + 50000; LO_spur_shifted = true; @@ -4238,7 +4212,7 @@ again: // Spur redu if (lf 1000 ? 200000 : 0); // Shift to avoid zero Hz peak LO_shifting = true; - } + } else 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)) { @@ -4247,6 +4221,8 @@ again: // Spur redu setting.below_IF= S_AUTO_OFF; } } + else if (hw_if && actual_rbw_x10 < 8500) + local_IF += 250000; #else local_IF = local_IF; // + DEFAULT_SPUR_OFFSET/2; // No spure removal and no spur, center in IF @@ -6802,7 +6778,7 @@ common_silent: setting.tracking = true; //Sweep BPF setting.auto_IF = false; #ifdef TINYSA4 - setting.frequency_IF = config.frequency_IF1 + STATIC_DEFAULT_SPUR_OFFSET/3; // This is the place where the + setting.frequency_IF = config.frequency_IF1 + STATIC_DEFAULT_SPUR_OFFSET/3; // This is the place where the inverted offset from the middle of the IF pass band is defined for normal mode. set_refer_output(0); #else setting.frequency_IF = DEFAULT_IF+210000; // Center on SAW filters @@ -7031,10 +7007,10 @@ void selftest(int test) #ifdef TINYSA4 bool old_ultra = config.ultra; config.ultra = true; - if (adc_vbat_read() < 3800) { - drawMessageBox("Battery low", "Charge before testing", 2000); - goto quit; - } +// if (adc_vbat_read() < 3800) { +// drawMessageBox("Battery low", "Charge before testing", 2000); +// goto quit; +// } #endif setting.external_gain = 0; // Must be 0 // set_sweep_points(POINTS_COUNT); @@ -7865,7 +7841,7 @@ void calibrate(void) setting.test_argument = -7; selftest(0); int if_error = peakFreq - 30000000; - if (if_error > -1000000 && if_error < 1000000) { + if (if_error > -2000000 && if_error < 2000000) { config.frequency_IF1 += if_error; setting.auto_IF = true; setting.frequency_IF = config.frequency_IF1; From b2e7e322cad3b386821acb81efe0c225d06a9ba3 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 5 Nov 2024 17:12:11 +0100 Subject: [PATCH 4/5] Repair CSV load bug --- nanovna.h | 6 +++--- sa_core.c | 58 +++++++++++++++++++++++++++------------------------ vna_browser.c | 1 + 3 files changed, 35 insertions(+), 30 deletions(-) diff --git a/nanovna.h b/nanovna.h index 4c97526..24aedc2 100644 --- a/nanovna.h +++ b/nanovna.h @@ -156,7 +156,7 @@ typedef uint32_t freq_t; typedef uint64_t freq_t; #define FREQ_MULTIPLIER 100 // Multiplier of the 30MHz reference to get accurate frequency correction #define VARIANT(X,Y) (Y) -#define DEFAULT_IF ((freq_t)977900000) +#define DEFAULT_IF ((freq_t)977400000) #define DEFAULT_IF_PLUS ((freq_t)1070100000) extern uint16_t hw_if; #define DEFAULT_SPUR_OFFSET ((freq_t)(actual_rbw_x10 > 3000 ? 1500000 : 1000000)) @@ -1493,8 +1493,8 @@ typedef struct properties { //sizeof(properties_t) == 0x1200 -#define CONFIG_MAGIC 0x434f4e6a -#define SETTING_MAGIC 0x434f4e6a +#define CONFIG_MAGIC 0x434f4e6b +#define SETTING_MAGIC 0x434f4e6b extern int16_t lastsaveid; //extern properties_t *active_props; diff --git a/sa_core.c b/sa_core.c index 463f0f5..fc3b1d9 100644 --- a/sa_core.c +++ b/sa_core.c @@ -387,7 +387,7 @@ void set_output_path(freq_t f, float level) SI4463_init_tx(); break; } - + setting.spur_removal &= 0xFE; } static void calculate_static_correction(void); @@ -412,14 +412,15 @@ void set_input_path(freq_t f) else if(config.ultra && ((config.ultra_start == ULTRA_AUTO && f > ultra_start) || (config.ultra_start != ULTRA_AUTO && f >config.ultra_start))) { LO_harmonic = (f > (config.harmonic_start?config.harmonic_start:ULTRA_MAX_FREQ)); signal_path = PATH_ULTRA; - } else + } else { signal_path = PATH_LOW; - + } if (signal_path == PATH_HIGH) { return; // TODO setup high input path } enable_rx_output(setting.atten_step); + bool mirrors = false; switch(signal_path) { case PATH_LOW: enable_ultra(false); @@ -441,19 +442,26 @@ void set_input_path(freq_t f) goto common2; case PATH_ULTRA: + mirrors = true; enable_ultra(true); enable_high(false); enable_direct(false); enable_extra_lna(setting.extra_lna); - common: + common: enable_ADF_output(true, setting.tracking_output); - common2: + common2: if (SI4463_is_in_tx_mode()) SI4463_init_rx(); break; } if (force_signal_path) calculate_static_correction(); + if (S_IS_AUTO(setting.spur_removal)) { + if (mirrors) + setting.spur_removal |= 0x01; + else + setting.spur_removal &= 0xFE; + } } #endif @@ -3139,6 +3147,7 @@ static const freq_t static_spur_table_plus[] = // Valid for IF=977.4MHz #define MAX_DYNAMIC_SPUR_TABLE_SIZE 100 static freq_t dynamic_spur_table[MAX_DYNAMIC_SPUR_TABLE_SIZE]; // Frequencies to be calculated static int dynamic_spur_table_size = 0; +freq_t dynamic_spur_IF = 0; static int always_use_dynamic_table = false; static freq_t *spur_table = (freq_t *)static_spur_table; @@ -3230,7 +3239,7 @@ void fill_spur_table(void) { freq_t corr_IF; - if (always_use_dynamic_table) { + if (always_use_dynamic_table) { // Only after doing selftest 1 spur_table = dynamic_spur_table; spur_table_size = dynamic_spur_table_size; return; @@ -3250,11 +3259,10 @@ void fill_spur_table(void) } return; } - if (!setting.auto_IF) - corr_IF = setting.frequency_IF; - else { - corr_IF = (hw_if? config.frequency_IF1 + 250000 : config.frequency_IF1); - } + corr_IF = setting.frequency_IF; + if (dynamic_spur_IF == corr_IF) + return; + dynamic_spur_IF = corr_IF; dynamic_spur_table_size = 0; // dynamic_spur_table[dynamic_spur_table_size++] = 132000000; // dynamic_spur_table[dynamic_spur_table_size++] = 153000000; @@ -3362,7 +3370,7 @@ int avoid_spur(freq_t f) // find if this frequency should be a #ifdef TINYSA4 #if 1 if (!setting.auto_IF && setting.frequency_IF-2000000 < f && f < setting.frequency_IF -200000) - return true; + return F_AT_SPUR; if(config.frequency_IF1+200000 > f && config.frequency_IF1 < f+200000) return F_AT_SPUR; #endif @@ -4090,7 +4098,7 @@ again: // Spur redu #ifdef __ULTRA__ // LO_harmonic = false; #endif - if (MODE_LOW(setting.mode)){ // All low mode + if (MODE_LOW(setting.mode) && !direct){ // All low input/output mode except direct that require setting of IF if (!setting.auto_IF) local_IF = setting.frequency_IF; else @@ -4098,13 +4106,15 @@ again: // Spur redu #ifdef TINYSA4 if (!hw_if && actual_rbw_x10 < RBW_FOR_STATIC_TABLE && setting.mode == M_LOW && lf > static_spur_table[0] - RBW_FOR_STATIC_TABLE * 100) local_IF = spur_IF; // static spur table IF - else - local_IF = (hw_if? config.frequency_IF1 + 250000 : config.frequency_IF1); + else { + local_IF = (hw_if? config.frequency_IF1 - 500000 : config.frequency_IF1 - 500000); + setting.frequency_IF = local_IF; + } #else local_IF = DEFAULT_IF; #endif } - if (setting.mode == M_LOW && !direct) { + if (setting.mode == M_LOW) { // Low input mode if (tracking) { // VERY SPECIAL CASE!!!!! Measure BPF #if 0 // Isolation test local_IF = lf; @@ -4122,9 +4132,6 @@ again: // Spur redu setting.spur_removal= S_AUTO_OFF; } } -#endif - -#ifdef __ULTRA__ if (S_IS_AUTO(setting.below_IF)) { if ((freq_t)lf > MAX_ABOVE_IF_FREQ && lf <= ULTRA_MAX_FREQ && !LO_harmonic) setting.below_IF = S_AUTO_ON; // Only way to reach this range. Use below IF in harmonic mode @@ -4153,16 +4160,13 @@ again: // Spur redu setting.below_IF = S_AUTO_OFF; // use below IF in second pass } } - else // if (setting.auto_IF) + else // if (setting.auto_IF) // spur reduction is on and can not do above/below IF { if ((debug_avoid && debug_avoid_second) || spur_second_pass) { #ifdef TINYSA4 local_IF = local_IF + DEFAULT_SPUR_OFFSET-(actual_rbw_x10 > 1000 ? 200000 : 0); // apply IF spur shift LO_spur_shifted = true; -#ifdef TINYSA4 LO_shifting = true; -#endif - } else { local_IF = local_IF; // - (actual_rbw_x10 > 5000 ? 200000 : 0);// - DEFAULT_SPUR_OFFSET/2; // apply IF spur shift } @@ -4171,7 +4175,7 @@ again: // Spur redu } #endif } - } else { + } else { // No spur removal int spur_flag = avoid_spur(lf); #ifdef TINYSA4 if(spur_flag) { // check if alternate IF is needed to avoid spur. @@ -4242,7 +4246,7 @@ again: // Spur redu if (setting.modulation == MO_EXTERNAL) // VERY SPECIAL CASE !!!!!! LO input via high port local_IF += lf; } - } // --------------- END IF calculation ------------------------ + } // --------------- END IF calculation ------------------------ all low input/output modes with IF setting TRACE(2); // ------------- Set LO --------------------------- @@ -6778,10 +6782,10 @@ common_silent: setting.tracking = true; //Sweep BPF setting.auto_IF = false; #ifdef TINYSA4 - setting.frequency_IF = config.frequency_IF1 + STATIC_DEFAULT_SPUR_OFFSET/3; // This is the place where the inverted offset from the middle of the IF pass band is defined for normal mode. + setting.frequency_IF = config.frequency_IF1; // Center on SAW filter set_refer_output(0); #else - setting.frequency_IF = DEFAULT_IF+210000; // Center on SAW filters + setting.frequency_IF = DEFAULT_IF + 210000; // Center on SAW filters set_refer_output(2); #endif markers[1].enabled = M_ENABLED; diff --git a/vna_browser.c b/vna_browser.c index 49a2eb7..33f7312 100644 --- a/vna_browser.c +++ b/vna_browser.c @@ -204,6 +204,7 @@ finish3: while (f_read(fs_file, buf_8, buffer_size, &size) == FR_OK && size > 0) { for (i = 0; i < size; i++) { uint8_t c = buf_8[i]; + if (c == ',') c = ' '; if (c == '\r') { // New line (Enter) line[j] = 0; j = 0; char *args[16]; From 1dd6b0764fcb0e0514ccc9d5dabc42766e96e96e Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 6 Nov 2024 09:38:34 +0100 Subject: [PATCH 5/5] Selftest updated --- sa_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sa_core.c b/sa_core.c index fc3b1d9..67e38b9 100644 --- a/sa_core.c +++ b/sa_core.c @@ -6520,7 +6520,7 @@ int validate_signal_within(int i, float margin) c_freq = LPF_TEST_FREQ; #endif test_fail_cause[i] = "Frequency "; - if (peakFreq < c_freq - 500000 || c_freq + 500000 < peakFreq ) + if ((peakFreq < c_freq - 500000 || c_freq + 500000 < peakFreq) && setting.measurement != M_PASS_BAND) return TS_FAIL; test_fail_cause[i] = ""; return TS_PASS;