mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
enhancement: adjust delay
This commit is contained in:
parent
b7fb2c390b
commit
58bf0fb151
28
main.c
28
main.c
|
|
@ -258,42 +258,48 @@ static void cmd_reset(BaseSequentialStream *chp, int argc, char *argv[])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DELAY_ON_GAIN_CHANGE 3
|
||||||
|
|
||||||
int set_frequency(int freq)
|
int set_frequency(int freq)
|
||||||
{
|
{
|
||||||
int delay = 0;
|
bool gain_changed = false;
|
||||||
if (frequency == freq)
|
if (frequency == freq)
|
||||||
return delay;
|
return 0;
|
||||||
|
|
||||||
if (freq > 1400000000 && frequency <= 1400000000) {
|
if (freq > 1400000000 && frequency <= 1400000000) {
|
||||||
tlv320aic3204_set_gain(95, 95);
|
tlv320aic3204_set_gain(95, 95);
|
||||||
delay += 10;
|
gain_changed = true;
|
||||||
} else
|
} else
|
||||||
if (freq > 1200000000 && frequency <= 1200000000) {
|
if (freq > 1200000000 && frequency <= 1200000000) {
|
||||||
tlv320aic3204_set_gain(85, 85);
|
tlv320aic3204_set_gain(85, 85);
|
||||||
delay += 10;
|
gain_changed = true;
|
||||||
} else
|
} else
|
||||||
if (freq > 900000000 && frequency <= 900000000) {
|
if (freq > 900000000 && frequency <= 900000000) {
|
||||||
tlv320aic3204_set_gain(75, 75);
|
tlv320aic3204_set_gain(75, 75);
|
||||||
delay += 10;
|
gain_changed = true;
|
||||||
} else
|
} else
|
||||||
if (freq > 600000000 && frequency <= 600000000) {
|
if (freq > 600000000 && frequency <= 600000000) {
|
||||||
tlv320aic3204_set_gain(50, 50);
|
tlv320aic3204_set_gain(50, 50);
|
||||||
delay += 10;
|
gain_changed = true;
|
||||||
} else
|
} else
|
||||||
if (freq > FREQ_HARMONICS && frequency <= FREQ_HARMONICS) {
|
if (freq > FREQ_HARMONICS && frequency <= FREQ_HARMONICS) {
|
||||||
tlv320aic3204_set_gain(40, 40);
|
tlv320aic3204_set_gain(40, 40);
|
||||||
delay += 10;
|
gain_changed = true;
|
||||||
} else
|
} else
|
||||||
if (freq <= FREQ_HARMONICS && frequency > FREQ_HARMONICS) {
|
if (freq <= FREQ_HARMONICS && frequency > FREQ_HARMONICS) {
|
||||||
tlv320aic3204_set_gain(0, 0);
|
tlv320aic3204_set_gain(0, 0);
|
||||||
delay += 10;
|
gain_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t ds = drive_strength;
|
int8_t ds = drive_strength;
|
||||||
if (ds == DRIVE_STRENGTH_AUTO) {
|
if (ds == DRIVE_STRENGTH_AUTO) {
|
||||||
ds = freq > FREQ_HARMONICS ? SI5351_CLK_DRIVE_STRENGTH_8MA : SI5351_CLK_DRIVE_STRENGTH_2MA;
|
ds = freq > FREQ_HARMONICS ? SI5351_CLK_DRIVE_STRENGTH_8MA : SI5351_CLK_DRIVE_STRENGTH_2MA;
|
||||||
}
|
}
|
||||||
delay += si5351_set_frequency_with_offset(freq, frequency_offset, ds);
|
|
||||||
|
int delay = si5351_set_frequency_with_offset(freq, frequency_offset, ds);
|
||||||
|
if (gain_changed && delay < DELAY_ON_GAIN_CHANGE) {
|
||||||
|
delay = DELAY_ON_GAIN_CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
frequency = freq;
|
frequency = freq;
|
||||||
return delay;
|
return delay;
|
||||||
|
|
@ -642,6 +648,8 @@ ensure_edit_config(void)
|
||||||
cal_status = 0;
|
cal_status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DELAY_CHANNEL_CHANGE 1
|
||||||
|
|
||||||
// main loop for measurement
|
// main loop for measurement
|
||||||
bool sweep(bool break_on_operation)
|
bool sweep(bool break_on_operation)
|
||||||
{
|
{
|
||||||
|
|
@ -659,7 +667,7 @@ bool sweep(bool break_on_operation)
|
||||||
(*sample_func)(measured[0][i]);
|
(*sample_func)(measured[0][i]);
|
||||||
|
|
||||||
tlv320aic3204_select_in1(); // CH1:TRANSMISSION
|
tlv320aic3204_select_in1(); // CH1:TRANSMISSION
|
||||||
wait_dsp(delay);
|
wait_dsp(delay + DELAY_CHANNEL_CHANGE);
|
||||||
|
|
||||||
/* calculate transmission coeficient */
|
/* calculate transmission coeficient */
|
||||||
(*sample_func)(measured[1][i]);
|
(*sample_func)(measured[1][i]);
|
||||||
|
|
|
||||||
10
si5351.c
10
si5351.c
|
|
@ -295,6 +295,10 @@ si5351_set_frequency(int channel, int freq, uint8_t drive_strength)
|
||||||
|
|
||||||
int current_band = -1;
|
int current_band = -1;
|
||||||
|
|
||||||
|
#define DELAY_NORMAL 1
|
||||||
|
#define DELAY_BANDCHANGE 1
|
||||||
|
#define DELAY_LOWBAND 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* configure output as follows:
|
* configure output as follows:
|
||||||
* CLK0: frequency + offset
|
* CLK0: frequency + offset
|
||||||
|
|
@ -306,7 +310,7 @@ int
|
||||||
si5351_set_frequency_with_offset(int freq, int offset, uint8_t drive_strength)
|
si5351_set_frequency_with_offset(int freq, int offset, uint8_t drive_strength)
|
||||||
{
|
{
|
||||||
int band;
|
int band;
|
||||||
int delay = 3;
|
int delay = DELAY_NORMAL;
|
||||||
uint32_t ofreq = freq + offset;
|
uint32_t ofreq = freq + offset;
|
||||||
uint32_t rdiv = SI5351_R_DIV_1;
|
uint32_t rdiv = SI5351_R_DIV_1;
|
||||||
if (freq > 900000000) {
|
if (freq > 900000000) {
|
||||||
|
|
@ -388,8 +392,10 @@ si5351_set_frequency_with_offset(int freq, int offset, uint8_t drive_strength)
|
||||||
#if 1
|
#if 1
|
||||||
si5351_enable_output();
|
si5351_enable_output();
|
||||||
#endif
|
#endif
|
||||||
delay += 10;
|
delay += DELAY_BANDCHANGE;
|
||||||
}
|
}
|
||||||
|
if (band == 0)
|
||||||
|
delay += DELAY_LOWBAND;
|
||||||
|
|
||||||
current_band = band;
|
current_band = band;
|
||||||
return delay;
|
return delay;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue