Analysis of DSP for Floating Point Fast Fourier Transform

Foreword

The purpose of this paper is to demonstrate how to use the internal DSP of STM32F30x for floating-point fast Fourier transform (FFT). For the actual application, ADC is used to sample the waveform generator, and then the ADC sampling result is FFT. Compare with Matlab simulation results. The accuracy of the final result. The ARMDSP library file, as well as the floating point unit of the STM32F30x and DSP instructions, are used.

Simulate ADC sample data to implement FFT

Generate AM modulated waveforms using Matlab

The waveform formula is: AM_50= sin(2Ï€fc)*(1+50%*sin(2Ï€fm)), where fc is the carrier frequency, fm is the modulation wave frequency, and the modulation ratio is 50%. In order to use the ADC sampling, the waveform is offset and superimposed with a voltage of 1.5V. The final waveform expansion formula is as follows:

AM_50 = sin(2 π fc) + 50%*sin(2 π fm))* sin(2 π fc) + 1.5

The Matlab program is as follows:

x =sin(2*pi*fm*t); % modulation wave

Figure;plot(t,x);y =sin(2*pi*fc*t); % carrier wavefigure;plot(t,y);z1 =y.*(1+m1*x) + 1.5; % AM Wave with 50% depthfigure; %figure 1plot(t,z1);xlabel('Time');ylabel('Amplitude');title('AM with50% depth');Z1 =z1*4096/3.3; % 12- Bit ADC Value

The resulting waveform is as follows:

Figure [1]

Generate analog ADC data and perform FFT operations using STM32F30x

The generated data is stored in the AM_50_ADC_Data[] array, the real number is converted to a complex number, the CFFT operation is performed, the arm_cfft_f32 library function is called, and the 1024-point FFT is performed.

/* Real data to magnitudedata */

For(i=0; i {testInput_f32_10khz[i*2+1] =0; testInput_f32_10khz[i*2] = AM_50_ADC_Data[i];}

/* Process the data throughthe CFFT/CIFFT module */

Arm_cfft_f32(&arm_cfft_sR_f32_len1024, testInput_f32_10khz, ifftFlag, doBitReverse);

/* Process the data throughthe Complex Magnitude Module forcalculating the magnitude ateach bin */

Arm_cmplx_mag_f32(testInput_f32_10khz,testOutput, fftSize);

Results printed and compared with Matlab calculations

For the convenience of display, only the integer part is compared: Figure [2] is the Matlab output, and Figure [3] is the result after the STM32F30x calculation.

Figure II】

Figure [three]

From the data point of view, Matlab simulation and STM32F30x FFT are very consistent, and the data can be used directly. Based on the time data conversion to the frequency domain, theoretically, the DC component, the frequency fc, and the frequency fc-fm, fc+fm will have peaks. Actually, the FFT waveform is as follows:

Actual ADC sampling and FFT operation

The waveform generator is used to generate 50% amplitude modulation wave, carrier 10KHz, modulation wave 1KHz, modulation ratio 50%, and offset 1.5V.

The STM32F30x is used for ADC sampling. The sampling results are stored in an array. The data is imported into Matlab and the waveforms are as follows:

The FFT transform is performed based on the ADC sample data, and the analysis results are as follows:

in conclusion:

The waveform sampled by the STM32F30x's ADC can be fully fast Fourier transformed, and the results are in line with theoretical expectations. And the STM32F30x's FPU and DSP module make it easy to change quickly, which brings great convenience to practical applications.


General Purpose Servo Motors

General Purpose Servo Motors,Cnc Lathe Electric Motors,Cnc Lathe Servo Motor,Servo Motor For Sewing Machine

Zhejiang Synmot Electrical Technology Co., Ltd , https://www.synmot-electrical.com