From acd944d5fa1c8bfd016b27c65e92e14e81f755c8 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Thu, 19 Sep 2019 21:28:56 +0200 Subject: [PATCH] Modified FFT to avoid window function Instead of doing a window function its better to extend the FFT to twice the length with the complex conjugate. Then after the FFT trow away the imag part. As the FFT is limited to 128 point I only used the first 64. Better would be to exten to128 and then af extending with the complex conjugate do a 256 point FFT --- main.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/main.c b/main.c index 2a82795..6713b82 100644 --- a/main.c +++ b/main.c @@ -176,27 +176,27 @@ transform_domain(void) for (int ch = 0; ch < 2; ch++) { memcpy(tmp, measured[ch], sizeof(measured[0])); - if (beta != 0.0) { - for (int i = 0; i < 101; i++) { - float w = kaiser_window(i+offset, window_size, beta); - tmp[i*2+0] *= w; - tmp[i*2+1] *= w; - } - } - for (int i = 101; i < 128; i++) { - tmp[i*2+0] = 0.0; - tmp[i*2+1] = 0.0; +// if (beta != 0.0) { +// for (int i = 0; i < 101; i++) { +// float w = kaiser_window(i+offset, window_size, beta); +// tmp[i*2+0] *= w; +// tmp[i*2+1] *= w; +// } +// } + for (int i = 0; i < 128; i +=2) { + tmp[256 - i+0] = tmp[i+0]; + tmp[256 - i+1] = -tmp[i+1]; } fft128_inverse((float(*)[2])tmp); memcpy(measured[ch], tmp, sizeof(measured[0])); for (int i = 0; i < 101; i++) { measured[ch][i][0] /= 128.0; - measured[ch][i][1] /= 128.0; + measured[ch][i][1] = 0; } if ( (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_STEP ) { for (int i = 1; i < 101; i++) { measured[ch][i][0] += measured[ch][i-1][0]; - measured[ch][i][1] += measured[ch][i-1][1]; +// measured[ch][i][1] += measured[ch][i-1][1]; } } } @@ -1888,13 +1888,13 @@ static void cmd_stat(BaseSequentialStream *chp, int argc, char *argv[]) #define VERSION "unknown" #endif -const char NANOVNA_VERSION[] = VERSION; +const char NANOVNA_VERSION[] = "edy555 0.1.1"; static void cmd_version(BaseSequentialStream *chp, int argc, char *argv[]) { (void)argc; (void)argv; - chprintf(chp, "%s\r\n", NANOVNA_VERSION); + chprintf(chp, "%s %s\r\n", NANOVNA_VERSION, "extended with scan command"); } static void cmd_vbat(BaseSequentialStream *chp, int argc, char *argv[])