Add out_switch, disable mode restart

pull/34/head
erikkaashoek 4 years ago
parent 9454e1fb7e
commit ae87eec9c6

@ -1030,6 +1030,9 @@ config_t config = {
.high_out_adf4350 = true, .high_out_adf4350 = true,
.ext_zero_level = 174, .ext_zero_level = 174,
.receive_switch_offset = 0.0, .receive_switch_offset = 0.0,
#ifdef TINYSA4
.out_switch_offset = 0.0,
#endif
#ifdef __NOISE_FIGURE__ #ifdef __NOISE_FIGURE__
.noise_figure = 5.0, .noise_figure = 5.0,
#endif #endif
@ -2598,7 +2601,7 @@ int main(void)
int i = 5; int i = 5;
while (i--) while (i--)
*t++ = *f++; *t++ = *f++;
#if 0 // Set mode not working reliably
set_mode(b.mode); set_mode(b.mode);
switch (b.mode) { switch (b.mode) {
case M_LOW: case M_LOW:
@ -2613,7 +2616,7 @@ int main(void)
menu_push_submenu(menu_highoutputmode); menu_push_submenu(menu_highoutputmode);
break; break;
} }
#endif
if (b.frequency0 != 0 || b.frequency1 != 0) { if (b.frequency0 != 0 || b.frequency1 != 0) {
if (b.mode <= M_HIGH){ if (b.mode <= M_HIGH){
set_sweep_frequency(ST_START, b.frequency0); set_sweep_frequency(ST_START, b.frequency0);

@ -713,6 +713,7 @@ typedef struct config {
float high_level_output_offset; float high_level_output_offset;
float receive_switch_offset; float receive_switch_offset;
#ifdef TINYSA4 #ifdef TINYSA4
float out_switch_offset;
float lna_level_offset; float lna_level_offset;
float harmonic_level_offset; float harmonic_level_offset;
float shift1_level_offset; float shift1_level_offset;

@ -340,7 +340,7 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
{ {
// 0 1 2 // 0 1 2
#ifdef TINYSA4 #ifdef TINYSA4
static const char cmd_mode_list[] = "low|high|switch|receive_switch|lna|harmonic|shift1|shift2|drive1|drive2|drive3"; static const char cmd_mode_list[] = "low|high|switch|receive_switch|out_switch|lna|harmonic|shift1|shift2|drive1|drive2|drive3";
#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
@ -353,6 +353,7 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
shell_printf(p, "switch", config.switch_offset); shell_printf(p, "switch", config.switch_offset);
shell_printf(p, "receive_switch",config.receive_switch_offset); shell_printf(p, "receive_switch",config.receive_switch_offset);
#ifdef TINYSA4 #ifdef TINYSA4
shell_printf(p, "out_switch", config.out_switch_offset);
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, "shift1", config.shift1_level_offset); shell_printf(p, "shift1", config.shift1_level_offset);
@ -377,13 +378,14 @@ VNA_SHELL_FUNCTION(cmd_leveloffset)
case 2: config.switch_offset = v; break; case 2: config.switch_offset = v; break;
case 3: config.receive_switch_offset = v; break; case 3: config.receive_switch_offset = v; break;
#ifdef TINYSA4 #ifdef TINYSA4
case 4: config.lna_level_offset = v; break; case 4: config.out_switch_offset = v; break;
case 5: config.harmonic_level_offset = v; break; case 5: config.lna_level_offset = v; break;
case 6: config.shift1_level_offset = v; break; case 6: config.harmonic_level_offset = v; break;
case 7: config.shift2_level_offset = v; break; case 7: config.shift1_level_offset = v; break;
case 8: config.drive1_level_offset = v; break; case 8: config.shift2_level_offset = v; break;
case 9: config.drive2_level_offset = v; break; case 9: config.drive1_level_offset = v; break;
case 10: config.drive3_level_offset = v; break; case 10: config.drive2_level_offset = v; break;
case 11: config.drive3_level_offset = v; break;
#endif #endif
default: goto usage; default: goto usage;
} }
@ -1137,7 +1139,7 @@ VNA_SHELL_FUNCTION(cmd_q)
static const char cmd[] = "s|d|a"; static const char cmd[] = "s|d|a";
if (argc < 1) { if (argc < 1) {
usage: usage:
usage_printf("q s|d 0..18|a 0..63 %s\r\n", cmd); usage_printf("q [s 0..1|d 0..18|a 0..63] %s\r\n", cmd);
test_output=false; test_output=false;
return; return;
} }
@ -1153,7 +1155,7 @@ VNA_SHELL_FUNCTION(cmd_q)
argc--; argc--;
switch (m) { switch (m) {
case -1: goto usage; case -1: goto usage;
case 0: test_output_switch = true; break; case 0: test_output_switch = argv[i++][0] - '0'; argc--; break;
case 1: test_output_drive = atoi(argv[i++]); argc--; break; case 1: test_output_drive = atoi(argv[i++]); argc--; break;
case 2: test_output_attenuate = atoi(argv[i++]); argc--; break; case 2: test_output_attenuate = atoi(argv[i++]); argc--; break;
} }

@ -103,7 +103,7 @@ static freq_t real_old_freq[4] = { 0, 0, 0, 0};
#endif #endif
#ifdef TINYSA4 #ifdef TINYSA4
const float si_drive_dBm [] = {-44.30, -29.98, -19.41, -16.80, -13.79, -11.49, -9.67, -8.18, -6.98, -5.87, -4.91, -4.16, -3.31, -2.62 , -1.99, -1.41, -0.95, -0.47, 0}; const float si_drive_dBm [] = {-44.1, -30, -21.6, -17, -14, -11.7, -9.9, -8.4, -7.1, -6, -5, -4.2, -3.4, -2.7 , 2.1, -1.5, -1, -0.47, 0};
const float adf_drive_dBm[] = {-15,-12,-9,-6}; const float adf_drive_dBm[] = {-15,-12,-9,-6};
const uint8_t drive_register[] = {0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}; const uint8_t drive_register[] = {0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};
float *drive_dBm = (float *) adf_drive_dBm; float *drive_dBm = (float *) adf_drive_dBm;
@ -117,12 +117,12 @@ int actual_drive = -1;
#endif #endif
#ifdef TINYSA4 #ifdef TINYSA4
#define SWITCH_ATTENUATION ((setting.mode == M_GENHIGH && config.high_out_adf4350) ? 40 : 25.0) #define SWITCH_ATTENUATION ((setting.mode == M_GENHIGH && config.high_out_adf4350) ? 40 : 25.0 + config.out_switch_offset)
#define RECEIVE_SWITCH_ATTENUATION (29 + config.receive_switch_offset) #define RECEIVE_SWITCH_ATTENUATION (29 + config.receive_switch_offset)
//#define POWER_OFFSET -18 // Max level with all enabled //#define POWER_OFFSET -18 // Max level with all enabled
//#define POWER_RANGE 70 //#define POWER_RANGE 70
#define MAX_DRIVE ((setting.mode == M_GENHIGH && config.high_out_adf4350 ) ? 3 : 18) #define MAX_DRIVE ((setting.mode == M_GENHIGH && config.high_out_adf4350 ) ? 3 : 18)
#define MIN_DRIVE ((setting.mode == M_GENHIGH && config.high_out_adf4350 ) ? 0: 1) #define MIN_DRIVE ((setting.mode == M_GENHIGH && config.high_out_adf4350 ) ? 0: 0)
//#define SL_GENHIGH_LEVEL_MIN -15 //#define SL_GENHIGH_LEVEL_MIN -15
//#define SL_GENHIGH_LEVEL_RANGE 9 //#define SL_GENHIGH_LEVEL_RANGE 9
@ -3149,7 +3149,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
float ls=setting.level_sweep; // calculate and set the output level float ls=setting.level_sweep; // calculate and set the output level
if (ls > 0) if (ls > 0)
ls += 0.5; ls += 0.5;
else else if (ls < 0)
ls -= 0.5; ls -= 0.5;
float a = ((int)((setting.level + ((float)i / sweep_points) * ls)*2.0)) / 2.0 /* + get_level_offset() */ ; float a = ((int)((setting.level + ((float)i / sweep_points) * ls)*2.0)) / 2.0 /* + get_level_offset() */ ;
correct_RSSI_freq = get_frequency_correction(f); // No direct in output correct_RSSI_freq = get_frequency_correction(f); // No direct in output

Loading…
Cancel
Save

Powered by TurnKey Linux.