Added output leveloffset

Removed_REF_marker
erikkaashoek 5 years ago
parent 15cfc56ec9
commit e8d23a7047

@ -948,8 +948,10 @@ config_t config = {
.frequency_IF2 = 0,
.ultra_threshold = 800000000,
#endif
.low_level_offset = 100, // Uncalibrated
.high_level_offset = 100, // Uncalibrated
.low_level_offset = 100.0, // Uncalibrated
.high_level_offset = 100.0, // Uncalibrated
.low_level_output_offset = 0.0, // Uncalibrated
.high_level_output_offset = 0.0, // Uncalibrated
#ifdef TINYSA3
.correction_frequency = { 10000, 100000, 200000, 500000, 50000000, 140000000, 200000000, 300000000, 330000000, 350000000 },
.correction_value = { +6.0, +2.8, +1.6, -0.4, 0.0, -0.4, +0.4, +3.0, +4.0, +8.1 },

@ -569,8 +569,10 @@ typedef struct config {
uint16_t vbat_offset;
float low_level_offset;
float high_level_offset;
freq_t correction_frequency[CORRECTION_POINTS];
float correction_value[CORRECTION_POINTS];
float low_level_output_offset;
float high_level_output_offset;
freq_t low_correction_frequency[CORRECTION_POINTS];
float low_correction_value[CORRECTION_POINTS];
uint32_t deviceid;
freq_t setting_frequency_30mhz;

@ -247,6 +247,8 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
if (argc == 0) {
shell_printf("leveloffset low %.1f\r\n", config.low_level_offset);
shell_printf("leveloffset high %.1f\r\n", config.high_level_offset);
shell_printf("leveloffset low output %.1f\r\n", config.low_level_output_offset);
shell_printf("leveloffset high output %.1f\r\n", config.high_level_output_offset);
return;
} else if (argc == 2) {
float v = my_atof(argv[1]);
@ -256,9 +258,17 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
config.high_level_offset = v;
else
goto usage;
} else if (argc == 3) {
float v = my_atof(argv[2]);
if (strcmp(argv[0],"low") == 0)
config.low_level_output_offset = v;
else if (strcmp(argv[0],"high") == 0)
config.high_level_output_offset = v;
else
goto usage;
} else {
usage:
shell_printf("leveloffset [low|high] [<offset>]\r\n");
shell_printf("leveloffset [low|high] {output} [<offset>]\r\n");
}
}

@ -116,7 +116,7 @@ void reset_settings(int m)
setting.level_sweep = 0.0; // And this
setting.rx_drive=MAX_DRIVE; // And this
setting.atten_step = 0; // And this, only used in low output mode
setting.level = SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE; // This is the level with above settings.
setting.level = SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE + config.low_level_output_offset; // This is the level with above settings.
setting.rbw_x10 = 0;
setting.average = 0;
setting.harmonic = 3; // Automatically used when above ULTRA_MAX_FREQ
@ -515,7 +515,7 @@ float get_attenuation(void)
{
float actual_attenuation = setting.attenuate_x2 / 2.0;
if (setting.mode == M_GENLOW) {
return (float)( SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE - actual_attenuation - (MAX_DRIVE - setting.rx_drive) * SI_DRIVE_STEP - ( setting.atten_step ? SWITCH_ATTENUATION : 0) );
return (float)( SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE + config.low_level_output_offset - actual_attenuation - (MAX_DRIVE - setting.rx_drive) * SI_DRIVE_STEP - ( setting.atten_step ? SWITCH_ATTENUATION : 0) );
} else if (setting.atten_step) {
if (setting.mode == M_LOW)
return actual_attenuation + RECEIVE_SWITCH_ATTENUATION;
@ -565,7 +565,7 @@ float get_level(void)
void set_attenuation(float a) // Is used both in low output mode and high/low input mode
{
if (setting.mode == M_GENLOW) {
a = a - (SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE); // Move to zero for max power
a = a - (SL_GENLOW_LEVEL_MIN + config.low_level_output_offset + SL_GENLOW_LEVEL_RANGE); // Move to zero for max power
if (a > 0)
a = 0;
if( a < - SWITCH_ATTENUATION) {
@ -682,6 +682,12 @@ float get_level_offset(void)
return 0;
return(config.low_level_offset);
}
if (setting.mode == M_GENLOW) {
return(config.low_level_output_offset);
}
if (setting.mode == M_GENHIGH) {
return(config.high_level_output_offset);
}
return(0);
}
@ -1006,7 +1012,7 @@ void set_offset(float offset)
setting.offset = offset;
int min,max;
if (setting.mode == M_GENLOW) {
min = SL_GENLOW_LEVEL_MIN; max = SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE;
min = SL_GENLOW_LEVEL_MIN + config.low_level_output_offset; max = SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE + config.low_level_output_offset;
} else {
min = SL_GENHIGH_LEVEL_MIN; max = SL_GENHIGH_LEVEL_MIN + SL_GENHIGH_LEVEL_RANGE;
}
@ -2029,7 +2035,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
a += PURE_TO_float(get_frequency_correction(f));
if (a != old_a) {
old_a = a;
a = a - (SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE); // convert to all settings maximum power output equals a = zero
a = a - (SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE + config.low_level_output_offset); // convert to all settings maximum power output equals a = zero
if (a < -SWITCH_ATTENUATION) {
a = a + SWITCH_ATTENUATION;
@ -2333,33 +2339,6 @@ modulation_again:
else
ADF4351_R_counter(setting.R);
#if 1 // No 72MHz spur avoidance yet
if (setting.mode == M_LOW /* && !(SDU1.config->usbp->state == USB_ACTIVE) */ ) { // Avoid 72MHz spur
int set_below = false;
if (lf < 40000000) {
uint32_t tf = lf;
while (tf > 4000000) tf -= 4000000;
if (tf < 2000000 )
set_below = true;
} else {
uint32_t tf = lf;
while (tf > 48000000) tf -= 48000000;
if (tf < 20000000 )
set_below = true;
}
if (set_below) { // If below 48MHz
if (!is_below) {
clock_below_48MHz();
is_below = true;
}
} else {
if (is_below) {
clock_above_48MHz();
is_below = false;
}
}
}
#endif
#endif // __ADF4351__
#if 0
freq_t target_f;
@ -4146,6 +4125,7 @@ void self_test(int test)
in_selftest = true; // Spur search
reset_settings(M_LOW);
test_prepare(TEST_SPUR);
set_RBW(300);
setting.extra_lna = true;
for (int i = 0; i < 31; i++) {
hsical = (RCC->CR & 0xff00) >> 8;
@ -4153,7 +4133,6 @@ void self_test(int test)
RCC->CR |= ( (hsical) << 8 );
RCC->CR &= RCC_CR_HSITRIM | RCC_CR_HSION; /* CR Reset value. */
RCC->CR |= (i << 3 ) & RCC_CR_HSITRIM;
set_RBW(100);
test_acquire(TEST_SPUR); // Acquire test
shell_printf("%d: %9.3q\n\r",i, peakFreq);
test_validate(TEST_SPUR); // Validate test

@ -1885,7 +1885,7 @@ draw_menu_buttons(const menuitem_t *menu)
}
goto draw_divider;
} else if (menu[i].data == KM_LOWOUTLEVEL) {
local_slider_positions = ((get_level() - SL_GENLOW_LEVEL_MIN ) * (MENU_FORM_WIDTH-8)) / SL_GENLOW_LEVEL_RANGE + OFFSETX+4;
local_slider_positions = ((get_level() - SL_GENLOW_LEVEL_MIN - config.low_level_output_offset ) * (MENU_FORM_WIDTH-8)) / SL_GENLOW_LEVEL_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);
}
@ -2062,7 +2062,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) * SL_GENLOW_LEVEL_RANGE ) / (MENU_FORM_WIDTH-8) + SL_GENLOW_LEVEL_MIN;
uistat.value = setting.offset + ((touch_x - OFFSETX+4) * SL_GENLOW_LEVEL_RANGE ) / (MENU_FORM_WIDTH-8) + SL_GENLOW_LEVEL_MIN + config.low_level_output_offset;
apply_step:
set_keypad_value(keypad);
apply:

@ -2254,10 +2254,10 @@ static void fetch_numeric_target(void)
case KM_LOWOUTLEVEL:
uistat.value = get_level(); // compensation for dB offset during low output mode
int end_level = ((int32_t)uistat.value)+setting.level_sweep;
if (end_level < SL_GENLOW_LEVEL_MIN)
end_level = SL_GENLOW_LEVEL_MIN;
if (end_level > SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE)
end_level = SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE;
if (end_level < SL_GENLOW_LEVEL_MIN + config.low_level_output_offset)
end_level = SL_GENLOW_LEVEL_MIN + config.low_level_output_offset;
if (end_level > SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE + config.low_level_output_offset)
end_level = SL_GENLOW_LEVEL_MIN + SL_GENLOW_LEVEL_RANGE + config.low_level_output_offset;
uistat.value += setting.offset;
end_level += setting.offset;
if (setting.level_sweep != 0)

Loading…
Cancel
Save

Powered by TurnKey Linux.