Development of a Digital Universal Filter Bank
Total Page:16
File Type:pdf, Size:1020Kb
UPTEC E16 005 Examensarbete 30 hp Oktober 2016 Development of a Digital Universal Filter Bank Mats Larsson Abstract Development of a Digital Universal Filter Bank Mats Larsson Teknisk- naturvetenskaplig fakultet UTH-enheten This is a master's thesis project, which is a part of the Master Programme in Electrical Engineering at Uppsala university. Besöksadress: Ångströmlaboratoriet Lägerhyddsvägen 1 When developing a product or performing measurements, it is Hus 4, Plan 0 sometimes necessary to remove some content of a signal. This might be due to an interfering source that has to be filtered out, or Postadress: that only a specific frequency interval is of interest. In such a Box 536 751 21 Uppsala case, it would be practical if a universal frequency selective filter was available and easy to use. Telefon: 018 – 471 30 03 In this thesis, a platform for implementing different frequency Telefax: selective digital filters is developed. Through a user interface, 018 – 471 30 00 parameters such as sampling frequency, filter order, type of filter and cutoff frequencies are set by the user. This provides a Hemsida: platform which is easy to configure in order to run one or http://www.teknat.uu.se/student multiple IIR or FIR filters in various constellations. By combining different filters, a wide variety of frequency responses can be obtained. A prototype is constructed, which allows the user to connect up to two input signals and retrieve up to two output signals. The filter bank is programmed in C and implemented in a 32-bit microcontroller, base on the ARM architecture. To get a reliable prototype, a printed circuit board is designed and manufactured. To protect the electronics from external stress, a cover is designed and 3D-printed. The filter design algorithms and the algorithm used when running the filter bank gives satisfying results. The capacity of the filter bank can be increased by refining the filtering algorithm. By improving the hardware, noise generated by the electronics can be decreased. The filter bank has a really good potential to become a very useful tool. Handledare: Ping Wu Ämnesgranskare: Tomas Olofsson Examinator: Mikael Bergkvist ISSN: 1654-7616, UPTEC E16 005 Sammanfattning Denna rapport ¨arett resultat fr˚anett examensarbete inom civilingenj¨orsprogrammet i elektroteknik vid Uppsala Universitet. Vid t.ex. utveckling av produkter eller inom m¨atteknikskulle det underl¨attaom det fanns m¨ojlighetatt p˚aett enkelt s¨attfiltrera bort delar av inneh˚alleti en signal. Detta d˚at.ex. en st¨orningfortplantat sig i ett m¨atsystem. De befintliga systemen som finns tillg¨angligap˚amarknaden kr¨aver oftast programmering i specifik mjukvara, via t.ex. en PC, och tar d¨arf¨ortid att implementera. Mjukvaran f¨ordessa system medf¨ordessutom oftast kostnader, d˚alicenser kr¨avs. I detta examensarbete utvecklas en plattform som erbjuder ett snabbt och enkelt s¨attatt implementera och kombinera olika digitala frekvensselektiva filter. Den universala digitala filterbanken kan hantera upp till tv˚ain- och utsignaler. Genom ett anv¨andargr¨anssnitt best˚aendeav en display och en knappsats, kan ett eller flera filter konfigueras f¨oratt sedan kopplas samman i filterbanken. P˚adetta s¨attkan anv¨andarenforma frekvenssvaret efter det behov som finns. Filterbanken ¨arprogrammerad i C och implementerad i en 32-bitars mikrokontroller. Den slutliga prototypen fungerar som ¨onskat och l˚ateranv¨andarenp˚aett mycket enkelt s¨attimplementera ett stort antal olika typer av frekvensselektiva filter. Anv¨andaren best¨ammer sj¨alvparrametrar s˚asomfiltrets ordningstal och brytfrekvenser. Olika filter kan dessutom kombineras genom att kopplas i serie eller parralellt, efter det behov som finns. Genom vidareutveckling av h˚ardvaran har filterbanken stor potential f¨oratt bli ett mycket anv¨andbartverktyg. Jag skulle vilja rikta ett tack till Ping Wu p˚aavdelningen f¨orsignaler och system vid Uppsala universitet som varit min handledare genom projektet samt Etteplan i V¨aster˚as som bist˚attmed tid f¨orkonsultation g¨allandeprogrammering. Jag skulle ocks˚avilja tacka Robin Hindgren f¨ordiskussioner och f¨orslag till f¨orb¨attringarav kretskortkonstruktionen samt Fredrik Evestedt p˚aavdelningen f¨orelectricitetsl¨aravid Uppsala universitet f¨or hj¨alpen med att skriva ut h¨oljettill prototypen. II Contents 1 Introduction 1 1.1 Background . .1 1.2 Aim of the project . .1 1.3 Project description . .1 1.4 Outline of the report . .4 2 Theory 5 2.1 Linear phase delay . .5 2.2 Sallen-Key topology . .6 2.3 Differential amplifier . .7 2.4 Analog to digital conversion . .8 2.5 Anti-aliasing filter . .9 2.6 Digital filter . 10 2.6.1 Finite impulse response filter . 11 2.6.2 Infinite impulse response filters . 19 2.7 Digital to analog conversion . 26 2.8 Reconstruction filter . 26 3 Hardware implementation 27 3.1 Design of analog signal chain . 27 3.1.1 DC-blocker . 27 3.1.2 DC-adaption . 28 3.1.3 Anti-aliasing and reconstruction filter . 28 3.1.4 Buffer . 28 3.1.5 Current limiter . 29 3.2 Microcontroller . 29 3.3 User interface . 30 3.4 Printed circuit board . 31 3.5 3D-printed cover . 32 4 Software implementation 34 4.1 Filter design algorithms . 35 4.2 Filter structure . 35 4.3 Output structure . 36 4.4 Filter bank algorithm . 37 4.5 User interface menu system . 38 5 Results 43 5.1 Hardware . 43 5.1.1 DC-blocker . 43 5.1.2 Anti-aliasing filter and reconstruction filters . 44 5.1.3 Prototype . 48 5.2 Software . 50 5.2.1 Filter validation . 50 III 5.2.2 User interface . 59 6 Discussion 64 7 Further development 66 Appendix A IIR filter coefficients 68 Appendix B Derivation of Sallen-Key topology 73 Appendix C Derivation of differential amplifier circuit 75 IV Glossary AAF Anti-Aliasing Filter. ADC Analog to Digital Converter. ARM Advanced RISC Machine. BP Band Pass. BS Band Stop. CPU Central Processing Unit. CT Continuous Time. DAC Digital to Analog Converter. DMA Direct Memory Access. DSP Digital Signal Processing. DT Discrete Time. FFT Fast Fourier Transform. FIR Finite Impulse Response. GPIO General-Purpose Input/Output. HP High Pass. IIR Infinite Impulse Response. KCL Kirchhoff's Current Law. LCD Liquid-Crystal Display. LP Low Pass. LTI Linear Time Invariant. MCU Microcontroller Unit. MIMO Multiple Input Multiple Output. MISO Multiple Input Single Output. PCB Printed Circuit Board. V RECF Reconstruction Filter. SIMO Single Input Multiple Output. SISO Single Input Single Output. VI 1 Introduction 1.1 Background Frequency selective filtering is a very important topic within the field of signal processing. By designing a filter it is possible to remove unwanted frequency components such as band-limited noise or an interfering signal. Digital filtering is a widely used method for filtering almost any signal, such as sensor signals and audio signals. In comparison to an analog filter, a digital filter is implemented in software, and therefore often no extra components need to be added. Also analog components characteristics tend to drift due to change of the ambient temperature, which is not the case for digital filters. Currently, there is no universal digital filter on the market, which allows the user to easily implement almost any filter without a sophisticated user interface, which is based on an additional system, such as a PC. 1.2 Aim of the project When developing a product, performing measurements on a system or any other situation requiring setting up a test rig, it would sometimes simplify the procedure if a specific filter was available and easy to implement. The aim of this project is to design such a universal filter bank where various filters can be designed and implemented to a system where one or multiple analog signals are available and have to be filtered. In this way, it is no longer necessary to bother about tedious and time-consuming calculations, it will also be easier to tune the filter for the specific application. 1.3 Project description In this thesis, a digital universal filter bank is designed and implemented in a Micro- controller Unit (MCU) based on the Advanced RISC Machine (ARM) architecture. The design allows the user to connect up to two input signals and achieve up to two output signals, where the maximum amplitude of the input signal is limited to 3.3 V peak-to- peak. Through a user interface, the user selects an appropriate filter for the given application and enter all the design parameters for the filter to be designed. When all design pa- rameters are selected, the filter bank automatically generates the filter. The filter bank is capable of running multiple filters simultaneously. In this way it is possible to connect different filters in series or in parallel to achieve the frequency response required for the given application. Since the MCU has a multiple channel Analog to Digital Converter (ADC) and Digital to Analog Converter (DAC), it is possible to configure the filter bank into a Single Input Single Output (SISO), Single Input Multiple Output (SIMO), Multiple Input Single Output (MISO) or a Multiple Input Multiple Output (MIMO) system. 1 The user interface allows the user to perform the following actions: • Select sampling frequency, either one of the three predefined sampling frequencies (16kHz, 48kHz or 96kHz), which are using an Anti-Aliasing Filter (AAF) and a Reconstruction Filter (RECF), or select a custom sampling frequency. • Add a new filter to the system. • Select Finite Impulse Response (FIR) or Infinite Impulse Response (IIR) filter. • Select an analog reference filter such as Butterworth or Chebyshev I if an IIR filter is designed, see section 2.6.2.1. • Select window function if a FIR filter is designed, see section 2.6.1.2. • Select filter order. • Select Low Pass (LP), High Pass (HP), Band Pass (BP) or Band Stop (BS) filter.