Add LNA correction

Removed_REF_marker
erikkaashoek 5 years ago
parent 27799c8bc3
commit d4d6e15413

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-644081821413706" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="300448615141682" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -17,7 +17,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-644081821413706" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="300448615141682" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

@ -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,

@ -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;
#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

@ -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<CORRECTION_POINTS; i++) {
shell_printf("%d %D %.1f\r\n", i, setting.correction_frequency[i], setting.correction_value[i]);
shell_printf("correction %s %d %D %.1f\r\n", argv[0], i, config.correction_frequency[m][i], config.correction_value[m][i]);
}
return;
}
if (argc == 1 && (get_str_index(argv[0],"reset") == 0)) {
if (argc == 2 && (get_str_index(argv[1],"reset") == 0)) {
for (int i=0; i<CORRECTION_POINTS; i++) {
setting.correction_value[i] = 0.0;
config.correction_value[m][i] = 0.0;
}
shell_printf("correction table reset\r\n");
shell_printf("correction table %s reset\r\n", argv[0]);
return;
}
if (argc != 3) {
shell_printf("usage: correction 0-9 frequency(Hz) value(dB)\r\n");
if (argc != 4) {
shell_printf("usage: correction %s %s frequency(Hz) value(dB)\r\n", cmd, range);
return;
}
int i = my_atoi(argv[0]);
freq_t f = my_atoui(argv[1]);
float v = my_atof(argv[2]);
setting.correction_frequency[i] = f;
setting.correction_value[i] = v;
int i = my_atoi(argv[1]);
freq_t f = my_atoui(argv[2]);
float v = my_atof(argv[3]);
config.correction_frequency[m][i] = f;
config.correction_value[m][i] = v;
redraw_request|=REDRAW_AREA; // to ensure the change in level will be visible
shell_printf("updated %d to %D %.1f\r\n", i, setting.correction_frequency[i], setting.correction_value[i]);
shell_printf("updated %d to %D %.1f\r\n", i, config.correction_frequency[m][i], config.correction_value[m][i]);
}
VNA_SHELL_FUNCTION(cmd_scanraw)

@ -275,8 +275,8 @@ void reset_settings(int m)
setting.lo_drive=1;
setting.extra_lna = false;
#endif
setting.correction_frequency = config.low_correction_frequency;
setting.correction_value = config.low_correction_value;
setting.correction_frequency = config.correction_frequency[CORRECTION_LOW];
setting.correction_value = config.correction_value[CORRECTION_LOW];
break;
case M_GENLOW:
#ifdef TINYSA4
@ -293,8 +293,8 @@ void reset_settings(int m)
#ifdef TINYSA4
setting.extra_lna = false;
#endif
setting.correction_frequency = config.low_correction_frequency;
setting.correction_value = config.low_correction_value;
setting.correction_frequency = config.correction_frequency[CORRECTION_LOW];
setting.correction_value = config.correction_value[CORRECTION_LOW];
level_min = SL_GENLOW_LEVEL_MIN + config.low_level_output_offset;
level_max = SL_GENLOW_LEVEL_MAX + config.low_level_output_offset;
level_range = level_max - level_min;
@ -306,8 +306,8 @@ void reset_settings(int m)
#ifdef TINYSA4
setting.extra_lna = false;
#endif
setting.correction_frequency = config.high_correction_frequency;
setting.correction_value = config.high_correction_value;
setting.correction_frequency = config.correction_frequency[CORRECTION_HIGH];
setting.correction_value = config.correction_value[CORRECTION_HIGH];
break;
case M_GENHIGH:
#ifdef TINYSA4
@ -322,8 +322,8 @@ void reset_settings(int m)
set_sweep_frequency(ST_SPAN, 0);
setting.sweep_time_us = 10*ONE_SECOND_TIME;
setting.step_delay_mode = SD_FAST;
setting.correction_frequency = config.high_correction_frequency;
setting.correction_value = config.high_correction_value;
setting.correction_frequency = config.correction_frequency[CORRECTION_HIGH];
setting.correction_value = config.correction_value[CORRECTION_HIGH];
level_min = SL_GENHIGH_LEVEL_MIN + config.high_level_output_offset;
level_max = SL_GENHIGH_LEVEL_MAX + config.high_level_output_offset;
level_range = level_max - level_min;
@ -525,12 +525,19 @@ void toggle_high_out_adf4350(void)
void toggle_extra_lna(void)
{
setting.extra_lna = !setting.extra_lna;
dirty = true;
set_extra_lna(setting.extra_lna);
}
void set_extra_lna(int t)
{
setting.extra_lna = t;
if (setting.extra_lna) {
setting.correction_frequency = config.correction_frequency[CORRECTION_LNA];
setting.correction_value = config.correction_value[CORRECTION_LNA];
} else {
setting.correction_frequency = config.correction_frequency[CORRECTION_LOW];
setting.correction_value = config.correction_value[CORRECTION_LOW];
}
dirty = true;
}
#endif
@ -3610,9 +3617,11 @@ sweep_again: // stay in sweep loop when output mo
} else {
#define MAX_FIT (NGRIDY-1.2)
float s_min = value(temp_min_level)/setting.scale;
#ifdef TINYSA4
float noise = (noise_level - setting.external_gain - (setting.extra_lna ? 25 : 0))/setting.scale;
if (s_min < noise)
s_min = noise;
#endif
float s_ref = setting.reflevel/setting.scale;
if (s_max < s_ref - NGRIDY || s_min > 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

Loading…
Cancel
Save

Powered by TurnKey Linux.