introduction
With the advent of the information age and the digital world, digital signal processing has become an extremely important discipline and technical field. Digital signal processing has been widely used in many fields such as communication, voice, image, automatic control, radar, military, aerospace, medical and household appliances. In digital signal processing applications, digital filters are very important and have been widely used.
1 Design of digital filter
1.1 Basic steps in digital filter design
Digital filters can be divided into two types according to the time domain characteristics of their impulse response functions, namely infinite impulse response (IIR) filters and finite impulse response (FIR) filters. The characteristic of IIR filters is that they have impulse responses of infinite duration. This type of filter generally needs to be implemented using a recursive model, so it is sometimes also called a recursive filter. The impulse response of the FIR filter can only last for a certain period of time. In engineering practice, it can be implemented recursively or non-recursively. There are many methods for designing digital filters, such as bilinear transformation method, window function design method, interpolation approximation method, Chebyshev approximation method, etc. With the continuous improvement of MATLAB software, especially MATLAB's signal processing workbox, not only has the computer-aided design of digital filters become possible, but the design can also be optimized.
The basic steps in digital filter design are as follows:
(1) Determine the indicators
Before designing a filter, the technical indicators of the filter must be determined according to the actual needs of the project. In many practical applications, digital filters are often used to implement frequency selection operations. Therefore, the form of the indicator generally gives the amplitude and phase response in the frequency domain. The amplitude indicator is mainly given in two ways. The first is an absolute indicator. It provides requirements for the amplitude response function and is generally used in the design of FIR filters. The second indicator is a relative indicator. It gives requirements in the form of decibel values. In engineering practice, this indicator is the most popular. For the phase response indicator form, it is usually hoped that the system has a linear phase in the passband. The use of linear phase response indicators for filter design has the following advantages: ① It only contains real number algorithms and does not involve complex number operations; ② There is no delay distortion, only a fixed number of delays; ③ For a filter with a length of N (the order is N-1), the calculation amount is on the order of N/2. Therefore, the design of the filter in this article takes the design of a linear phase FIR filter as an example.
(2) Approximation
After determining the technical indicators, a target digital filter model can be established. Usually, an ideal digital filter model is used. After that, a practical filter model is designed using the digital filter design method to approximate the given target.
(3) Performance analysis and computer simulation
The result of the above two steps is to obtain a filter described by differential or system function or impulse response. Based on this description, its frequency characteristics and phase characteristics can be analyzed to verify whether the design results meet the index requirements; or the designed filter can be implemented by computer simulation and then the filtering results can be analyzed to make a judgment.
1.2 MATLAB Design of Filter
(1) MATLAB
MATLAB is a high-performance visual language and software environment for scientific computing. It integrates numerical analysis, matrix operations, signal processing and graphic display to form a user-friendly interface. Its signal processing toolbox contains a variety of classic and modern digital signal processing technologies. It is an excellent tool for algorithm research and auxiliary design. When designing digital filters, MATLAB is usually used for auxiliary design and simulation.
(2) MATLAB design of FIR filter
The following introduces the specific design method by taking the design of linear phase FIR filter as an example.
Linear phase FIR filters are usually designed using the window function method. The basic idea of designing FIR filters using the window function method is to select the filter length N and the window function ω (n) based on the given filter technical indicators so that it has the narrowest main lobe and the smallest side lobe. The core is to determine the finite length unit impulse response sequence h (n) by adding a window from the given frequency characteristics. There are 6 commonly used window functions in engineering, namely rectangular window, Bartlett window, Hanning window, Hamming window, Blackman window and Kaiser window. [page]
Assume that the actual project needs to design a linear phase bandpass FIR filter with the following indicators:
fn=[1000,1375,3625,4000];
a=[0,1,0];
dev=[0.0005,0.05,0.0005];
The minimum attenuation of the stop band is 60dB. If the sampling frequency fs=10kHz, the Kaiser window is selected according to the minimum attenuation of the stop band. The required digital filter can be quickly designed by using MATLAB's order function and FIR filter design function. The two design functions are as follows:
[N,Wn,beta,ftype]=kaiserord(fn,a,dev,fs);
b=fir1(n,Wn,ftype,Kaiser(n+1,beta);
Finally, the filter analysis function freqz is used to analyze the amplitude-frequency characteristics and phase-frequency characteristics of the designed filter, and the graphical display function plot is used to display them, as shown in Figure 1. As can be seen from Figure 1, the design results meet the index requirements.
2 Implementation method of digital filter
There are generally several ways to implement digital filters.
① Use adders, multipliers, and delay devices to design special filtering circuits.
② Design and implement it by adding a dedicated acceleration processor to a general-purpose computer system.
③Implemented with general-purpose programmable DSP chip.
④ Use a dedicated DSP chip to implement. In some special occasions, the required signal processing speed is extremely high, which is difficult to achieve with a general-purpose DSP chip. This chip implements the corresponding filtering algorithm in hardware inside the chip without programming.
⑤Use FPGA/CPLD to design and implement.
Among the above methods, the disadvantage of the second method is that it is slow and can generally be used to simulate DSP algorithms. The first and fourth methods are highly specialized and their applications are greatly limited. The third and fifth methods can both be programmed to implement various digital filters, but the third method is easy to program because it has dedicated instructions to implement filtering operations, while the fifth method is more difficult to program.
3 DSP Implementation of Digital Filter
DSP is a real-time, fast microprocessor that is particularly suitable for implementing various digital signal processing operations. Due to its rich hardware resources, improved Harvard structure, high-speed data processing capabilities and powerful instruction system, it is widely used in various fields such as communications, aviation, aerospace, radar, industrial control, networks and household appliances. DSP is divided into fixed-point and floating-point. The following takes the fixed-point DSP chip as an example to discuss several key issues in the implementation of FIR filters. These issues discussed have practical reference and application value in DSP system design.
3.1 Fixed-point number calibration
In fixed-point DSP chips, fixed-point numbers are used for numerical calculations, and their operands are generally represented by integers. The maximum representation range of an integer depends on the word length given by the DSP chip, which is generally 16 bits or 24 bits. Obviously, the longer the word length, the larger the range of numbers that can be represented and the higher the precision. In the implementation of the filter, the numbers to be processed by the DSP may be integers, decimals, or mixed decimals; however, when the DSP executes arithmetic instructions, it does not know whether the data currently processed is an integer or a decimal, and it cannot point out where the decimal point is. Therefore, when programming, it is necessary to specify where the decimal point of a number is located, which is calibration. Through calibration, the decimal point can be determined at different positions of a 16-bit number, thereby representing a decimal with different ranges and different precisions. For example: in Q15, 1080H=0.12890625; in Q0, 1080H=4224.
When using fixed-point DSP, how to choose the appropriate Q value is a key issue. In terms of the processing process of DSP operations, the variables actually involved in the operation are variables, some of which are unknown, and some of which change their values continuously during the operation process, but they all have a certain dynamic range as a physical parameter in an actual engineering environment. As long as the dynamic range is determined, the Q value is also determined. Therefore, before programming, we must first find out the range of variation of all variables involved in the operation through careful and rigorous analysis, fully estimate the various situations that may occur in the operation, and then determine which calibration standard to use to ensure that the operation results are correct and reliable. Here, the theoretical analysis method and statistical analysis method discussed determine the maximum absolute value of the variable |max|, and then determine the Q value based on |max|. However, unexpected situations in the DSP operation process are unavoidable, and even if statistical analysis is used, it is impossible to cover all situations. Therefore, some judgment and protection measures should be taken in the fixed-point operation process (especially in fixed-point addition). In addition, a large number of operations in digital signal processing are multiplication and accumulation, and pure integer or pure decimal operations should be used as much as possible, that is, all variables are represented in Q0 or Q15 format. The advantage of this is that it is simple to operate and easy to program. Only when pure integer or pure decimal operations cannot meet the dynamic range and precision requirements of the variable, mixed decimal representation is used for fixed-point operations.
3.2 Error Problem
Because when using fixed-point DSP to implement, all data are fixed-length, and all operations are fixed-point operations, so there will be a finite word length effect. The errors generated mainly include: quantization error caused by digital-to-analog conversion, error caused by coefficient quantization, and rounding error in the operation process. When using fixed-point DSP, errors are inevitable, but some methods can be used to reduce the errors. For example, two storage units can be used to represent a number, and double-word operations can be used during operations; the filter coefficients can be represented by double words as needed, or only half of the coefficients can be represented by double words, depending on the needs. In addition, the quantization errors introduced by FIR digital filters and IIR digital filters are different. FIR digital filters mainly use non-recursive structures, so they are stable in finite precision operations; while IIR digital filters are recursive structures, and the poles must be within the unit circle of the z plane to be stable. The rounding process in the operation of this structure sometimes causes parasitic oscillations. In addition to the finite word length effect, the errors introduced by different structures are also different. In actual design, attention should be paid to the error problem in implementation. When choosing different structures, the errors they introduce should be considered, and fixed-point simulation should be performed using a high-level language to compare the size of the errors under different structures so as to make a reasonable choice.
3.3 Circular Addressing
Circular addressing is an addressing method often used in DSP. This addressing method can implement circular operations on a specific storage area. Circular addressing can be understood as implementing a sliding window. When new data is introduced, it will overwrite the old data, so that the window contains the latest data to be processed. Circular addressing is extremely important in FIR, convolution and other operations in digital signal processing. [page]
In TI's DSP, circular addressing is implemented as follows.
① Set the BK (register block size) value to determine the size of the circular addressing buffer, which can also be regarded as the period of the loop.
② Set the bottom address of the buffer. Note that its lower N bits are zero, where N is the minimum N value that satisfies equation (1).
2 N>BK (1)
③Use auxiliary registers to indirectly address the circular buffer.
3.4 Implementation Example
According to the FIR filter designed above, considering the actual needs of the project (precision requirements) and the convenience of using fixed-point DSP chips, Q15 calibration is selected. To this end, the input data and the coefficients of the filter must be normalized. The normalization of the input data can be achieved by setting the reference level of the A/D conversion. The normalization of the filter coefficients only requires taking the maximum value of the coefficients, and then using this maximum value to remove the coefficients.
Since an N (assuming N is an even number) order FIR filter has coefficient symmetry, its output equation can be written as:
y(n)=ao[x(n)+x(n-N+1)]+a1[x(n-1)+x(n-N+2)]+…+aN/2-1[X (nN/2+1)+x(nN/2)] (2)
According to formula (2), the following implementation algorithm can be established:
① Open two circular buffers in the data storage, the New circular buffer stores new data, and the O1d circular buffer stores old data. The length of the circular buffer is N/2.
② Set the circular buffer pointer, AR2 points to the latest data in the New buffer, and AR3 points to the oldest data in the O1d buffer.
③Set the coefficient table in the program memory.
④ (AR2) + (AR3) → AH (high bit of accumulator A); (AR2) -1 → AR2; (AR3) -1 → AR3.
⑤ Clear accumulator B and repeat the following operation N/2 times: (AH)*coefficient ai+(B)→B, coefficient pointer (PAR) increases by 1, (AR2)+(AR3)→AH, AR2 and AR3 decrease by 1.
⑥Save and output the results (the results are in BH).
⑦ Correct the data pointers so that AR2 and AR3 point to the latest data in the New buffer and the oldest data in the O1d buffer respectively.
⑧ Replace the oldest data in the O1d buffer with the oldest data in the New buffer. The O1d buffer pointer is reduced by 1.
⑨ Input a new data to replace the oldest data in the New buffer.
Repeat steps ④ to 9.
According to the above algorithm, the program was compiled [4, 5], and the simulation and debugging were carried out on CCS5000. The input data and output spectrum were analyzed, and the results are shown in Figure 2 and Figure 3. It can be seen from the figure that the filter achieves the target requirements.
Finally, the program was transplanted into the interrupt service program of MCBSP0 of Wenting's TMS320VC5409 evaluation board, and the resulting executable file was loaded onto the evaluation board for operation. The analog signal is input from the analog input port of the TMS320VC5409 evaluation board, and is converted into a digital signal at a sampling frequency of 8kHz by the TLC320A/D conversion chip, and then input into the DSP. After filtering, the analog quantity is output through the D/A. The results show that the program can realize real-time filtering of analog signals with a sampling rate of 8kHz.
Conclusion
Digital filters are widely used. Running MATLAB language, it is easy to design filters with strict requirements (such as linear phase, etc.). To implement filters with fixed-point DSP, several key issues such as DSP calibration, error, and circular addressing must be considered. The example in this article is to show that DSP can be used to easily implement real-time filtering of analog signals, and the sampling frequency used is not high. If DSP uses a higher clock, its processing speed will be faster and will be able to meet the real-time filtering of digital signals with higher sampling rates.
Previous article:In-circuit programming of DSP external Flash memory through JTAG port
Next article:Design of hierarchical distributed management system based on DSP chip
Recommended ReadingLatest update time:2024-11-16 20:39
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Programming example of msp430 keypress
- Compensation Designer 2P2Z controller S domain model understanding
- MSP430 G2553 Launchpad implements capacitance measurement
- [GD32L233C-START Review] 12. Button - External Interrupt
- [Qinheng RISC-V core CH582] Environment configuration and lighting test
- Design and implementation of image cropping circuit based on FPGA
- MSP430 Launchpad MSP430g2452 SHT10 Temperature and Humidity Sensor
- Establishment of RF chip/modem chip design team
- F28335 uses external SRAM for program simulation
- Do you know about the programmer and emulator of msp430?