level testing command added

Removed_REF_marker
erikkaashoek 5 years ago
parent 4926ad39cb
commit 47a4b2fadc

@ -2516,6 +2516,7 @@ static const VNAShellCommand commands[] =
#endif
#ifdef TINYSA4
{ "g", cmd_g, CMD_WAIT_MUTEX },
{ "q", cmd_q, CMD_WAIT_MUTEX },
{ "z", cmd_z, CMD_WAIT_MUTEX },
#endif
#ifdef __ADF4351__

@ -294,6 +294,10 @@ extern const char * const unit_string[];
extern freq_t ultra_threshold;
extern bool ultra;
extern float *drive_dBm;
extern int test_output;
extern int test_output_switch;
extern int test_output_drive;
extern int test_output_attenuate;
#else
extern const int8_t drive_dBm [];
#endif

@ -886,6 +886,7 @@ VNA_SHELL_FUNCTION(cmd_correction)
for (int i=0; i<CORRECTION_POINTS; i++) {
config.correction_value[m][i] = 0.0;
}
dirty = true; // recalculate intermediate table
shell_printf("correction table %s reset\r\n", argv[0]);
return;
}
@ -976,6 +977,36 @@ VNA_SHELL_FUNCTION(cmd_caloutput)
set_refer_output(m - 1);
}
#ifdef TINYSA4
VNA_SHELL_FUNCTION(cmd_q)
{
static const char cmd[] = "s|d|a";
if (argc < 1) {
usage:
shell_printf("usage: q s|d 0..18|a 0..63 %s\r\n", cmd);
test_output=false;
return;
}
int i = 0;
test_output=true;
test_output_switch = false;
test_output_drive = MAX_DRIVE;
test_output_attenuate = 0;
again:
if (argc == 0)
return;
int m = get_str_index(argv[i++], cmd);
argc--;
switch (m) {
case -1: goto usage;
case 0: test_output_switch = true; break;
case 1: test_output_drive = MAX_DRIVE - atoi(argv[i++]); argc--; break;
case 2: test_output_attenuate = atoi(argv[i++]); argc--; break;
}
goto again;
}
#endif
#pragma GCC pop_options

@ -75,7 +75,7 @@ static freq_t real_old_freq[4] = { 0, 0, 0, 0};
#endif
#ifdef TINYSA4
const float si_drive_dBm [] = {-41, -30, -21, -17, -14, -11, -10, -8, -7, -6, -5, -4, -3, -2.5 , -2, -1.5, -1, -0.5, 0};
const float si_drive_dBm [] = {-43, -30.1, -19.5, -15.5, -13, -11, -9.5, -8.1, -6.9, -5.9, -5, -4.2, -3.5, -2.8 , -2.2, -1.7, -1, -0.5, 0};
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};
float *drive_dBm = (float *) adf_drive_dBm;
@ -84,11 +84,11 @@ const int8_t drive_dBm [16] = {-38, -32, -30, -27, -24, -19, -15, -12, -5, -2, 0
#endif
#ifdef TINYSA4
#define SWITCH_ATTENUATION ((setting.mode == M_GENHIGH && config.high_out_adf4350) ? 40 : 37 - config.switch_offset)
#define SWITCH_ATTENUATION ((setting.mode == M_GENHIGH && config.high_out_adf4350) ? 40 : 35.8 - config.switch_offset)
//#define POWER_OFFSET -18 // Max level with all enabled
//#define POWER_RANGE 70
#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: 2)
#define MIN_DRIVE ((setting.mode == M_GENHIGH && config.high_out_adf4350 ) ? 0: 1)
//#define SL_GENHIGH_LEVEL_MIN -15
//#define SL_GENHIGH_LEVEL_RANGE 9
@ -2446,6 +2446,10 @@ void clock_at_48MHz(void)
#ifdef TINYSA4
int old_drive = -1;
int test_output = false;
int test_output_switch = false;
int test_output_drive = 0;
int test_output_attenuate = 0;
#endif
pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) // Measure the RSSI for one frequency, used from sweep and other measurement routines. Must do all HW setup
@ -2543,13 +2547,22 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
if (( setting.frequency_step != 0 || setting.level_sweep != 0.0 || i == 0)) { // Initialize or adapt output levels
if (setting.mode == M_GENLOW) {// if in low output mode and level sweep or frequency weep is active or at start of sweep
#ifdef TINYSA4
if (test_output) {
enable_rx_output(!test_output_switch);
SI4463_set_output_level(test_output_drive);
PE4302_Write_Byte(test_output_attenuate);
} else
#endif
{
float ls=setting.level_sweep; // calculate and set the output level
if (ls > 0)
ls += 0.5;
else
ls -= 0.5;
float a = ((int)((setting.level + ((float)i / sweep_points) * ls)*2.0)) / 2.0;
a += PURE_TO_float(get_frequency_correction(f));
correct_RSSI_freq = get_frequency_correction(f);
a += PURE_TO_float(correct_RSSI_freq);
if (a != old_a) {
int very_low_flag = false;
old_a = a;
@ -2600,6 +2613,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
#endif
}
}
}
else if (setting.mode == M_GENHIGH) {
float a = setting.level - level_max;
if (a <= -SWITCH_ATTENUATION) {
@ -2660,6 +2674,14 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
if (setting.frequency_step != 0)
correct_RSSI_freq = get_frequency_correction(f);
}
//#define DEBUG_CORRECTION
#ifdef DEBUG_CORRECTION
if (SDU1.config->usbp->state == USB_ACTIVE) {
shell_printf ("%d:%Q %d\r\n", i, f, correct_RSSI_freq);
osalThreadSleepMilliseconds(2);
}
#endif
// ----------------------------- Initiate modulation ---------------------------

Loading…
Cancel
Save

Powered by TurnKey Linux.