Hey everyone, I'm doing a radar project to measure distances. More specifically I am making an FMCW radar that uses the PSoC 6 BLE Kit (CY8C6347BZI-BLD53, U1) to do the dsp and displaying of the distance using a 4-bit 7-segment display. Probably should have used PSoC 5 for dsp but I'm just using what I have currently.
How I intended for the project to work:
Run an ADC to collect a period's worth of data from both a transmitted and received signal (both are roughly triangle waves around 25 Hz). Then both data sets are run through FFT's (currently using the CMSIS DSP library, Frequency Bin Example) and related functions to get the frequency magnitudes and bin values. I then find the frequency peaks of each signal and find their difference, which can then be used to find the distance of an object from the radar system.
The FFT function arm_Cfft_f32 seems to not be doing what I expected and after calculating the frequency peaks. After testing with a frequency generator and changing frequencies, the values out remain to be around 600 Hz, which means somewhere the FFT is going wrong, or maybe the data being inputted is incorrect, but that can't be due to it just coming out of the ADC. It could be because I'm using a complex FFT whereas there is both signals are real so that could be causing an issue, but I'm not 100% sure. To summarize, the issue I'm having is with the outputs of each signals FFT, leading to incorrect peak frequency outputs.
Attached is my project.
First make sure you are getting the desired data from the ADC. You can check out the example ADC project CE220974 which I am guessing you already have.
For FFT, I would recommend using the real FFT function since your data set is real and the function is computationally faster. Here is how I would do it:
1- arm_rfft_fast_init_f32(&S, N_SAMPLES); /* make sure the N_SAMPLES is a power of 2 and greater or equal to 32 */
2- arm_rfft_fast_f32(&S, adc_in, adc_in, FALSE); /* both source and destination array can be the same since the FFT functions operate in-place */
3- arm_cmplx_mag_f32(adc_in, FFT_output, HALF_N_SAMPLES); /* FFT_output array would be half the size of the adc_in array since it is all real
4- find your peak from the FFT_output
Now you could also use the complex FFT but the input array would then have to have alternate real and complex values as mentioned at Complex FFT Functions and shown below
Let me know if this helps.
EDIT: So if using complex FFT function, you will have to put zeros in between your real values since your complex component of the data set is zero.