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
This commit is contained in:
erikkaashoek 2019-09-19 21:28:56 +02:00
parent 2255127a98
commit acd944d5fa

28
main.c
View file

@ -176,27 +176,27 @@ transform_domain(void)
for (int ch = 0; ch < 2; ch++) { for (int ch = 0; ch < 2; ch++) {
memcpy(tmp, measured[ch], sizeof(measured[0])); memcpy(tmp, measured[ch], sizeof(measured[0]));
if (beta != 0.0) { // if (beta != 0.0) {
for (int i = 0; i < 101; i++) { // for (int i = 0; i < 101; i++) {
float w = kaiser_window(i+offset, window_size, beta); // float w = kaiser_window(i+offset, window_size, beta);
tmp[i*2+0] *= w; // tmp[i*2+0] *= w;
tmp[i*2+1] *= w; // tmp[i*2+1] *= w;
} // }
} // }
for (int i = 101; i < 128; i++) { for (int i = 0; i < 128; i +=2) {
tmp[i*2+0] = 0.0; tmp[256 - i+0] = tmp[i+0];
tmp[i*2+1] = 0.0; tmp[256 - i+1] = -tmp[i+1];
} }
fft128_inverse((float(*)[2])tmp); fft128_inverse((float(*)[2])tmp);
memcpy(measured[ch], tmp, sizeof(measured[0])); memcpy(measured[ch], tmp, sizeof(measured[0]));
for (int i = 0; i < 101; i++) { for (int i = 0; i < 101; i++) {
measured[ch][i][0] /= 128.0; 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 ) { if ( (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_STEP ) {
for (int i = 1; i < 101; i++) { for (int i = 1; i < 101; i++) {
measured[ch][i][0] += measured[ch][i-1][0]; 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" #define VERSION "unknown"
#endif #endif
const char NANOVNA_VERSION[] = VERSION; const char NANOVNA_VERSION[] = "edy555 0.1.1";
static void cmd_version(BaseSequentialStream *chp, int argc, char *argv[]) static void cmd_version(BaseSequentialStream *chp, int argc, char *argv[])
{ {
(void)argc; (void)argc;
(void)argv; (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[]) static void cmd_vbat(BaseSequentialStream *chp, int argc, char *argv[])