Sterling
Sterling
DIIDevHeads IoT Integration Server
Created by Sterling on 8/8/2024 in #middleware-and-os
How to store and manage ADC values in a 2D array for FFT processing in an FMCW radar system
I am using an FMCW radar to determine the distance and speed of a moving object with an STM32L476 microcontroller. To find the range of a stationary object, I store the ADC values into the "fft_in" array using the "HAL_ADC_ConvCpltCallback" function. I have initialized "is_data_ready_for_fft = 1" as follows:
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc1) {
is_data_ready_for_fft = 1;
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc1) {
is_data_ready_for_fft = 1;
}
Then, I calculate the range using FFT. Now, I need to store this 1D array of ADC values in a 2D array to calculate the Doppler frequency across the chirp index. The code that copies ADC values into the fft_in array and performs the range calculation is in the file below () Here is the desired matrix structure, where each fft_in array at different times forms rows of the matrix:
[0,0] = fft_in(0)[0], [0,1] = fft_in(0)[1], ..., [0,512] = fft_in(0)[512]
[1,0] = fft_in(1)[0], [1,1] = fft_in(1)[1], ..., [1,512] = fft_in(1)[512]
[2,0] = fft_in(2)[0], [2,1] = fft_in(2)[1], ..., [2,512] = fft_in(2)[512]
...
[19,0] = fft_in(19)[0], [19,1] = fft_in(19)[1], ..., [19,512] = fft_in(19)[512]
#The chirp index is taken as 20, and the number of samples is 512. Thus, FFT across rows yields range, and FFT across columns yields velocity.
[0,0] = fft_in(0)[0], [0,1] = fft_in(0)[1], ..., [0,512] = fft_in(0)[512]
[1,0] = fft_in(1)[0], [1,1] = fft_in(1)[1], ..., [1,512] = fft_in(1)[512]
[2,0] = fft_in(2)[0], [2,1] = fft_in(2)[1], ..., [2,512] = fft_in(2)[512]
...
[19,0] = fft_in(19)[0], [19,1] = fft_in(19)[1], ..., [19,512] = fft_in(19)[512]
#The chirp index is taken as 20, and the number of samples is 512. Thus, FFT across rows yields range, and FFT across columns yields velocity.
9 replies