From 29253363143d6cf47609469d02064e260f8c6f82 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Mon, 15 Jun 2020 09:00:29 +0200 Subject: [PATCH] Correct delta unit and fast trigger sweeps --- nanovna.h | 2 +- plot.c | 14 ++++++++++++-- sa_core.c | 15 +++++++++++---- si4432.c | 6 +++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/nanovna.h b/nanovna.h index e3c5a57..a8f6484 100644 --- a/nanovna.h +++ b/nanovna.h @@ -818,7 +818,7 @@ void SI4432_Init(void); void SI4432_Drive(int); float SI4432_RSSI(uint32_t i, int s); #ifdef __FAST_SWEEP__ -void SI4432_Fill(int s); +void SI4432_Fill(int s, int start); #endif void SI4432_Set_Frequency ( long Freq ); float SI4432_SET_RBW(float WISH); diff --git a/plot.c b/plot.c index 4b80199..7590b81 100644 --- a/plot.c +++ b/plot.c @@ -845,6 +845,7 @@ static void trace_get_value_string( int ii = i; int unit_index = setting.unit; if (mtype & M_DELTA) { + unit_index = setting.unit+5; if (ri > i) { dfreq = frequencies[ri] - frequencies[i]; ii = ri - i; @@ -855,7 +856,6 @@ static void trace_get_value_string( buf2[0] = '+'; } rlevel = value(coeff[ri]); - unit_index = U_DBC; } else { dfreq = frequencies[i]; } @@ -884,6 +884,7 @@ static void trace_get_value_string( #endif } else { uint32_t resolution = get_sweep_frequency(ST_SPAN)/290; +#if 0 if (resolution <= 2000) plot_printf(&buf2[1], sizeof(buf2) -1, "%3.3f" , (dfreq + 500) / 1000000.0); else if (resolution <= 20000) @@ -891,7 +892,16 @@ static void trace_get_value_string( else plot_printf(&buf2[1], sizeof(buf2) -1, "%3.1f" , (dfreq + 50000) / 1000000.0); } -// frequency_string(&buf2[1], sizeof(buf2) -1, dfreq); +#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); v = value(coeff[i]); if (mtype & M_NOISE) v = v - 10*log10(actual_rbw*1000.0); diff --git a/sa_core.c b/sa_core.c index dc97b9f..da18012 100644 --- a/sa_core.c +++ b/sa_core.c @@ -130,8 +130,8 @@ float calc_min_sweep_time(void) // Calculate minimum sweep time in mS else { if (FREQ_IS_CW()) { 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) - a = 15.0 / 290.0; // time per step in CW mode with trigger + if (setting.repeat != 1 || setting.sweep_time >= 1000) + 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)); } @@ -193,6 +193,8 @@ void set_sweep_time(float t) if (t > 600000.0) t = 600000.0; setting.sweep_time = t; + if (FREQ_IS_CW()) + update_grid(); // Really only needed in zero span mode dirty = true; } @@ -1296,7 +1298,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) skip_LO_setting: #ifdef __FAST_SWEEP__ 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 @@ -1331,6 +1333,11 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) break; // abort if (subRSSI < setting.trigger_level) 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 if (setting.trigger == T_SINGLE) pause_sweep(); // Trigger once so pause after this sweep has completed!!!!!!! @@ -1819,7 +1826,7 @@ float my_round(float 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 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"}; diff --git a/si4432.c b/si4432.c index 18a0e14..d855249 100644 --- a/si4432.c +++ b/si4432.c @@ -320,7 +320,7 @@ extern char age[POINTS_COUNT]; static int buf_index = 0; static bool buf_read = false; -void SI4432_Fill(int s) +void SI4432_Fill(int s, int start) { SI4432_Sel = s; int sel = SI_nSEL[SI4432_Sel]; @@ -328,7 +328,7 @@ void SI4432_Fill(int s) if (t < 0) t = 0; int ti = t * 1000 / 290.0; // Now in uS per point if (t < 30000) - for (int i=0; i