/*****************fft programe*********************/
#include "typedef.h"
#include "math.h"
struct compx EE(struct compx b1,struct compx b2)
{
struct compx b3 ;
b3.real=b1.real*b2.real-b1.imag*b2.imag ;
b3.imag=b1.real*b2.imag+b1.imag*b2.real ;
return(b3);
}
void FFT(struct compx*xin,int N)
{
int f,m,nv2,nm1,i,k,j=1,l ;
/*int f,m,nv2,nm1,i,k,j=N/2,l;*/
struct compx v,w,t ;
nv2=N/2 ;
f=N ;
for(m=1;(f=f/2)!=1;m++)
{
;
}
nm1=N-1 ;
/*变址运算*/
for(i=1;i<=nm1;i++)
{
if(i
t=xin[j];
xin[j]=xin[i];
xin[i]=t ;
}
k=nv2 ;
while(k
j=j-k ;
k=k/2 ;
}
j=j+k ;
}
{
int le,lei,ip ;
float pi ;
for(l=1;l<=m;l++)
{
le=pow(2,l);
// 这里用的是L而不是1 !!!!
lei=le/2 ;
pi=3.14159 ;
v.real=1.0 ;
v.imag=0.0 ;
w.real=cos(pi/lei);
w.imag=-sin(pi/lei);
for(j=1;j<=lei;j++)
{
/*double p=pow(2,m-l)*j;
double ps=2*pi/N*p;
w.real=cos(ps);
w.imag=-sin(ps);*/
for(i=j;i<=N;i=i+le)
{
/* w.real=cos(ps);
w.imag=-sin(ps);*/
ip=i+lei ;
t=EE(xin[ip],v);
xin[ip].real=xin[i].real-t.real ;
xin[ip].imag=xin[i].imag-t.imag ;
xin[i].real=xin[i].real+t.real ;
xin[i].imag=xin[i].imag+t.imag ;
}
v=EE(v,w);
}
}
}
return ;
}
/*****************main programe********************/
#include
#include
#include
#include "typedef.h"
float result[257];
struct compx s[257];
int Num=256 ;
const float pp=3.14159 ;
main()
{
int i=1 ;
for(;i<0x101;i++)
{
s[i].real=sin(pp*i/32);
s[i].imag=0 ;
}
FFT(s,Num);
for(i=1;i<0x101;i++)
{
result[i]=sqrt(pow(s[i].real,2)+pow(s[i].imag,2));
}
}
Previous article:DSP Basics
Next article:Design of SoPC automatic fingerprint recognition system
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- I can't receive emails after submitting IAR RISC-V. Can anyone help me try?
- Disassembling the Garmin vivosmart wristband
- wants topic /camera/rgb/image_raw/compressed to have datatype/md5sum
- PCB design experience - for reference
- Confused, what is an oscilloscope with a Z axis? Don't worry, here is an introduction
- STM32 Hefei Seminar
- "Recommend Chinese Chip" + Minsilicon (ARM core 32-bit MCU)
- Wireless communication, 5G, RF, antenna and several concepts and indicators
- Happy Lantern Festival! Guess the lantern riddles and have fun
- How to make an automatic switch when there are 3 5V input ports on a circuit board?