Command levelsweep added

tinySA-v0.2
erikkaashoek 6 years ago
parent 979f369724
commit 5ce6439211

@ -2268,6 +2268,7 @@ static const VNAShellCommand commands[] =
{ "if", cmd_if, 0 },
{ "attenuate", cmd_attenuate, 0 },
{ "level", cmd_level, 0 },
{ "levelsweep", cmd_levelsweep, 0 },
{ "modulation", cmd_modulation, 0 },
{ "reflevel", cmd_reflevel, 0 },
{ "rbw", cmd_rbw, 0 },

@ -183,6 +183,8 @@ void set_drive(int d);
void set_IF(int f);
void set_step_delay(int t);
void set_repeat(int);
void set_level_sweep(float);
void set_level(float);
//extern int setting.repeat;
//extern int setting.rbw;
#ifdef __SPUR__
@ -571,6 +573,8 @@ typedef struct setting
float trigger_level;
int trigger;
int linearity_step;
float level;
float level_sweep;
int test_argument;
uint32_t checksum;
}setting_t;
@ -775,6 +779,7 @@ void SI4432_Write_Byte(byte ADR, byte DATA );
byte SI4432_Read_Byte( byte ADR );
void SI4432_Init(void);
void SI4432_Drive(int);
float SI4432_RSSI(uint32_t i, int s);
void SI4432_Set_Frequency ( long Freq );
float SI4432_SET_RBW(float WISH);

@ -92,10 +92,23 @@ VNA_SHELL_FUNCTION(cmd_level)
shell_printf("usage: level -76..20\r\n");
return;
}
int a = my_atoi(argv[0]);
set_attenuation(a);
float f = my_atof(argv[0]);
set_level(f);
}
VNA_SHELL_FUNCTION(cmd_levelsweep)
{
if (argc != 1) {
usage:
shell_printf("usage: levelsweep -76..+76\r\n");
return;
}
float f = my_atof(argv[0]);
set_level_sweep(f);
}
VNA_SHELL_FUNCTION(cmd_reflevel)
{
if (argc != 1) {

@ -48,6 +48,8 @@ void reset_settings(int m)
setting.frequency_IF = 433800000;
setting.offset = 0.0;
setting.trigger = T_AUTO;
setting.level_sweep = 0.0;
setting.level = -15.0;
setting.trigger_level = -150.0;
setting.linearity_step = 0;
trace[TRACE_STORED].enabled = false;
@ -155,6 +157,12 @@ void set_drive(int d)
dirty = true;
}
void set_level_sweep(float l)
{
setting.level_sweep = l;
}
void set_tracking_output(int t)
{
setting.tracking_output = t;
@ -235,6 +243,13 @@ int get_attenuation(void)
return(setting.attenuate);
}
void set_level(float v)
{
setting.level = v;
set_attenuation((int)v);
dirty = true;
}
void set_attenuation(int a)
{
if (setting.mode == M_GENLOW) {
@ -951,6 +966,40 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking)
dirty = false;
}
if (setting.level_sweep != 0.0) {
static int old_a = -150;
int a = setting.level + (i / 290.0) * setting.level_sweep;
if (a != old_a) {
old_a = a;
int d = 0; // Start at lowest drive level;
a = a + POWER_OFFSET;
if (a > 0) {
d++;
a = a - 3;
}
if (a > 0) {
d++;
a = a - 3;
}
if (a > 0) {
d++;
a = a - 3;
}
SI4432_Sel = 0;
SI4432_Drive(d);
if (a > 0)
a = 0;
if( a > - SWITCH_ATTENUATION) {
set_switch_transmit();
} else {
a = a + SWITCH_ATTENUATION;
set_switch_receive();
}
a = -a;
PE4302_Write_Byte(a * 2 );
}
}
if (MODE_OUTPUT(setting.mode) && setting.modulation == MO_AM) { // AM modulation
int p = setting.attenuate * 2 + am_modulation[modulation_counter];
PE4302_Write_Byte(p);

@ -145,6 +145,11 @@ void SI4432_Reset(void)
}
}
void SI4432_Drive(int d)
{
SI4432_Write_Byte(0x6D, (byte) (0x18+(d & 7)));
}
void SI4432_Transmit(int d)
{
int count = 0;

@ -279,7 +279,7 @@ const uint16_t right_icons [] =
enum {
KM_START=1, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_REFPOS, KM_SCALE, KM_ATTENUATION,
KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, KM_10MHZ, KM_REPEAT, KM_OFFSET, KM_TRIGGER,
KM_ACTUALPOWER, KM_IF, KM_SAMPLETIME, KM_DRIVE, KM_LOWOUTLEVEL, KM_DECAY, KM_NOISE, KM_10MHZ, KM_REPEAT, KM_OFFSET, KM_TRIGGER, KM_LEVELSWEEP,
};
@ -391,6 +391,7 @@ static const keypads_t * const keypads_mode_tbl[] = {
keypads_level, // KM_REPEA
keypads_level, // KM_OFFSET
keypads_level, // KM_TRIGGER
keypads_level, // KM_LEVELSWEEP
};
#ifdef __VNA__
@ -402,7 +403,7 @@ static const char * const keypad_mode_label[] = {
static const char * const keypad_mode_label[] = {
"error", "START", "STOP", "CENTER", "SPAN", "FREQ", "REFPOS", "SCALE", // 0-7
"\2ATTENUATE\0 0-31dB", "ACTUALPOWER", "IF", "SAMPLE TIME", "DRIVE", "LEVEL", "LEVEL", "LEVEL", // 8-15
"OFFSET" , "REPEATS", "OFFSET", "TRIGGER"// 16-
"OFFSET" , "REPEATS", "OFFSET", "TRIGGER", "LEVELSWEEP"// 16-
};
#endif
@ -1059,6 +1060,7 @@ const menuitem_t menu_lowoutputmode[] = {
{ MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", NULL},
{ MT_FORM | MT_SUBMENU, 0, "MODULATION: %s", menu_modulation},
{ MT_FORM | MT_KEYPAD, KM_SPAN, "SPAN: %s", NULL},
{ MT_FORM | MT_KEYPAD, KM_LEVELSWEEP, "LEVELSWEEP: %s", NULL},
// { MT_FORM | MT_KEYPAD, KM_10MHZ, "10MHZ: %s", NULL},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
@ -1718,7 +1720,11 @@ static void fetch_numeric_target(void)
break;
case KM_OFFSET:
uistat.value = setting.offset;
plot_printf(uistat.text, sizeof uistat.text, "%fdB", uistat.value);
plot_printf(uistat.text, sizeof uistat.text, "%.1fdB", uistat.value);
break;
case KM_LEVELSWEEP:
uistat.value = setting.level_sweep;
plot_printf(uistat.text, sizeof uistat.text, "%.1fdB", uistat.value);
break;
case KM_TRIGGER:
uistat.value = setting.trigger_level;
@ -1785,7 +1791,7 @@ set_numeric_value(void)
set_drive(uistat.value);
break;
case KM_LOWOUTLEVEL:
set_attenuation(uistat.value);
set_level(uistat.value);
break;
case KM_DECAY:
set_decay(uistat.value);
@ -1803,6 +1809,9 @@ set_numeric_value(void)
case KM_OFFSET:
set_offset(uistat.value);
break;
case KM_LEVELSWEEP:
set_level_sweep(uistat.value);
break;
case KM_TRIGGER:
set_trigger_level(uistat.value);
break;

Loading…
Cancel
Save

Powered by TurnKey Linux.