# Digital signal processing theory

### Assignment Brief

### Background Research

Part One: Literature Review. Review the lecture notes and other sources of information, detailing different aspects of FIR filter design. Obtain, read and familiarise yourself with various review and journal articles, books, Internet sites and manufacturers information on all aspects of digital based filters.

### Practical Activities

Part Two: FIR Filter Design. Using the appropriate design equations design your own set of FIR filter co-efficient in order to fulfil the given design criteria. You need to demonstrate for the first two iterations, by hand, the calculation of the coefficients. Obviously, this can be a rather repetitive process and if you are not extremely careful you will make mistakes. It is recommended (essential) that you write a small program to calculate the co-efficient for you - i.e. write a MATLAB based program to design your filter. Once the programme is working check that the hand calculated coefficients much the one obtained using the MATLAB program for the first two iterations.

Part Three: Design Verification. Make use of MATLAB's SPTOOL to verify your design. Print graphical plots of the impulse response, any window functions used and the final filter response. Note that although you may use SPTOOL to verify your design, you must write your own small design program to calculate the filter.

Part Four: Filter Simulation. Import your filter design into SPTOOL and using a suitable test signal file, verify that your filter works correctly.

### Presentation of results & Write up

Part Five: During the assignment period you should present your FIR filter design to the subject tutor - i.e. using MATLAB demo your calculation software.

Part Six: You will write a detailed technical report of approx. 2000 words long plus diagrams, charts and programs- the content of which will be as detailed below. You should bring together relevant information obtained through the research periods of the assignment, collate results from your practical activities and present your findings in a clearly written analytical report. The report will demonstrate that you have undertaken an extensive level of research activity and that you have understood the subject matter to an appropriate level.

Project details: Name of the project, Course title, Module title, Filter specification parameters (given individually), Year written, your name.

General review of FIR design method used: An explanation of how you designed the FIR filter, the methods, processes and equations used. If you decided to write a program to help calculate the filter co-efficient discuss the use of this program here include a copy of your co-efficient calculator program along with a co-efficient data table in the appendices at the end of the report.

Comments and Conclusions: General review of the whole process, the success of the project, final conclusions.

Part Seven: Once completed your filter design, you need to approach the tutor to demonstrate your working filter and a mark will be awarded.

Part Eight: If necessary additional session will be arranged to discuss the project, associated theory and the final design.

### Introduction

In general, there are two classes of signals which can be identified, namely, continuous-time and discrete-time signals. A discrete-time signal is the one that is defined at discrete instants of time. The numerical manipulation of signal and data in discrete-time signals is called Digital signal processing (DSP).

The term signal processing refers to the science of analysing time-varying processes. Such as, signal processing is divided into two categories, analogue signal processing and digital signal processing. DSP technology considered as the core of many digital products and applications, such products and applications which requires a processing and analysing of signals like the products that could be found on the medicine and healthcare. For example in patient monitors, digital X-ray appliances, brain mapping system.

It is known in the signal processing environment that, the function of a filter is to remove unwanted parts of the signal, such as a random noise, or sometimes to use some of these parts within the components which lying on certain frequency ranges.

A filter is a system that changes the parameters of signal either, amplitude, frequency or phase in a desired manner. In this piece of work digital filters are of interest to us, so the work will be devoted to the digital filters, (FIR filters in particular).

There is also another way to make digital filters, called recursion. When a filter is implemented by convolution, each sample in the output is calculated by weighting the samples in the input, and adding them together. Recursive filters are an extension of this, using previously calculated values from the output, beside points from the input. Recursive filters are defined by a set of recursion coefficients.

### Digital Filter Types:

There are two main categories of digital filters:

- Finite Impulse Response (FIR).
- Infinite Impulse Response (IIR).

In this assignment, I had given a specification of FIR filter which would be designed using MATLAB software. Although the main advantage of an IIR filter is that it can provide a much better performance than the FIR filter having the same number of coefficients, there are some problems with the design of IIR filters such as there might be a possibility of the filter becoming unstable during the adaptation process.

Table 1 Comparison of FIR and IIR Filters

- The only way to achieve integer or fractional constant delays by using FIR filters.
- Limit cycles are instability of a particular type due to quantization, which is severely non-linear The filter designing chart:

The following chart shows the steps which involved in a digital filter design.

The above chart shows the main five parts for designing a filter. The source of this chart is [Digital signal processing: a practical approach By Emmanuel C. Ifeachor, Barrie W. Jervis].

### Features of FIR filters

FIR, finite impulse response filters are said to be finite because they do not have any feedback. Therefore, if an impulse is sent through the system then the output will invariably become zero as soon as the impulse runs through the filter.

The basic FIR filter is characterised by the following two equations:

FIR Filter Design & implementation

In designing FIR filters, the following steps should be followed:

a) Filter specification: this includes the type of the filter, attenuation desired.

In practice it is more convenient to express dp and ds in decibels and their expressions: pass-band deviation=20log (1+dp) stop-band deviation= - 20log (ds) Transition width = fs - fp and N: filter length.

### Low-Pass Filter Design Parameters

b) Coefficient calculation: coefficients of H(z) can be determined which will satisfy the specification given. This will be influenced mainly by the factors mentioned in the first step.

There are several methods of calculating filter coefficients of which the following are most widely used for the FIR digital filter:

- Window
- Frequency sampling
- Optimal

c) Implementation: this involves producing the MATLAB software code and performing the actual filtering using SP tool.

### Design Specifications

NOTE: The value which was given to me from the main list of the specification was 60, but in the lab session with the help of the tutor Tom, "he asked me to change the value of the given one to be 59".

### Window method:

In the design of FIR filter window functions used to reduce the infinite length of the impulse response. By applying a rectangular window on the impulse response, i.e. just deleting a number of the coefficients, there will be oscillations in the frequency response due to Gibbs phenomenon. In order to reduce the oscillations different window functions can be applied such as Hanning, Hamming, Blackman and Kaiser Window.

To design FIR filter by windowing, we need to complete the following steps:

- Decide on an ideal frequency response as shown in the table.
- Calculate the impulse response of the ideal frequency response.
- Truncate the impulse response to produce a finite number of coefficients. To meet the linear-phase constraint, maintain symmetry about the centre point of the coefficients.
- Apply a symmetric smoothing window.

### FIR Filter Design Equations

From the specification given to me, either Blackman or Kaiser Window would full fill the task, both of them could be used to produce tow different filters with the same specifications, tow different calculation, MATLAB simulation would be provided but only one of them is going to be carry using the Blackman window with the SPTOOL.

### Using Blackman window:

Pass-band edge frequency: fp = 3.625 kHz

Sampling frequency fs = 16 kHz

### Calculation of the filter coefficients

### MATLAB Implementation:

As soon as the code runs within the program, and start the work properly without any errors two figures will appear as a separate windows.

### Figure (3) window function, ideal impulse and filter impulse

Clearly figure (2), shows the following components:

- Blackman Window Function
- Ideal Impulse
- Filter Impulse

The figure clearly proves the order of the filter N to be 59. As well as, the symmetrical distribution of the data proves the correct design of the filter and that the response of the filter is as expected to be. The impulse response exhibits even symmetry.

Figure (3) illustrates the response of the filter in terms of magnitude and phase. The cut-off frequency could be easily worked out using the data from the above two graphs, by applying the following equation:

cut-off Frequency= fn fs2

Fn = the normalised frequency

Fs = sampling frequency

cut-off Frequency= 0.45 16k2 = 3600Hz

The result is close enough, and this proves that the design of the filter is successfully designed.

Filter design and analysing tool was used as an alternative way of to design the proposed filter. MATLAB graphical capacity can help in the design and analyse of digital filters. The phase and the magnitude were produced in figure 5. The figure depicts the value of Fcut which is (3. and something kHz). As expected, the filter produces a linear phase shift that is proportional to the frequency. This means that the frequency components in the signal will each be delayed by an amount proportional to frequency.

### Simulation Results:

For simulation results verification, SP-tool has been used.

With SPTool, importing signals, filters and spectra can be easily achieve. By using the SPTool, the user can access other GUI (Graphical User Interface) tools to provide a complete integrated environment for browsing signals and analysing filters, as well as the design and the implementation of filters.

- Analyze signals
- Design filters
- Analyze (view) filters
- Filter signals
- Analyze signal spectra" [2]
- Signal browser, graphical views can be obtained from this specific tool, which provides the option of measuring, analysing and printing of these signals, the target signal needs to be selected first.
- Filter designer and viewer, this tool allows the editing and creation of the different types of FIR or IIR digital filters for various lengths. The viewer provides the option of viewing different filter responses and characteristics such as, impulse response, step response, phase and magnitude response also group delays, poles and zeros.
- The spectrum viewer, allows the user to create view modify and print spectra interactively. As well as, performing graphical analysis of the frequency domain, by employing different methods of spectral estimation.
- Analyze and compare spectral density plots.
- Use different spectral estimation method to create spectra."[3]
- Emmanuel C. Ifeachor and Barrie W. Jervis (2002), Digital Signal Processing, a practical approach, 2nd edition, Person Education Limited.
- Schaum's Outline of Theory and Problems of DIGITAL SIGNAL PROCESSING by Monson H. Hayes.
- Understanding Digital Signal Processing by Richard G. Lyons, (2001).
- Haddad, Richard A, (1991), Digital Signal Processing: theory, applications, and hardware. 3rd edition. Computer Science Press.

### Figure 6 MATLAB SPTool Screen Shot

The figure above shows the SPTool components, which can be introduced individually as follows:

The spectral viewer provides the following functionality:

### Conclusion:

By finishing this piece of work, a working LOW pass filter was produced under a set of design specifications. The window method was used to produce the filet design, and Blackman window in particular was used.

The computational aspect of the design was straight forward compared to other techniques of coefficients calculations, and this is one of the attractive features about using the window method. Regarding the analysis of the system results using the MATLAB toolboxes, analyzing and understanding the concepts of designing a digital filter and applying random noise to it and experiencing the effect of applying the filters, all was made easy by using the SPTool and MATLAB plot functions. Investigation of parameters like, amplitude and phase responses, spectral power analysis, impulse and stop responses was approachable.

Generally FIR filters proved to have linear response and that is by satisfying both of the conditions stated earlier in the report, and by using the FIR filters designs can be easily achieve and would satisfy most of the design requirements, unless data memory and speed of cycles becomes a critical design issue that FIR filters cannot satisfy.

Last but not least, doing this assignment has given me the opportunity to get more familiar with digital filters and get used to MATLAB environment. As I had the chance to use the SP tool which is a new thing for me.

### Bibliography:

Lecture notes

### Websites:

1. http://www.mathworks.com/access/helpdesk/help/toolbox/signal/f0-134222.html Mathworks support site. Last date accessed: 18/02/2010

2. http://ocw.mit.edu/NR/rdonlyres/89A0504C-6C10-463B-8207-A27E41D512BF/0/lec08.pdf MIT publication lectures. Last date accessed: 07/02/2010.

3. http://www.netrino.com/Embedded-Systems/How-To/Digital-Filters-FIR-IIR Introduction to FIR digital filters. Last date accessed: 10/02/2010.

4. http://www.dspguru.com/dsp/faqs/fir/design FIR filters Design. Last date accessed: 20/02/2010.

5. http://www.youtube.com/

### UNSW e-learning's Channel. ELEC3104 Digital Signal Processing by Prof. E. Ambikairajah. Last date accessed: 15/02/2010.

Books:

### Log book:

[1] Source [www.dspguide.com/ ch14/1.htm]

[2] Source [http://cnx.org/content/m18078/latest/]

[3] Source [ http://www.mathworks.com ]