Application of Matlab in FIR digital filter

Publisher:幸福家园Latest update time:2012-02-12 Keywords:Matlab Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The design scheme of FIR digital filter is proposed , and the filter simulation is realized based on Matlab. By using the functions provided by Matlab signal processing toolbox, the appropriate window function is selected to write the program, in which the window function is selected according to the processing requirements of the actual signal and the parameters are compromised. The experiment obtains relatively ideal filter characteristics and can achieve better filtering effect. Moreover, in practical applications, only the filter parameters need to be modified according to the requirements, and combined with the corresponding changes in the program, filters with different functions can be realized. In addition, the method of designing filters using FDATool is introduced, and a variety of filters can be realized by simply modifying the parameters.

1 Digital filter and design scheme

When applying digital filters to process analog signals, the input analog signals must first be band-limited, sampled, and converted to analog/digital. The sampling rate of the digital filter input signal should be greater than twice the bandwidth of the processed signal. Its frequency response has a periodic repetition characteristic with the sampling frequency as the interval, and is mirror-symmetric at the folding frequency, i.e., 1/2 sampling frequency. The output signal of the filter must be converted to digital/analog and smoothed.

The relationship between the output value u(Kt) of the FIR digital filter and the past value u(Kt-kt) of the output is as follows:

a.jpg

This is a process of continuous multiplication and accumulation, which solves the problem of the filter coefficient α. The filter design can be realized by adding multiplication and addition calculations. Since the unit impulse response h(n) of the FIR filter is a finite length sequence, the filter has no instability problem. The FIR filter is generally a non-recursive structure. Therefore, when using Matlab to design, finite precision calculation is used to avoid unstable phenomena such as polarity oscillation in the recursive structure. The two common FIR filter design methods are the window function method and the frequency sampling method. Although the frequency sampling method can accurately control the frequency response of the sampling point, the transition point must be inserted in the design to improve the ripple, and the cutoff frequency is not easy to control. The transition point also needs further optimization. In contrast, the window function rule is a basic design concept and the design method is relatively mature. In addition, the functions provided in Matlab can easily realize the design of windowed linear phase FIR filters, including the more common low-pass, band-pass, high-pass and band-stop digital filters. This paper adopts the design method of combining window function with programming.

The basic idea of ​​the window function method is to first give the ideal filter frequency response as

b.jpg

,

Where: ωc is the cut-off frequency; α is the sampling delay.

The required frequency response is

d.jpg

, the next task is to make

e.jpg

Approach

The windowed w(n) is truncated to the unit sampling response hd(n) (see equation (3)) of the ideal filter to obtain the h(n) to be designed.

e.jpg

For the FDATool design method, this paper uses Matlab to complete it by selecting appropriate parameters.

2 FIR digital filter design

2.1 Window function method to design FIR filter solution

In Matlab, window functions can be directly generated: Rectangle Window, Triangular Window, Hanging Window, Kaiser Window, etc. The window can be loaded by calling the system function. The specific calling method is as follows: calling format: w=function name (n), a rectangular window w is generated according to the length n. Generally, the normal ECG signal frequency range is within 0.05~100 Hz, which is itself a relatively weak electrical signal. When it is interfered by other organs of the body, the ECG signal will be seriously distorted. In addition, the existence of electronic device noise and 50 Hz power frequency signal must be considered. This requires to eliminate the influence of noise and interference as much as possible. The design indicators of the low-pass filter selected here are: passband cutoff frequency ωp=0.2π, stopband cutoff frequency ωs=0.3π, and minimum stopband attenuation As≥50 dB. Therefore, the transition bandwidth tr_width=ωs-ωp and the column length N=10 π/tr_width are obtained. When selecting a window function, it is generally recommended to choose a wider main lobe, which can increase the attenuation of the stopband and ensure the stability of the passband. In addition, while ensuring the minimum attenuation index of the stopband, the column length N value is appropriately increased to narrow the transition band. According to the characteristics of the minimum stopband attenuation of the window function. Only the Hamming window and the Kaiser window can provide an attenuation greater than 50 dB. In practical applications, the selection of window functions is mostly a compromise between them. The Kaiser window can compromise the main lobe width and sidelobe attenuation by changing the parameter value. The filter based on this has strong adaptability and is relatively flexible. This article adopts the Kaiser window programming design. The window function design method is to use a certain width window function to intercept an infinite pulse response sequence to obtain a finite length pulse response sequence. The design steps are:

(1) The unit impulse response hd(n) of the ideal filter is obtained by inverse Fourier transform.

f.jpg

(2) Determine the window function W(n) and window length N based on performance indicators.

(3) Obtain the unit impulse response h(n) of the actual filter, where h(n) is the designed FIR filter coefficient vector a(n).

g.jpg
(4) Check the filter performance.

The Matlab signal processing toolbox provides various window functions, filter design functions, and filter implementation functions. The design uses the function firl provided by Matlab, and programming is to directly call these functions to complete the design simply and intuitively. The calling format is: firl(n, Wn, 'ftype', Window), where n is the order, Wn is the cutoff frequency, ftype is the type of filter, and Window is the window function. The code for applying the Kaiser window is as follows:

The results of program execution are shown in Figure 1 and Figure 2.

From the filter effect diagram, the designed filter basically eliminates the influence of noise and interference, and objectively obtains the real signal. According to the filter indicators in the design scheme, the function operation can be obtained: N=68, As=59. Then increase the parameter N value. In this design, the Kaiser window function is used to perform a variety of N value changes. With the increase of N value, the transition band becomes narrower, but the minimum attenuation of the stop band does not change.

2.2 FDATool design

FDATool (Filter Design & Analysis Tool1) 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 filters. The digital filter designed by this method can adjust the filter characteristics at any time, and the filtering results are displayed in real time in the graphics area, which reduces the workload and is conducive to further optimization of the filter design. After entering FDATool in the Matlab command window and pressing Enter, the FDATool interface will pop up. You can also select "start" → "toolbox" → "filterdesign" below the Matlab main interface. The specific parameter selection is:

(1) The filter type is lowpass;

(2) The design method is FIR, using a window;

(3) The filter order is 15;

(4) The window type is Kaiser and beta is 0.5;

(5)fs is 48 000 Hz, fc is 10 800 Hz.

Click "design filter". It is worth noting that the filter order here is 15th order, not the designed 16th order filter. This is because the constant coefficient term h(0)=0. Select "magnitude" and "phase response" from the "analysis" menu to get the characteristic display of Figure 3 and Figure 4. Select "step response" and "im-pulse" from "analysis" to get the response display of Figure 5 and Figure 6. It can be seen that the step response and impulse response of the designed FIR filter are close to the ideal state.

3 Conclusion

From the characteristic curves of Figures 1 to 4, it can be seen that the performance of the filter has basically met the requirements, and the filtering effect is quite obvious. The curve is relatively stable and can meet the design technical indicators of the weak signal filter. In particular, from the phase-frequency characteristic curve in Scheme 2, the curve passes through the origin and is a smooth straight line, indicating that it has good linear phase characteristics, which is also an important reason for choosing FIR digital filters in applications, but its actual effect still needs to be tested in practice. The accuracy of FIR amplitude-frequency characteristics is lower than that of IIR, and the order required by the filter is relatively high, but it has a good linear phase, that is, the time difference of signals with different frequency components remains unchanged after passing through the FIR filter. In addition, the shortcomings of FIR should be improved, such as the large delay of the signal. This takes into account the use of high-performance DSP devices, which can be improved to a certain extent due to their fast processing speed.

4 Conclusion

Since Matl-ah has powerful interface functions, the simulation results can be easily transplanted to DSP, CPLD or FPGA devices. In practical applications, different filters can be realized by simply modifying the filter parameters as required and making minor changes to the program, which is very practical.

Keywords:Matlab Reference address:Application of Matlab in FIR digital filter

Previous article:Analysis of display effects of handheld mobile devices
Next article:Touch screen operation tips

Recommended ReadingLatest update time:2024-11-16 21:45

Communication between Matlab and digital oscilloscope
    Abstract: The communication process between Matlab and TDS series digital oscilloscopes under Windows environment is given. The relevant communication procedures are given, and the waveform data read by the oscilloscope is processed in the frequency domain in Matlab. This shows that the communication between them
[Test Measurement]
How to design a three-level PWM rectifier based on MATLAB?
Part 1 Three-level PWM is a very effective technology that uses the digital output of a microprocessor to control analog circuits. It is widely used in measurement, communication, power control and conversion. A rectifier is a device that converts alternating current into direct current. It can be us
[Embedded]
How to design a three-level PWM rectifier based on MATLAB?
Design of FIR digital filter using CPLD
At present, the requirements for real-time and rapid digital signal processing are becoming increasingly higher, both in military and civilian fields. As programmable logic devices (PLDs) are rapidly increasing in speed and integration, more and more electronic systems use programmable logic devices to implement dig
[Embedded]
Design of FIR digital filter using CPLD
Matlab FAQ
A collection of Matlab installation, operation and other issues Q1: Is there any way to monitor memory in Matlab? A: Use the whos function. Q2: How to solve the problem of a lot of Java errors popping up in the matlab7.0 command window... A: Change to sp2 of matlab 7. Q3: Since installin
[Embedded]
A New Method of Hybrid Processing of GHz High-Frequency Signals Using LabVIEW and MATLAB
With the continuous improvement of technological strength, the frequency of the processed signals is getting higher and higher. For example, the signal of a mobile phone is an ultra-high frequency signal of GHz. In the process of collecting such ultra-high frequency signals, the system is easily interfered by various
[Test Measurement]
A New Method of Hybrid Processing of GHz High-Frequency Signals Using LabVIEW and MATLAB
Implementation of IIR Digital Filters with Matlab and FPGA
Abstract: A design method of a fourth-order IIR digital elliptic filter formed by cascading two second-order sections is proposed, and an IIR digital filter with a passband ripple of no more than 0.1 dB and a stopband attenuation of no less than 42 dB is designed using Matlab simulation software. A method of imple
[Embedded]
Implementation of IIR Digital Filters with Matlab and FPGA
FIR parallel filter design
Digital filters can filter out excess noise, expand the signal frequency band, complete signal pre-adjustment, and change specific spectral components of the signal to obtain the desired results. Digital filters are widely used in digital signal processing such as DVB and wireless communication. In digital signal pr
[Embedded]
FIR parallel filter design
Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号