Analysis of DSP for Floating Point Fast Fourier Transform

**Foreword** This paper aims to demonstrate the use of the internal DSP capabilities of the STM32F30x microcontroller for performing a floating-point Fast Fourier Transform (FFT). The process involves using the ADC to sample signals from a waveform generator, followed by an FFT analysis of the sampled data. The results are then compared with those obtained from a MATLAB simulation to evaluate the accuracy of the implementation. The ARM DSP library, along with the floating-point unit and DSP instructions of the STM32F30x, are utilized throughout the process. **Generating AM Modulated Waveforms in MATLAB** The waveform used is an amplitude-modulated signal defined by the formula: AM_50 = sin(2Ï€fc) * (1 + 50% * sin(2Ï€fm)), where fc is the carrier frequency, fm is the modulation frequency, and the modulation depth is 50%. To make it suitable for ADC sampling, the waveform is shifted by 1.5V. The final expression becomes: AM_50 = [sin(2Ï€fc) + 50% * sin(2Ï€fm)] * sin(2Ï€fc) + 1.5 The MATLAB code for generating this waveform is as follows: ```matlab x = sin(2*pi*fm*t); % Modulation wave figure; plot(t,x); y = sin(2*pi*fc*t); % Carrier wave figure; plot(t,y); z1 = y.*(1 + m1*x) + 1.5; % AM Wave with 50% depth figure; plot(t,z1); xlabel('Time'); ylabel('Amplitude'); title('AM with 50% depth'); Z1 = z1 * 4096 / 3.3; % Convert to 12-bit ADC value ``` The resulting waveform is shown in Figure [1]. **Simulating ADC Data and Performing FFT on STM32F30x** The generated waveform data is stored in the `AM_50_ADC_Data[]` array. This real-valued data is converted into complex format before applying the CFFT operation using the `arm_cfft_f32` function from the ARM DSP library. A 1024-point FFT is performed, followed by magnitude calculation using the `arm_cmplx_mag_f32` function. The code snippet for this process is as follows: ```c /* Convert real data to complex format */ for(i=0; i < fftSize/2; i++) { testInput_f32_10khz[i*2+1] = 0; testInput_f32_10khz[i*2] = AM_50_ADC_Data[i]; } /* Process the data through the CFFT/CIFFT module */ arm_cfft_f32(&arm_cfft_sR_f32_len1024, testInput_f32_10khz, ifftFlag, doBitReverse); /* Calculate the magnitude at each bin */ arm_cmplx_mag_f32(testInput_f32_10khz, testOutput, fftSize); ``` The results are printed and compared with MATLAB's output. For display purposes, only the integer parts are compared. Figure [2] shows the MATLAB output, while Figure [3] displays the result from the STM32F30x. **Actual ADC Sampling and FFT Analysis** A waveform generator is used to produce a 50% AM signal with a carrier frequency of 10kHz, a modulation frequency of 1kHz, and a DC offset of 1.5V. The STM32F30x performs ADC sampling, and the data is stored in an array. When imported into MATLAB, the sampled waveform matches the expected shape. An FFT is then applied to the ADC samples, and the frequency domain representation is obtained. The results show peaks at the DC component, the carrier frequency (10kHz), and the sidebands (9kHz and 11kHz), which aligns with theoretical expectations. **Conclusion** The ADC-sampled waveform from the STM32F30x can be accurately transformed using FFT, and the results match theoretical predictions. The built-in FPU and DSP capabilities of the STM32F30x enable fast and efficient processing, making it highly suitable for real-world applications. This demonstrates the practicality and effectiveness of using the STM32F30x for signal analysis tasks.

Three Phase Ammeter

Three Phase Ammeter,Voltage Ammeter,Three-Phase Power Meter,Power Instrument

zhejiangjinyidianqiyouxiangongsi , https://www.jooeei.com