Abstract This paper
introduces three methods of FIR filter design using MATLAB signal processing toolbox: program design method, FDATool design method and SPTool design method. Detailed design steps are given, and the designed filter is applied to a mixed sine wave signal to verify the performance of the filter.
Keywords
MATLAB, digital filter, finite impulse response, window function, simulation
1 Introduction
A digital filter is a digital system used to filter discrete-time signals. It achieves the purpose of frequency domain filtering by mathematically processing the sampled data. According to the time domain characteristics of its unit impulse response function, it can be divided into two categories: infinite impulse response (IIR) filter and finite impulse response (FIR) filter. Compared with IIR filters, the implementation of FIR is non-recursive and always stable; more importantly, FIR filters can obtain strict linear phase characteristics while meeting the amplitude-frequency response requirements. Therefore, it is widely used in high-fidelity signal processing, such as digital audio, image processing, data transmission, biomedicine and other fields.
2 Window Function Design Method of FIR Filter
There are many methods for designing FIR filters, such as window function design method, frequency sampling design method and optimization design method. The basic principle of window function design method is to use a certain width window function to intercept an infinite impulse response sequence to obtain a finite length impulse response sequence. The main design steps are:
(1) Obtain the unit impulse response hd(n) of the ideal filter through inverse Fourier transform.
(2) Determine the window function W(n) and window length N based on the performance index.
(3) Obtain the unit impulse response h(n) of the actual filter, h(n) is the designed FIR filter coefficient vector b(n).
(4) Test the filter performance.
This paper will design a FIR bandpass filter for a mixed sine wave signal containing 5Hz, 15Hz and 30Hz, and give three methods to implement it using MATLAB: program design method, FDATool design method and SPTool design method. Parameter requirements: sampling frequency fs=100Hz, passband lower limit cutoff frequency fc1=10 Hz, passband upper limit cutoff frequency fc2=20 Hz, transition bandwidth 6 Hz, pass-stop band fluctuation 0.01, and Kaiser window design.
2 Programming method
MATLAB signal processing toolbox provides a variety of window functions, filter design functions and filter implementation functions. The bandpass filter design and filtering program of this article are as follows:
[n,Wn,beta,ftype]=kaiserord([7 13 17 23],[0 1 0],[0.01 0.01 0.01],100);
%The order of the filter is n=38, beta=3.4
w1=2*fc1/fs; w2=2*fc2/fs; %Convert the technical indicators of the analog filter to the technical indicators of the digital filter
window=kaiser(n+1,beta); %Use the kaiser window function
b=fir1(n,[w1 w2],window); Use the standard frequency response window design function fir1
freqz(b,1,512); %Digital filter frequency response
t = (0:100)/Fs;
s = sin(2*pi*t*5)+sin(2*pi*t*15)+sin(2*pi*t*30);%Mixed sine wave signal
sf = filter(b,1,s);%Filter signal s
The result of program execution is shown in Figure 1:
(1) Filter amplitude-frequency characteristics and phase-frequency characteristics (2) Waveforms before and after filtering
Figure 1 Filter characteristics and filtering effect diagram
4 FDATool design method
FDATool (Filter Design & Analysis Tool) is a filter design and analysis tool dedicated to the MATLAB signal processing toolbox. It is simple and flexible to operate, and can use a variety of methods to design FIR and IIR filters. Enter FDATool in the MATLAB command window and press Enter to pop up the FDATool interface.
4.1 Bandpass filter design
The order of the known filter is n=38, beta=3.4. In this example, first select Bandpass in Filter Type; select FIR Window in the Design Method option, then select Kaiser in the Window option, and the Beta value is 3.4; specify the Specify order in the Filter Order item to 38; sampling frequency Fs=100Hz, cutoff frequency Fc1=10Hz, Fc2=20Hz. After setting, click Design Filter at the bottom of the window, and you will see the amplitude-frequency response of the designed filter at the top of the window. Through the menu option Analysis, you can also see the phase-frequency response, group delay, impulse response, step response, zero-pole configuration, etc. of the filter. After the design is completed, save the result as kaiser15.fda file.
4.2 Simulink simulation
In the Simulink environment, the filter file kaiser15.fda is imported into the Digital Filter Design module. The input signal is s(t)=sin(10πt)+sin(30πt)+sin(60πt). The generated simulation diagram and filtering effect are shown in Figure 2.
(1) Simulink simulation diagram (2) Discrete waveforms before and after filtering
Figure 2 Simulink simulation diagram and filtering effect diagram
5 SPTool design method
SPTool is an interactive graphical user interface tool that comes with the MATLAB signal processing toolbox. It includes most of the functions in the signal processing toolbox and can easily and quickly complete the analysis, design and browsing of signals, filters and spectra. In this example, the following steps are taken to complete the design and filtering of the filter:
Create and import the signal source.
Enter the command in the MATLAB command window:
Fs = 100; t = (0:100)/Fs;
s = sin(2*pi*t*5)+sin(2*pi*t*15)+sin(2*pi*t*30);
At this time, the variables Fs, t, and s will be displayed in the workspace list. Type Sptool in the command window, and the Sptool main interface will pop up, as shown in Figure 3; click the menu File/Import to import the signal s and name it s.
(2) Click New under the Filters list and design the filter filt1 according to the parameter requirements. The specific steps are similar to 3.2.1.
(3) Apply the filter filt1 to the s signal sequence. Select s, filt1, and mtlbse in the Signals, Filters, and Spectra lists respectively, click the Apply button under the Filters list, and name the output signal sin15hz in the Apply Filter dialog box that pops up.
(4) Perform spectrum analysis. Select s in Signals, click the Create button under Spectra, select Method as FFT and Nfft=512 in the Spectra Viewer interface that pops up, and click the Apply button to generate the spectrum spect1 of s. The same steps can be used to generate the spectrum spect2 of the signal sin15hz.
Select the signals s, sin15hz, spect1, and spect2 respectively, and click the View button under each list to observe their waveforms, as shown in Figure 4.
Figure 3 SPTool main interface Figure 4 Time domain waveform and frequency domain characteristics before and after filtering
As can be seen from Figure 4, the bandpass filter filt1 allows the 15 Hz sine wave signal in the input signal s to pass, while greatly attenuating the 5 Hz and 30 Hz sine wave signals.
6 Conclusion
This paper introduces three methods of using MATLAB to implement FIR filter design and filtering through a design example. From the simulation results, it can be seen that they can all meet the technical index requirements, and the methods are simple and fast, which greatly reduces the workload. After the filter design work is completed, the system function H(z) of the designed filter can be exported with the help of MATLAB's export operation. Since MATLAB has powerful interface functions, the simulation results can be easily transplanted to devices such as DSP, CPLD or FPGA. In practical applications, only the filter parameters need to be modified as required, and the program needs to be modified slightly to realize FIR filters with different cutoff frequencies, which is very practical.
Previous article:DES algorithm principle
Next article:IIR filter source program designed using matlab - IIR first-order low-pass/high-pass
Recommended ReadingLatest update time:2024-11-16 20:55
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
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
- RISC-V MCU Development Practice (Part 4): Stepper Motor
- The problem that PL2303 driver cannot be used under win10
- EEWORLD University ----TI Precision Labs 5 - I2C
- MicroPython ported to WCH-CH32V307 RISC-V MCU
- I need help with the answers to the second edition of Electronics.
- Internal structure problem of SG2525A chip
- The versatile NeoPixel board
- ADI's award-winning live broadcast will start at 10:00 this morning: Voltage Reference Product Technology and Application Selection
- TGF4042 Function Signal Generator Evaluation: Waveform Superposition
- CircuitPython Show