mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
Size fixes
- bandwidth count stored in menu (less error on add new values) - allow set any bandwidth count from command - bandwidth command print bandwidth freq on apply
This commit is contained in:
parent
ddf51987eb
commit
2ed2f96f4a
2
dsp.c
2
dsp.c
|
|
@ -42,7 +42,7 @@ const int16_t sincos_tbl[48][2] = {
|
|||
};
|
||||
#if 0
|
||||
void generate_DSP_Table(int offset){
|
||||
float audio_freq = 48000.0;
|
||||
float audio_freq = AUDIO_ADC_FREQ;
|
||||
// N = offset * AUDIO_SAMPLES_COUNT / audio_freq; should be integer
|
||||
// AUDIO_SAMPLES_COUNT = N * audio_freq / offset; N - minimum integer value for get integer AUDIO_SAMPLES_COUNT
|
||||
// Bandwidth on one step = audio_freq / AUDIO_SAMPLES_COUNT
|
||||
|
|
|
|||
40
main.c
40
main.c
|
|
@ -92,7 +92,6 @@ volatile uint8_t redraw_request = 0; // contains REDRAW_XXX flags
|
|||
|
||||
// sweep operation variables
|
||||
volatile uint8_t wait_count = 0;
|
||||
static uint8_t accumerate_count = 0;
|
||||
|
||||
static uint16_t p_sweep = 0;
|
||||
// ChibiOS i2s buffer must be 2x size (for process one while next buffer filled by DMA)
|
||||
|
|
@ -745,7 +744,7 @@ void load_default_properties(void)
|
|||
current_props._active_marker = 0;
|
||||
current_props._domain_mode = 0;
|
||||
current_props._marker_smith_format = MS_RLC;
|
||||
current_props._bandwidth = 0;
|
||||
current_props._bandwidth = BANDWIDTH_1000;
|
||||
//Checksum add on caldata_save
|
||||
//current_props.checksum = 0;
|
||||
}
|
||||
|
|
@ -791,8 +790,8 @@ void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n)
|
|||
int16_t *p = &rx_buffer[offset];
|
||||
(void)i2sp;
|
||||
if (wait_count > 0){
|
||||
if (wait_count <= accumerate_count){
|
||||
if (wait_count == accumerate_count)
|
||||
if (wait_count <= bandwidth+1){
|
||||
if (wait_count == bandwidth+1)
|
||||
reset_dsp_accumerator();
|
||||
dsp_process(p, n);
|
||||
}
|
||||
|
|
@ -810,16 +809,6 @@ void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n)
|
|||
stat.callback_count++;
|
||||
}
|
||||
|
||||
// Bandwidth depend from AUDIO_SAMPLES_COUNT and audio ADC frequency
|
||||
// for AUDIO_SAMPLES_COUNT = 48 and ADC = 48kHz one measure give 48000/48=1000Hz
|
||||
static const int8_t bandwidth_accumerate_count[MAX_BANDWIDTH_IDX+1] = {
|
||||
1, // 1kHz
|
||||
3, // 300Hz
|
||||
10, // 100Hz
|
||||
33, // 30Hz
|
||||
100 // 10Hz
|
||||
};
|
||||
|
||||
static const I2SConfig i2sconfig = {
|
||||
NULL, // TX Buffer
|
||||
rx_buffer, // RX Buffer
|
||||
|
|
@ -830,7 +819,7 @@ static const I2SConfig i2sconfig = {
|
|||
0 // i2spr
|
||||
};
|
||||
|
||||
#define DSP_START(delay) {wait_count = delay-1 + accumerate_count;}
|
||||
#define DSP_START(delay) {wait_count = delay + bandwidth;}
|
||||
#define DSP_WAIT_READY while (wait_count) {if (operation_requested && break_on_operation) return false; __WFI();}
|
||||
#define DSP_WAIT while (wait_count) {__WFI();}
|
||||
#define RESET_SWEEP {p_sweep = 0;}
|
||||
|
|
@ -841,10 +830,9 @@ bool sweep(bool break_on_operation)
|
|||
{
|
||||
int delay=1;
|
||||
if (p_sweep>=sweep_points || break_on_operation == false) RESET_SWEEP;
|
||||
accumerate_count = bandwidth_accumerate_count[bandwidth];
|
||||
|
||||
// blink LED while scanning
|
||||
palClearPad(GPIOC, GPIOC_LED);
|
||||
START_PROFILE
|
||||
// Power stabilization after LED off, also align timings on delay == 0
|
||||
for (; p_sweep < sweep_points; p_sweep++) { // 5300
|
||||
if (frequencies[p_sweep] == 0) break;
|
||||
|
|
@ -874,7 +862,6 @@ bool sweep(bool break_on_operation)
|
|||
// Display SPI made noise on measurement (can see in CW mode)
|
||||
// ili9341_fill(OFFSETX+CELLOFFSETX, OFFSETY, (p_sweep * WIDTH)/(sweep_points-1), 1, RGB565(0,0,255));
|
||||
}
|
||||
STOP_PROFILE
|
||||
// blink LED while scanning
|
||||
palSetPad(GPIOC, GPIOC_LED);
|
||||
return true;
|
||||
|
|
@ -882,14 +869,11 @@ bool sweep(bool break_on_operation)
|
|||
|
||||
VNA_SHELL_FUNCTION(cmd_bandwidth)
|
||||
{
|
||||
if (argc != 1) {
|
||||
shell_printf("bandwidth %d\r\n", bandwidth);
|
||||
return;
|
||||
}
|
||||
uint8_t v = my_atoui(argv[0]);
|
||||
if (v>=sizeof(bandwidth_accumerate_count))
|
||||
return;
|
||||
bandwidth = v;
|
||||
if (argc != 1)
|
||||
goto result;
|
||||
bandwidth = my_atoui(argv[0]);
|
||||
result:
|
||||
shell_printf("bandwidth %d (%dHz)\r\n", bandwidth, (AUDIO_ADC_FREQ/AUDIO_SAMPLES_COUNT)/(bandwidth+1));
|
||||
}
|
||||
|
||||
VNA_SHELL_FUNCTION(cmd_scan)
|
||||
|
|
@ -1346,9 +1330,9 @@ cal_collect(int type)
|
|||
default:
|
||||
return;
|
||||
}
|
||||
// Run sweep for collect data (use naximum bandwidth setting)
|
||||
// Run sweep for collect data (use maximum bandwidth setting)
|
||||
uint8_t bw = bandwidth; // store current setting
|
||||
bandwidth = MAX_BANDWIDTH_IDX;
|
||||
bandwidth = BANDWIDTH_10;
|
||||
sweep(false);
|
||||
bandwidth = bw; // restore
|
||||
// Copy calibration data
|
||||
|
|
|
|||
12
nanovna.h
12
nanovna.h
|
|
@ -38,7 +38,16 @@
|
|||
#define VNA_PI 3.14159265358979323846
|
||||
|
||||
#define POINTS_COUNT 101
|
||||
#define MAX_BANDWIDTH_IDX 4
|
||||
|
||||
// Bandwidth depend from AUDIO_SAMPLES_COUNT and audio ADC frequency
|
||||
// for AUDIO_SAMPLES_COUNT = 48 and ADC = 48kHz one measure give 48000/48=1000Hz
|
||||
// define additional measure count
|
||||
#define BANDWIDTH_1000 ( 1 - 1)
|
||||
#define BANDWIDTH_300 ( 3 - 1)
|
||||
#define BANDWIDTH_100 ( 10 - 1)
|
||||
#define BANDWIDTH_30 ( 33 - 1)
|
||||
#define BANDWIDTH_10 (100 - 1)
|
||||
|
||||
extern float measured[2][POINTS_COUNT][2];
|
||||
|
||||
#define CAL_LOAD 0
|
||||
|
|
@ -105,6 +114,7 @@ extern const char *info_about[];
|
|||
* dsp.c
|
||||
*/
|
||||
// 5ms @ 48kHz
|
||||
#define AUDIO_ADC_FREQ 48000
|
||||
#define AUDIO_SAMPLES_COUNT 48
|
||||
// Buffer contain left and right channel samples (need x2)
|
||||
#define AUDIO_BUFFER_LEN (AUDIO_SAMPLES_COUNT*2)
|
||||
|
|
|
|||
14
ui.c
14
ui.c
|
|
@ -937,12 +937,12 @@ const menuitem_t menu_transform[] = {
|
|||
};
|
||||
|
||||
const menuitem_t menu_bandwidth[] = {
|
||||
{ MT_CALLBACK, 0, "1 kHz", menu_bandwidth_cb },
|
||||
{ MT_CALLBACK, 1, "300 Hz", menu_bandwidth_cb },
|
||||
{ MT_CALLBACK, 2, "100 Hz", menu_bandwidth_cb },
|
||||
{ MT_CALLBACK, 3, "30 Hz", menu_bandwidth_cb },
|
||||
{ MT_CALLBACK, 4, "10 Hz", menu_bandwidth_cb },
|
||||
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
||||
{ MT_CALLBACK, BANDWIDTH_1000, "1 kHz", menu_bandwidth_cb },
|
||||
{ MT_CALLBACK, BANDWIDTH_300, "300 Hz", menu_bandwidth_cb },
|
||||
{ MT_CALLBACK, BANDWIDTH_100, "100 Hz", menu_bandwidth_cb },
|
||||
{ MT_CALLBACK, BANDWIDTH_30, "30 Hz", menu_bandwidth_cb },
|
||||
{ MT_CALLBACK, BANDWIDTH_10, "10 Hz", menu_bandwidth_cb },
|
||||
{ MT_CANCEL, 255, S_LARROW" BACK", NULL },
|
||||
{ MT_NONE, 0, NULL, NULL } // sentinel
|
||||
};
|
||||
|
||||
|
|
@ -1385,7 +1385,7 @@ menu_item_modify_attribute(const menuitem_t *menu, int item,
|
|||
*fg = config.menu_normal_color;
|
||||
}
|
||||
} else if (menu == menu_bandwidth) {
|
||||
if (item == bandwidth) {
|
||||
if (menu_bandwidth[item].data == bandwidth) {
|
||||
*bg = 0x0000;
|
||||
*fg = 0xffff;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue