Correct delta unit and fast trigger sweeps

tinySA-v0.2
erikkaashoek 6 years ago
parent a56868cdb0
commit 2925336314

@ -818,7 +818,7 @@ void SI4432_Init(void);
void SI4432_Drive(int); void SI4432_Drive(int);
float SI4432_RSSI(uint32_t i, int s); float SI4432_RSSI(uint32_t i, int s);
#ifdef __FAST_SWEEP__ #ifdef __FAST_SWEEP__
void SI4432_Fill(int s); void SI4432_Fill(int s, int start);
#endif #endif
void SI4432_Set_Frequency ( long Freq ); void SI4432_Set_Frequency ( long Freq );
float SI4432_SET_RBW(float WISH); float SI4432_SET_RBW(float WISH);

@ -845,6 +845,7 @@ static void trace_get_value_string(
int ii = i; int ii = i;
int unit_index = setting.unit; int unit_index = setting.unit;
if (mtype & M_DELTA) { if (mtype & M_DELTA) {
unit_index = setting.unit+5;
if (ri > i) { if (ri > i) {
dfreq = frequencies[ri] - frequencies[i]; dfreq = frequencies[ri] - frequencies[i];
ii = ri - i; ii = ri - i;
@ -855,7 +856,6 @@ static void trace_get_value_string(
buf2[0] = '+'; buf2[0] = '+';
} }
rlevel = value(coeff[ri]); rlevel = value(coeff[ri]);
unit_index = U_DBC;
} else { } else {
dfreq = frequencies[i]; dfreq = frequencies[i];
} }
@ -884,6 +884,7 @@ static void trace_get_value_string(
#endif #endif
} else { } else {
uint32_t resolution = get_sweep_frequency(ST_SPAN)/290; uint32_t resolution = get_sweep_frequency(ST_SPAN)/290;
#if 0
if (resolution <= 2000) if (resolution <= 2000)
plot_printf(&buf2[1], sizeof(buf2) -1, "%3.3f" , (dfreq + 500) / 1000000.0); plot_printf(&buf2[1], sizeof(buf2) -1, "%3.3f" , (dfreq + 500) / 1000000.0);
else if (resolution <= 20000) else if (resolution <= 20000)
@ -891,6 +892,15 @@ static void trace_get_value_string(
else else
plot_printf(&buf2[1], sizeof(buf2) -1, "%3.1f" , (dfreq + 50000) / 1000000.0); plot_printf(&buf2[1], sizeof(buf2) -1, "%3.1f" , (dfreq + 50000) / 1000000.0);
} }
#else
int digits = 1;
if (resolution <= 2000)
digits = 3;
else if (resolution <= 20000)
digits = 2;
plot_printf(&buf2[1], sizeof(buf2) -1, "%3.*f" , digits, (dfreq + 50000) / 1000000.0);
}
#endif
// frequency_string(&buf2[1], sizeof(buf2) -1, dfreq); // frequency_string(&buf2[1], sizeof(buf2) -1, dfreq);
v = value(coeff[i]); v = value(coeff[i]);
if (mtype & M_NOISE) if (mtype & M_NOISE)

@ -130,8 +130,8 @@ float calc_min_sweep_time(void) // Calculate minimum sweep time in mS
else { else {
if (FREQ_IS_CW()) { if (FREQ_IS_CW()) {
a = (float)MINIMUM_SWEEP_TIME / 290.0; // time per step in CW mode a = (float)MINIMUM_SWEEP_TIME / 290.0; // time per step in CW mode
if (setting.trigger != T_AUTO || setting.repeat != 1 || setting.sweep_time >= 1000) if (setting.repeat != 1 || setting.sweep_time >= 1000)
a = 15.0 / 290.0; // time per step in CW mode with trigger a = 15.0 / 290.0; // time per step in CW mode with repeat
} }
t = vbwSteps * sweep_points * (setting.spur ? 2 : 1) * ( (a + (setting.repeat - 1)* REPEAT_TIME/1000.0)); t = vbwSteps * sweep_points * (setting.spur ? 2 : 1) * ( (a + (setting.repeat - 1)* REPEAT_TIME/1000.0));
} }
@ -193,6 +193,8 @@ void set_sweep_time(float t)
if (t > 600000.0) if (t > 600000.0)
t = 600000.0; t = 600000.0;
setting.sweep_time = t; setting.sweep_time = t;
if (FREQ_IS_CW())
update_grid(); // Really only needed in zero span mode
dirty = true; dirty = true;
} }
@ -1296,7 +1298,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking)
skip_LO_setting: skip_LO_setting:
#ifdef __FAST_SWEEP__ #ifdef __FAST_SWEEP__
if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && actualStepDelay == 0 && setting.repeat == 1 && setting.sweep_time < 1000) { if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && actualStepDelay == 0 && setting.repeat == 1 && setting.sweep_time < 1000) {
SI4432_Fill(MODE_SELECT(setting.mode)); SI4432_Fill(MODE_SELECT(setting.mode), 0);
} }
#endif #endif
@ -1331,6 +1333,11 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking)
break; // abort break; // abort
if (subRSSI < setting.trigger_level) if (subRSSI < setting.trigger_level)
goto wait; goto wait;
#ifdef __FAST_SWEEP__
if (i == 0 && setting.frequency_step == 0 /* && setting.trigger == T_AUTO */ && old_actual_step_delay == 0 && setting.repeat == 1 && setting.sweep_time < 1000) {
SI4432_Fill(MODE_SELECT(setting.mode), 1);
}
#endif
actualStepDelay = old_actual_step_delay; // Trigger happened, restore step delay actualStepDelay = old_actual_step_delay; // Trigger happened, restore step delay
if (setting.trigger == T_SINGLE) if (setting.trigger == T_SINGLE)
pause_sweep(); // Trigger once so pause after this sweep has completed!!!!!!! pause_sweep(); // Trigger once so pause after this sweep has completed!!!!!!!
@ -1819,7 +1826,7 @@ float my_round(float v)
return v; return v;
} }
const char * const unit_string[] = { "dBm", "dBmV", "dBuV", "V", "W", "dBc" }; const char * const unit_string[] = { "dBm", "dBmV", "dBuV", "V", "W", "dBc", "dBmVc", "dBuVc", "Vc", "Wc" }; // unit + 5 is delta unit
static const float scale_value[]={50000, 20000, 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20,10,5,2,1,0.5,0.2,0.1,0.05,0.02,0.01,0.005,0.002, 0.001,0.0005,0.0002, 0.0001}; static const float scale_value[]={50000, 20000, 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20,10,5,2,1,0.5,0.2,0.1,0.05,0.02,0.01,0.005,0.002, 0.001,0.0005,0.0002, 0.0001};
static const char * const scale_vtext[]= {"50000", "20000", "10000", "5000", "2000", "1000", "500", "200", "100", "50", "20","10","5","2","1","0.5","0.2","0.1","0.05","0.02","0.01", "0.005","0.002","0.001", "0.0005","0.0002","0.0001"}; static const char * const scale_vtext[]= {"50000", "20000", "10000", "5000", "2000", "1000", "500", "200", "100", "50", "20","10","5","2","1","0.5","0.2","0.1","0.05","0.02","0.01", "0.005","0.002","0.001", "0.0005","0.0002","0.0001"};

@ -320,7 +320,7 @@ extern char age[POINTS_COUNT];
static int buf_index = 0; static int buf_index = 0;
static bool buf_read = false; static bool buf_read = false;
void SI4432_Fill(int s) void SI4432_Fill(int s, int start)
{ {
SI4432_Sel = s; SI4432_Sel = s;
int sel = SI_nSEL[SI4432_Sel]; int sel = SI_nSEL[SI4432_Sel];
@ -328,7 +328,7 @@ void SI4432_Fill(int s)
if (t < 0) if (t < 0)
t = 0; t = 0;
int ti = t * 1000 / 290.0; // Now in uS per point if (t < 30000) int ti = t * 1000 / 290.0; // Now in uS per point if (t < 30000)
for (int i=0; i<POINTS_COUNT; ) { for (int i=start; i<POINTS_COUNT; ) {
SPI2_CLK_LOW; SPI2_CLK_LOW;
palClearPad(GPIOC, sel); palClearPad(GPIOC, sel);
shiftOut( 0x26 ); shiftOut( 0x26 );
@ -337,7 +337,7 @@ void SI4432_Fill(int s)
if (ti) if (ti)
my_microsecond_delay(ti); my_microsecond_delay(ti);
} }
buf_index = 0; buf_index = start;
buf_read = true; buf_read = true;
} }
#endif #endif

Loading…
Cancel
Save

Powered by TurnKey Linux.