diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index d16543b..240010c 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ - + diff --git a/main.c b/main.c index c36fa37..ee36749 100644 --- a/main.c +++ b/main.c @@ -995,10 +995,10 @@ config_t config = { .vbat_offset = 500, .low_level_offset = 100, // Uncalibrated .high_level_offset = 100, // Uncalibrated - .low_correction_frequency = { 10000, 100000, 200000, 500000, 30000000, 140000000, 200000000, 300000000, 330000000, 350000000 }, - .low_correction_value = { +6.0, +2.8, +1.6, -0.4, 0.0, -0.4, +0.4, +3.0, +4.0, +8.1 }, - .high_correction_frequency = { 240000000, 280000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 960000000 }, - .high_correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 }, + .correction_frequency = { { 10000, 100000, 200000, 500000, 30000000, 140000000, 200000000, 300000000, 330000000, 350000000 }, + { 240000000, 280000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 960000000 }}, + .correction_value = { { +6.0, +2.8, +1.6, -0.4, 0.0, -0.4, +0.4, +3.0, +4.0, +8.1 }, + { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 } }, .setting_frequency_10mhz = 10000000, .cor_am = 0,// -10, .cor_wfm = 0, //-18, @@ -1014,10 +1014,8 @@ config_t config = { .high_level_offset = 100.0, // Uncalibrated .low_level_output_offset = 0.0, // Uncalibrated .high_level_output_offset = 0.0, // Uncalibrated - .low_correction_frequency = { 10000, 100000, 200000, 500000, 30000000, 140000000, 200000000, 300000000, 330000000, 350000000 }, - .low_correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 }, - .high_correction_frequency = { 10000, 100000, 200000, 500000, 50000000, 140000000, 200000000, 300000000, 330000000, 350000000 }, - .high_correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 }, + .correction_frequency[0] = { 10000, 100000, 200000, 500000, 30000000, 140000000, 200000000, 300000000, 330000000, 350000000 }, + .correction_value[0] = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 }, .setting_frequency_30mhz = 30000000, .cor_am = 0, .cor_wfm = 0, diff --git a/nanovna.h b/nanovna.h index dc49bbc..392d3fd 100644 --- a/nanovna.h +++ b/nanovna.h @@ -121,13 +121,21 @@ typedef uint32_t freq_t; typedef int32_t long_t; extern bool has_esd; +#define CORRECTION_POINTS 10 // Frequency dependent level correction table entries +#define CORRECTION_LOW 0 +#define CORRECTION_HIGH 1 +#define CORRECTION_SIZE 2 #endif #ifdef TINYSA4 typedef uint64_t freq_t; typedef int64_t long_t; -#endif +#define CORRECTION_POINTS 20 // Frequency dependent level correction table entries +#define CORRECTION_LOW 0 +#define CORRECTION_LNA 1 +#define CORRECTION_HIGH 2 +#define CORRECTION_SIZE 3 + #endif -#define CORRECTION_POINTS 10 // Frequency dependent level correction table entries typedef float measurement_t[TRACES_MAX][POINTS_COUNT]; extern measurement_t measured; @@ -620,10 +628,8 @@ typedef struct config { float high_level_offset; float low_level_output_offset; float high_level_output_offset; - float low_correction_value[CORRECTION_POINTS]; - float high_correction_value[CORRECTION_POINTS]; - freq_t low_correction_frequency[CORRECTION_POINTS]; - freq_t high_correction_frequency[CORRECTION_POINTS]; + float correction_value[CORRECTION_SIZE][CORRECTION_POINTS]; + freq_t correction_frequency[CORRECTION_SIZE][CORRECTION_POINTS]; #ifdef TINYSA4 freq_t setting_frequency_30mhz; #else diff --git a/sa_cmd.c b/sa_cmd.c index 4636736..fd743b6 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -840,31 +840,39 @@ VNA_SHELL_FUNCTION(cmd_f) VNA_SHELL_FUNCTION(cmd_correction) { (void)argc; - if (argc == 0) { +#ifdef TINYSA4 + static const char cmd[] = "low|lna|high"; + static const char range[] = "0-19"; +#else + static const char cmd[] = "low|high"; + static const char range[] = "0-9"; +#endif + int m = get_str_index(argv[0], cmd); + if (argc == 1) { shell_printf("index frequency value\r\n"); for (int i=0; i s_ref) { //Completely outside if (s_max - s_min < NGRIDY - 2) @@ -4030,7 +4039,7 @@ const test_case_t test_case [] = TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.05, 0.1, 0, 0, 0), // 1 Zero Hz leakage TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.1, 0.1, -70, 0, 0), // 2 Phase noise of zero Hz TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ, 30, 1, -23, 10, -85), // 3 - TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ_ULTRA, 900, 1, -75, 10, -85), // 4 + TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ_ULTRA, 900, 1, -75, 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_BELOW, TPH_SILENT, 633, 994, -85, 0, 0), // 6 Wide band noise floor high mode