Professional Documents
Culture Documents
Fyp - Thesis - Group - Members - Bilal - Ahmd - 16 - Ect - 05 - Furqan - Shafiq - 16 - Ect - 59 - Awais - Mehmood - 16 - Ect - 86
Fyp - Thesis - Group - Members - Bilal - Ahmd - 16 - Ect - 05 - Furqan - Shafiq - 16 - Ect - 59 - Awais - Mehmood - 16 - Ect - 86
Supervisor
Engr. M. Usman
Submitted By
August 2020
1
FPGA BASED DIGITAL FILTER DESIGN FOR
BIOMEDICAL SIGNAL PROCESSING
Supervisor
Engr. M. Usman
Submitted By
August 2020
2
CERTIFICATE
This is to certify that Bilal Ahmed, Furqan Shafiq and Awais mehmood have successfully
accomplished their final year project. This project “FPGA based Digital Filter design for
Biomedical Signal Processing” was assigned to them to meet the partial requirements for the
Engr. M. Usman
Project Supervisor
Chairman
3
Declaration
We hereby declare that the contents of thesis, “FPGA base Digital Filter Design for
Biomedical signal Processing” is product of our own research and no part has been copied
from any published source (except the references, standard mathematical and generic formulas
and equations). We further declare that this work has not been submitted in support of another
award or qualification either at this institution or elsewhere. The material used from other
Signature
Bilal Ahmed
16-ECT-05
Signature
Furqan Shafiq
16-ECT-59
Signature
Awais Mehmood
16-ECT-86
4
DEDICATED
TO
Our beloved parents and supervisor
Engr. M. Usman
For their affections, prayers and
support
&
To our beloved siblings for their
endless support, encouragement and
corporation.
5
Acknowledgements
All praises are for Allah almighty; the most beneficent and the merciful. His blessings have
given us the ability to complete our project, without that it is impossible to complete our work.
Secondly, we would offer our heartiest thanks to the last messenger of Allah almighty; the Holy
Prophet Muhammad (PBUH) whose enlightening message always brighten our heart. His
We feel highly privileged to express our heartiest gratitude to our honorable supervisor
Engr. Muhmmad Usman Under whose kind, sympathetic attitude, guidance, motivation
through study and insightful supervision our project and thesis is accomplished. We would like
to thanks our external supervisor Engr. Muhammad Tahir khan for his cooperation and
We would also like to thanks our families and friends for their
6
Abstract
The project describes the implementation, processing and analysis of Biomedical signal. This
project include processing of ECG signal through IIR, FIR, band-pass, low-pass and high pass
filters (digital). Designed model can be use for field programmability. It will provide the
leverage of application based working, one can change its working through programmability
of FPGA kit. The sampling frequency for our project is 8khz considering the components. A
16 bit analog to digital convertor is used in this project to keep the resolution high. The FIR
filtering technique is use for linear phase response. This project provides better speed because
of gate logics and can process a lot of data at single Processing time. We are using MATLAB,
ISE design Software to perform the simulations for desired results. It is efficient and provides
better results in the field of biomedical. It is a low power Digital signal processing kit with
multiple functions, so it very well may be use in numerous different fields like EEG or ECO
signal handling.
7
Table of Contents
Declaration 4
Acknowledgements 6
Abstract 7
Chapter 1 12
Introduction
1.1 BACKGROUND
1.2 Non-invasive ECG technique
.3 Problem Statement
1.4 Objective
1.5 Deliverable
1.6 Thesis Outline
Chapter 2 17
Literature review
2.1 Techniques for digital filtering
2.1.1 FIR filtering
2.1.2 IIR Notch filtering
2.1.3Adaptive filtering
Chapter 3 22
Chapter 4 27
Chapter 5 40
Implementation of project
5.1 Data acquisition
5.2 Signal processing
5.3 Implementation
8
Chapter 6 44
Social Impact and recommendations
6.1 Social Impact
6.2 Recommendation and future work
Chapter 7 47
Conclusion
7.1 Conclusion
Chapter 8 49
References
8.1 References
Chapter 9 52
Appendix
9.1 Appendix
9.1.1 Codes
9.2 Hardware components
9.2.1 Detail of hardware
9.2.2 Gantt Chart
9
List of Figures
10
List of Abbreviations
11
Chapter 1
Introduction
12
Chapter 1
Introduction
1.1 BACKGROUND
The old conventional ECG technique consists of 12 leads, from which 10 of them are placed
on the patient’s limb and chest surface. The general magnitude of heart’s electric potential is
13
then estimated from 12 unique leads use for electrocardiography and then it is recorded for a
specific time to analyze it. Generally, it is recorded for 10sec. In this way the overall behavior
of heart working can be analyzed. It records the bio-potential that is produced by cardiac
activity. We had used modern ECG technique in which 3 electrodes are use to record the cardio
signals. The main reason of ECG is to check for following reasons.
‘‘FPGA-based Digital Filter Design for Biomedical Signals. Equipment that are already
present are much expensive and have efficiency of up to 80%. The devices use for ECG
14
are application specific but this project will provide the leverage of field programmability,
which will makes it able to perform multiple function just by changing the programming of
board’’.
1.4 Objective:
The objective is to achieve efficiency, flexibility in field and high processing speed
for biomedical signal processing. This project aims to eliminate the limitation of field
specified chips.
1.5 Deliverables:
This project is about designing of the Digital filter designing of digital filters for
electrocardiogrpahy on FPGA kit. The main motive behind using the FPGA kit is shifting
the things to flexibility and modernability. The deliverables include the filter designs, their
responses and their simulations. The techniquse use for this purpose are FIR, IIR, Lowpass,
Highpass and bandpass filtering. The circuitry includes Spartan6(FGPA kit) , heartbeat
Chapter 2: This chapter gives an overview of literature review, the work that had previously
Chapter 3: This chapter presents the noises and disturbances in Electrocardiographic signal.
Chapter 4: This chapter presents the selection, designing and responses of filters.
15
Chapter 5: This chapter evaluates the project, discusses its design, and draw the results.
Chapter 6: The social impacts of the project come under discussion in this chapter and
recommendations are proposed to avoid the things that can hurdle in progress and weaknesses
16
Chapter 2
Literature Review
17
Chapter 2
Literature Review
Various methods have been used by researchers and engineers for designing of digital filters
on various boards. But every technique has its own pros and cons.
There are basically two types of filters, one of them is finite impulse response
and other is infinite impulse response filter(recursive and non-recursive filters). Finite impulse
response filter is mostly chosen because of its stability and simplicity. Before choosing between
recursive and non-recursive filter few things must be considered
Computational property.
Storage capacity required for implementation.
Window method is the simplest method in designing of FIR filter. It consist of an array of a[n]
which consist of coefficients satisfying the requirement of proposed filter. In window method
designing of FIR filter it is specified which window will be used. The frequencies that are
below the cut off range of frequency are allowed to pass with unity amplitude, while higher
frequencies are blocked. We can acquire our desired response by taking inverse fourier
transform.
These type of filters are stable and have linear phase. In z-plane the frequency response
and magnitude characteristics of FIR filters is determined by zeros.
18
𝑁−1
𝐻 (𝑧 ) = ∑ ℎ(𝑛)𝑧 −𝑛
𝑛 =0
This type of filter is useful in those applications where we require exact linear phase. Non-
recursive techniques are generally implemented to achieve the stability. For ease in designing
and simplicity FIR filters using different windows are preffered.
Rectangular Window
W(m)= 1, 0≤m≤K-1
=0 otherwise
Hanning window
W(m)= 0.5- 0.5* cos(2πm/K-1), 0 ≤ m ≤ K-1
=0 otherwise
Hamming Window
=0 otherwise
Blackman Window
=0 otherwise
In stop band pulsation and sharp loss(attenuation) was clear. Filter is stable in case of pass band.
In case of hanning, hamming and blackman window, we can not achieve sharp cut off.
19
2.1.2 IIR Notch filtering:
Power line interferences and baseline wander are removed by IIR filters by
different researchers. IIR filters are only used where we require lower order of filter. IIR is also
bit simpler in design. Stationary power line interference are removed by using notch filters. Its
amplitude, frequency and phase do not vary with time. There cause distortion in ECG spectrum
In the absence proper information about power line interference noise.
Q=f / 𝛻f
From the equation it is clear that quality factor will decrease with the increase in bandwidth
and vice versa. Whereas increase in the quality factor causes a decrease in attenuation level.
To remove PLI noise up to a higher amount from our ECG signal the notch filter must have a
higher attenuation level.
As, we know PLI noise can be removed by increase in level of attenuation but this
causes an increase in bandwidth of notch filter. Thus disturbs the nearby spectrum.
After using IIR notch filter, further filtering is required.
Such filters require more memory.
20
upon the other system behavior and its surrounding. Terminology of filter makes it clear that it
will process any input signal and will generate the desired signal at the output.
d(n) is not only the desired signal but it also contains some unnecessary noise.
d(n)=s(n)+n(n)
n(n) is undesired noise and the desired signal can be obtained by subtracting noise
signal from the d(n).
There are two classification of adaptive filters. One of them is digital filter and other one is
adaptive algorithm. Proper filtering coefficients are made by adaptive filters but its coefficients
are also changed by surrounding (input signal, characteristics of output signal etc).
Advantage of adaptive filtering are as follow.
21
Chapter 3
22
Chapter 3
In this chapter we will discuss about the hurdles in acquiring our desired signal. In ECG signal
different type of noises are present and they cause disturbances in our desire signal.
23
In Pakistan we use 50Hz frequency, the devices like Ac, X-ray unit or elevators induces 50Hz
signal in the ECG machine input circuit.
24
This type of noise overlaps with PQRST complex. ECG repeats itself, so different methods can
be use to reduce noise. Success of noise reduction through averaging is limited to one QRS
signal at a time. Hence there is still need of another technique for ECG signal processing.
Baseline wander increases with the body movement during exercise or stress test. Since an FIR
high pass filter with cut off frequency of 0.5Hz can remove this noise.
25
3.1.5 Electrode contact noise:
This type of noise is occurred because of the loos of contact between skin and
the electrodes. The duration of noise is 0.1sec. Measurement system from the subject is
effectively disconnected as electrodes loses its contact with the skin.
They have mostly high amplitude. So, mostly they cause confusion of QRS complex because
of similarity between both of them. As this impedance changes, the ECG intensifier sees an
alternate source impedance which structures a voltage divider with the enhancer input
impedance in this manner the intensifier input voltage relies on the source impedance which
changes as the electrode position changes.
26
Chapter 4
27
Chapter 4
We had observed numerous types of noises in our signals in the last chapter. To acquire the
desired and correct ECG signal we must remove these types of noises from our signal. The
selection of filters and their designing must be based on few factors like constant phase, order
of filter and availability of resources. By considering all the situations we have to design
required filter. We have used FIR and IIR filters to denoise our noisy ECG signal. MATLAB
and Xilinx are used to design filters.
Another problem that arises in selecting these filters is their phase response in passband.
We need linear phase in passband. If a filter has a non linear phase response, it will distort the
signal very badly. FIR filters can give us linear phase but the order of these filters is huge. And
IIR filters can give us sharp cutoff with very low order but they have non linear phase response
and have stability issues.
So, there is a trade off between linear phase, sharp cutoff and order.
As discussed in the previous chapter, ECG signal contains different types of noises, which can
be removed by different techniques. We have used FIR low pass filter and used equiripple
technique because of maintaining a constant level of passband gain. This filter will remove
28
high frequency noise from the signal. And a property of FIR filters is that they have a linear
phase response in passband which is desired in this case.
Secondly, for removing power line interference noise we need a sharp cutoff to supress 50 Hz
frequency component. We can use IIR notch filter because they have a sharp cutoff with very
low order compared with the FIR filter which can give us our desired frequency response but
the order becomes so large that using an FIR filter in this case is not feasible.
For removing baseline wander noise, we will use IIR high pass filter that has a cutoff at 0.5 Hz
and passband from 1Hz and above. Again we have used IIR filter in this case because we need
a sharp cutoff and low order filter. If we use FIR filter, again the same problem arises that these
filters have a very large order for a sharp cutoff which increases the computational complexity.
29
4.2.1.1 Filter specifications:
The dominant frequency in ECG signal are up to 150Hz. So, We have to set our cut
off at 150Hz.
We had designed it through FIR filtering technique because it covers the whole
required frequency band and secondly the requirement of linear phase is accomplished
because of it. Order in FIR is higher than IIR but due to linear phase requirement we
have to make a tradeoff in between order and phase.
If we design it through IIR filtering technique then we are unable to achieve the linear
phase. The order achieved with IIR is lower but the important condition of linear phase
is not accomplished. So, we prefer to use FIR filtering techniques.
30
This technique causes the ripples to a constant attenuation in stop band.
FIR filtering using equiripple technique have finite transient and stable.
If we compare both the magnitude and phase response then we can see that we have
achieved our linear phase requirement.
31
It gives the constant phase delay in frequency just like delay in time.
Group delay is the delay of filter from input to output. It is a function of frequency.
The delay from input to output is also required to be constant and the response of our
filter as under.
32
Fig 16. Pole zero map of FIR low pass filter
As, we have to design a high pass filter for specific signal. So, the condition to be
followed for digital filter are as under.
The cut off frequency required for this signal is 0.5Hz and pass band is above 1Hz.
The sharp cut off can be observed.
33
We had selected IIR filter here because we needed a sharp cut off with lower order.
FIR can also give us sharp cut off but its order is very much increased and is difficult
to make it realizable.
The response of our designed filter is linear in pass band and nonlinear in stop band.
So, it meets our requirements and can be use for our application.
If we compare magnitude response and phase response then we can see after 5Hz it
becomes linear as required.
34
Impulse response of our designed filter is as under.
Phase delay is non linear in stop band and after 5Hz it becomes constant. So, We can
achieve our filteration according to our requirement.
In stop band group delay is higher but when it comes inside the pass band group delay
reduces to zero, which is very good.
35
Fig 22. Group delay of IIR high pass filter
Pole zero plot shows that poles are on the unit circle. Which means critically damped
system. This is the drawback of IIR filtering.
As, we have to design a notch filter for specific signal. So, the condition to be followed
for digital filter are as under.
36
4.2.3.1 Filter specifications:
It is 50Hz Notch filter for reducing power line interference. This filter will eliminate
the effect of the 50Hz electric interferences.
In pass band the repose is approximately near to the desired value. We can verify it with
the help of its graph.
It has constant phase in our specified range. So, the response in stop band will not
produce any impact. The desired conditions are almost fulfilled.
37
Fig 26. Magnitude vs phase response of notch filter
The group delay of our filter is zero as it comes to our pass band and the delay in stop
band dose not produces any impact on our filter performance.
38
Fig 28. Group delay of notch filter
39
Chapter 5
Implementation of Project
40
Chapter 5
Implementation of Project
Our project implementation is divided into three major steps. The first part is to acquire the
Electrocardiographic signal. This is the signal which we are taking as input and then we are
going for further processing. It is the second step of our project implementation in which firstly
we will acquire an ECG signal through a controller and then we are further processing it by the
help of ADC and then passing it through our designed filters. The last step is its implementation
on FPGA kit and then connecting kit to the PC or Laptop with the help of VGA cable.
The first step in the project is data acquisition. We had acquired ECG signal
with the help of ad8232 (ECG) sensor and controller. The noisy signal is achieved by the help
of it. We had observed the waveform at different baud rates. Let us analyze few of them.
41
Fig 30. ECG signal at 19200 baud rate
As we can see that the signal is very noisy. As , from the result we can see different type of
noises in the signal that are discussed in the previous chapters. We can see that the baseline
wander has shifted the level of the signal from 0 to an arbitrary value.
By analyzing the signal, we can also see that the high frequency noise is also present in the
signal, like electromyogram noise, muscle artifacts and noise generated by the movement of
the patient.
42
5.2 Signal processing:
As discussed in the previous chapter, these types of noises can be removed using
filters with desired responses.
For base line wander we have used a high pass filter with cutoff of 0.5 Hz and a
passband from 1 Hz and above. Since, baseline wander is a low frequency noise.
For electromyogram noise we have used a low pass filter with cutoff from 150 Hz. This
will remove the high frequency noise components in the signal. Usually high frequency
noise has dominant components from 150 Hz and above.
Power line interference is embedded in our signal at 50 Hz and for removing this we
have used a notch filter.
5.3 Implementation:
The final stage of our project is implementation of digitally designed filter. To remove
the errors from our incoming ECG signal these filter perform efficient working. The data is
taken from ECG sensor and then taken to ADC, further the digital data is to process on FPGA
kit and at the output there is a VGA cable that connects the kit with the laptop. But due to
pandemic situation and unavailability of kit, components and labs we were unable to observe
the results after implementation on FPGA. We were only able to perform software simulations.
43
Chapter 6
44
Chapter 6
The chapter includes the social impact that the “FPGA based digital filter design for biomedical
signal processing” project will have great importance in the whole world and this technology
is overcoming many fields. So, it will have great worth in future.
This project is developed with the aim in mind that it will be economical for hospitals
to buy. ECG machines are very costly and can cost up-to 200,000 Rs per unit. Heart diseases
are the leading cause of deaths in the world. With 17.9 million deaths per year that are caused
by heart related diseases. This makes the diagnostic of these diseases very crucial. But most
people are unaware that they may have a heart related issue due to unavailability of ECG
machines because of their cost. We are aiming to reduce the price of these machines by half of
its current value. This will save countless lives by diagnosing the disease in the early stages
and taking necessary steps to reduce the risk.
Secondly, we are designing our system on FPGA. They are relatively cheap and can be
programmed for different situations. ECGs of people vary from place to place and at different
places different form of noises may be added to the signal. From this perspective we have the
advantage of field programmability of FPGA. We can design our desired filter that can cancel
the noise depending on the place we are at. Conventional ECG machines are built for certain
places. They don’t have this advantage that FPGA based ECG machines have. We have used
digital filters. They have advantages over analog filters, in a sense that we can achieve sharp
cutoff. They have really small drift factor, meaning that the circuitry will change very slightly
as time passes. By contrast, analog filter components like resistors, capacitors, inductors values
change as time passes due to heating and other environmental effects.
In short, we have combined low cost, FPGA and digital filters to attain maximum efficiency.
45
6.2 Recommendation and future work:
The project will manage to instantiate the rules of filtering so far but there exist some
limiting factors that hinders the system designed to be perfect as there is always room for
improvement. The FGPA will not be able to give 100% perfect results where IIR filters are
used. IIR filters distorts a bit whereas in FIR delays are increased. So, here we use IIR filter
because of their lower order and are bearing a bit of distortion. IIR have natural instability
because all of its poles lie on unit circle. This is the biggest limitation while designing the filter
for noises. A small effect like heating or any of the other surrounding factor will make it
unstable.
In future better equipment must be use to obtain better results and high performance. High bit
ADC should be use for better resolutions. It is recommended to use a built in ADC of FPGA
kit in which they are available. Use any of the technique in future which makes order of FIR
filter low. At this stage no such technique exist.
46
Chapter 7
Conclusion
47
Chapter 7
Conclusion
7.1 Conclusion:
This thesis demonstrates our work relating FPGA based biomedical signal processing and
digital filters. FIR and IIR filtering techniques are use to remove the noise from the signal. The
project was not just the test of academic accomplishments and abilities. It was more than that
as it tested qualities exhibited of teamwork, leading capabilities, management of finances and
time. It taught and tested the project management capabilities and tactics required. Rather than
the achievements we gathered, there were fewer drawbacks that took place because of certain
reasons.
Firstly, it was certainly due to the fact that we did not have over hands on the high-tech
equipment and due to insufficiency of specific knowledge and skills needed, and
monetary limitations.
Secondly, it was due to corona pandemic that we are unable to perform last step of our
project implementation. There was unavailability of FPGA kit and vertex7 at home.
Also, the groupmates were not able to gather and work with the pace and passion
because of lock down.
48
Chapter 8
Reference
49
Chapter 8
References
8.1 Reference:
[1] Snehal Thalkar, Prof. Dhananjay Upasani “ Various Techniques for Removal of Power Line
Interference From ECG Signal” International Journal of Scientific & Engineering Research,
Volume 4, Issue 12, December-2013 12 ISSN 2229-5518.
[2] P. Raphisak, S.C. Schuckers, A.J. Curry, An algorithm for EMG noise detection in large
ECG data, Comput. Cardiol, 31 (2004) 369– 372.
[3] Gary M,Friesen Thomas C. Jannett, Manal Afify Jadallah,Standford L. Yates, Stephen
R.Quint, H.Troy N Nagle,1990,“A Comparision of the Noise Sensitivity of Nine QRS
Detection Algorithms”, IEEE Transactions on Biomedical Engineering,Vol,37, No. 1, March
1990.
[4] Chinmay Chandrakar, M.K. Kowar, “DENOISING ECG SIGNALS USING ADAPTIVE
FILTER ALGORITHM”, International Journal of Soft Computing and Engineering (IJSCE)
ISSN: 2231-2307, Volume-2,Issue-1, March 2012
[5] Omid Sayadi , Mohammad Bagher Shamsollahi, “ECG Denoising with Adaptive Bionic
Wavelet Transform” , in Proceedings of the 28th IEEE EMBS Annual International Conference
New York City, USA, Aug 30- Sept 3, 2006
[6] S. Iravanian, L. Tung, A novel algorithm for cardiac biosignal filtering based on filtered
residue method, IEEE Trans. Biomed. Eng. 49 (11) (2002) 1310–1317.
50
[7] B. Weng, M. B. Velasco, and K. E. Barner, “ECG denoising based on the empirical mode
decomposition,” in Proceedings of the 28th IEEE EMBS Annual International Conference New
York City, USA, Sept.2006, pp. 1–4.
[8] Sonali, Omkar Singh, Ramesh Kumar Sunkaria- ECG Signal Denoising Based on Empirical
Mode Decomposition and Moving Average Filter, 2013 IEEE
[9]Availablefrom:https://www.researchgate.net/publication/224326734_Estimation_of_noise
_in_ECG_signals_using_wavelets/figures?lo=1
[10]. A. Jayant, T. Singh and M. Kaur (2013): Different Techniques to Remove Baseline
Wander from ECG Signal, Int. J. of Emerging Research in Management & Technology,
[11] Leif Sornmo and Pablo Laguna. (2005) Bioelectric Signal Processing in Cardiac and
Neurological Processing. 1st Ed., Elsevier Academic Press, ISBN: 9780124375529.
[12] Rangraj M. Rangayyan. (2002) Biomedical Signal Analysis: A case study approach. John
Wiley & Sons, Inc., ISBN: 0-471- 20811-6. 6. J. L. Talmon, J. A. Kors, and J. H. van Bemmel
(1986): Adaptive Gaussian filtering in routine ECG/VCG analysis, IEEE Trans. Acoust.
Speech Sig. Proc. 34: 527-534.
51
Chapter 8
Appendix
52
Chapter 9
Appendix
9.1 Appendix:
9.1.1 Codes:
filter_tb.v filter.v
high_pass_tb.v high_pass.v
Notch filter:
notch.v notch_tb.v
The major hardware components used in our project are given below.
53
ads1194 (ADC)
VGA cable
Arduino
54
ADC (ads1194):
Arduino uno:
55
9.2.2 Gantt chart:
Table 10.2: Gantt Chart
Activity Sep 2019 Oct 2019 Nov- Dec Jan-Feb March- July– Aug 2020
2019 2020 April 2020
Collection of Literature 2
Weeks
Study of Literature 2
Weeks
Designing 6 Weeks
Result Formulation 3
Weeks
56