At present, the textbooks on digital signal processing in China are all based on complex FFT. The real FFT algorithms are all taken over. The specific implementation programs given in the book are mostly BASIC or FORTRAN programs. Most can't really run. In view of the fact that FFT operations are currently used in many embedded systems, such as DSP-based AC sampling systems, spectrum analysis, and correlation analysis. I combined my own practical development experience, studied the real FFT algorithm and gave the specific C language function, the reader can directly apply to their own system.
Firstly, the derivation process of real FFT algorithm is analyzed, and then a C language program which implements FFT algorithm is given, which can be directly applied to embedded systems such as single chip microcomputer or DSP which require FFT operation.
1 inverted order algorithm analysis
The time-decimated (DIT) FFT algorithm usually stores the original data in reverse order, and finally outputs the results X(0), X(1), ..., X(k), ... in the normal order. Assume that at the beginning, the data is in the array float dataR[128], we denote the subscript i as (b6b5b4b3b2b1b0)b, and the reverse order storage is to store the elements of the original i-th position to the position of the (b0b1b2b3b4b5b6)b. Since the bit operation ability of C language is very strong, b6, b5, b4, b3, b2, b1, b0 can be extracted separately, and then recombined into b0, b1, b2, b3, b4, b5, b6, which is the inversion The location of the order. The block is as follows (assuming a 128-point FFT):
/* i is the original storage location, and finally invert_pos is the reverse order storage location*/
Int b0=b1=b2=b3=b4=b5=6=0;
B0=i&0x01; b1=(i/2)&0x01; b2=(i/4)&0x01;
B3=(i/8)&0x01; b4=(i/16)&0x01; b5=(i/32)&0x01;
B6=(i/64)&0x01; /* The above statement extracts the 0 and 1 values ​​of each bit*/
Invert_pos=x0*64+x1*32+x2*16+x3*8+x4*4+x5*2+x6;
You can compare the reverse order program on the textbook, and you will find that this algorithm makes full use of the bit manipulation ability of the C language, which is very easy to understand and the bit operation speed is very fast.
2 Derivation of real butterfly algorithm
Let us first look at the butterfly diagram shown in Figure 1.

Butterfly formula:
X(K) = X'(K) + X'(K+B)W PN ,
X(K+B) = X'(K) - X'(K+B) W PN
Where W PN = cos(2Ï€P/N) - jsin(2Ï€P/N).
Let X(K+B) = XR(K+B) + jXI(K+B),
X(K) = XR(K) + jXI(K) ,
Have:
XR(K)+jXI(K)= XR'(K)+jXI'(K)+[ XR'(K+B) + jXI'(K+B)]*[ cos(2Ï€P/N)-jsin( 2Ï€P/N)];
Continue to decompose to get the following two formulas:
XR(K)= XR'(K)+ XR'(K+B) cos(2Ï€P/N)+ XI'(K+B) sin (2Ï€P/N) (1)
XI(K)= XI'(K)-XR'(K+B) sin(2Ï€P/N)+XI'(K+B)cos (2Ï€P/N) (2)
It should be noted that: XR(K) and XR'(K) have the same storage location, so after (1) and (2), the value at this position has changed, and the following X (K+B) is used. To X'(K), it is important to save XR'(K) and XI'(K) to TR and TI temporary variables during programming.
Similarly: XR(K+B)+jXI(K+B)= XR'(K)+jXI'(K)- [ XR'(K+B)+jXI'(K+B)] *[ cos( 2Ï€P/N)-jsin(2Ï€P/N)] continues to decompose to obtain the following two equations:
XR(K+B)= XR'(K)-XR'(K+B) cos(2Ï€P/N)- XI'(K+B) sin (2Ï€P/N) (3)
XI(K+B)= XI'(K)+ XR'(K+B) sin(2Ï€P/N)- XI'(K+B) cos (2Ï€P/N) (4)
note:
1 When programming, XR'(K) and XI'(K) in equations (3) and (4) are replaced by TR and TI, respectively.
2 After the equation (3), the value of XR(K+B) has changed, and the value of the previous level at the position is used in equation (4), so the previous one must be performed before the execution of equation (3). The value of the level XR' (K+B) is saved.
3 When programming, XR(K) and XR'(K), XI(K) and XI'(K) use the same variable.
Through the above analysis, we only need to convert the formulas (1), (2), (3), (4) into C language statements. Pay attention to the middle of the variable, see the following program section.
/* Butterfly operation block, dataR[] stores the real part, and dataI[] stores the imaginary part*/
/* cos, sin function into a table, directly look up the table to speed up the operation * /
TR=dataR[k]; TI=dataI[k]; temp=dataR[k+b];/*Save variables for later statements*/
dataR[k]=dataR[k]+dataR[k+b]*cos_tab[p]+dataI[k+b]*sin_tab[p];
dataI[k]=dataI[k]-dataR[k+b]*sin_tab[p]+dataI[k+b]*cos_tab[p];
dataR[k+b]=TR-dataR[k+b]*cos_tab[p]-dataI[k+b]*sin_tab[p];
dataI[k+b]=TI+temp*sin_tab[p]-dataI[k+b]*cos_tab[p];
This series is a traditional classic LED par light. As the most commonly used dyeing effect light on the stage, the par light is the most used one. There are not only styles suitable for indoor use, but also styles suitable for outdoor waterproofing. The brightness and effect are excellent. It is a very practical Stage Light. This series of lights is one of the most configured lights in the stage lights. It brings brightness and color transformation effects to the stage. It can make the stage effect better when matched with other series of effect lights.
Led Par Lights ,Led Par Can,Led Mini Flat Par Light,Led Par Can Light
Guangzhou Cheng Wen Photoelectric Technology Co., Ltd. , https://www.ledscreencw.com