You are on page 1of 22

Practical Digital Signal Processing using

Microcontrollers

Prof Dr Dogan Ibrahim


Near East University
ACKNOWLEDGEMENTS

The following material is reproduced in this book with the kind permission of the
respective copyright holders and may not be reprinted, or reproduced in any way, without
their prior consent.

Figures A.1 A.11 are taken from Microchip Technology Inc. Data Sheet
PIC18(L)F2X/4XK22 (DS41412F). Figures 3.1 3.3, 3.9, 12.4 are taken from the web site
of Microchip Technology Inc.

or
Figure 3.4 is taken from the web site of Custom Computer Services Inc.
kt
Figures 3.6 3.8, 12.2, 12.4 are taken from the web site of mikroElektronica.
e
El

Figure 3.5 is taken from the web site of Olimex.


ht

Figures 3.10 - 3.12, 14.1 14.3 are taken from the web site of Analog Devices Inc.
rig

Figure 3.13 is taken from the web site of Texas Instruments Inc.
y
op

Figure 3.14 is taken from the web site of Freescale Semiconductors Inc.
C

PIC, PICSTART, and MPLAB are all trademarks of Microchip Technology Inc.
Contents
CHAPTER 1 - INTRODUCTION ........................................................................... 17
1.1 BACKGROUND ....................................................................................................... 17
1.2 A TYPICAL DSP APPLICATION ................................................................................... 18
1.3 THE ANTI-ALIASING ANALOG FILTER ........................................................................... 18
1.4 SAMPLE AND HOLD CIRCUIT ..................................................................................... 21
1.5 A/D CONVERTER ................................................................................................... 21
1.6 DSP ................................................................................................................... 24
1.7 D/A CONVERTER ................................................................................................... 24
1.8 EXERCISES ............................................................................................................ 25
CHAPTER 2 - NUMBER SYSTEMS ...................................................................... 27
2.1 FIXED POINT NUMBERS ........................................................................................... 27
2.1.1 Decimal Number System............................................................................ 28
2.1.2 Binary Number System .............................................................................. 28
2.1.3 Octal Number System ................................................................................ 29
2.1.4 Hexadecimal Number System .................................................................... 29
2.1.5 Converting Binary Numbers into Decimal .................................................. 30
2.1.6 Converting Decimal Numbers into Binary .................................................. 31
2.1.7 Converting Binary Numbers into Hexadecimal ........................................... 33
2.1.8 Converting Hexadecimal Numbers into Binary ........................................... 34
2.1.9 Converting Hexadecimal Numbers into Decimal ........................................ 35
2.1.10 Converting Decimal Numbers into Hexadecimal ........................................ 36
2.1.11 Converting Octal Numbers into Decimal .................................................... 37
2.1.12 Converting Decimal Numbers into Octal .................................................... 38
2.1.13 Converting Octal Numbers into Binary ....................................................... 39
2.1.14 Converting Binary Numbers Into Octal....................................................... 40
2.1.15 Negative Numbers ..................................................................................... 40
2.1.16 Adding Binary Numbers ............................................................................. 42
2.1.17 Subtracting Binary Numbers ...................................................................... 43
2.1.18 Multiplication of Binary Numbers .............................................................. 43
2.1.19 Division of Binary Numbers ........................................................................ 45
2.1.20 Signed Magnitude Representation............................................................. 45
2.1.21 Offset Binary Representation ..................................................................... 46

5
2.1.22 Fractional Fixed Point Numbers ................................................................. 47
2.1.23 Converting Fractional Number into Integer................................................ 48
2.1.24 Converting from Integer into Fractional Number ....................................... 48
2.2 FLOATING POINT NUMBERS ..................................................................................... 49
2.2.1 Converting a Floating Point Number into Decimal ..................................... 50
2.2.2 Normalizing the Floating Point Numbers ................................................... 51
2.2.3 Converting a Decimal Number into Floating Point ..................................... 52
2.2.4 Multiplication and Division of Floating Point Numbers............................... 53
2.2.5 Addition and Subtraction of Floating Point Numbers ................................. 55
2.3 FIXED POINT OR FLOATING POINT NUMBERS IN DSP OPERATIONS .................................... 56
2.4 BCD NUMBERS ..................................................................................................... 57
2.5 THE ASCII TABLE................................................................................................... 58
2.6 SUMMARY ........................................................................................................... 59
2.7 EXERCISES ............................................................................................................ 60
CHAPTER 3 - DIGITAL SIGNAL PROCESSORS ............................................... 65
3.1 CHOOSING A DDSP PROCESSOR ............................................................................... 66
3.2 DSP HARDWARE DEVELOPMENT TOOLS ..................................................................... 68
3.2.1 General Purpose Microcontroller Development Tools ................................ 68
3.2.2 DSP-Enhanced Processor Development Tools ............................................. 75
3.2.3 Dedicated DSP Processor Development Tools ............................................ 80
3.3 DSP SOFTWARE DEVELOPMENT TOOLS ...................................................................... 83
3.3.1 General Purpose Microcontroller Software Development Tools ................. 83
3.3.2 DSP-Enhanced Processor Software Development Tools .............................. 84
3.3.3 Dedicated DSP Processor Software Development Tools.............................. 85
3.4 EXERCISES ............................................................................................................ 86
CHAPTER 4 - MIKROC PRO PROGRAMMING LANGUAGE FOR
MICROCONTROLLERS .................................................................. 87
4.1 C LANGUAGES FOR MICROCONTROLLERS ..................................................................... 87
4.2 YOUR FIRST MIKROC PRO FOR PIC PROGRAM .............................................................. 89
4.2.1 Comments ................................................................................................. 90
4.2.2 Beginning and Ending a Program .............................................................. 90
4.2.3 White Spaces ............................................................................................. 91
4.2.4 Variable Names ......................................................................................... 92
4.2.5 Reserved Names ........................................................................................ 92
4.2.6 Variable Types ........................................................................................... 93

6
4.2.7 Constants .................................................................................................. 95
4.2.8 Escape Sequences ...................................................................................... 96
4.2.9 Accessing Bits of a Variable ....................................................................... 96
4.2.10 sbit Type .................................................................................................... 97
4.2.11 bit Type ..................................................................................................... 97
4.2.12 Arrays ........................................................................................................ 97
4.2.13 Pointers ................................................................................................... 100
4.2.14 Structures ................................................................................................ 102
4.2.15 Operators in mikroC Pro for PIC ............................................................... 105
4.2.16 The Flow of Control ................................................................................. 109
4.3 FUNCTIONS IN MIKROC PRO FOR PIC ....................................................................... 118
4.3.1 void Functions ......................................................................................... 119
4.3.2 Passing Parameters to Functions ............................................................. 119
4.3.3 Passing Arrays to Functions ..................................................................... 120
4.3.4 Interrupt Processing ................................................................................ 121
4.4 MIKROC PRO FOR PIC BUILT-IN FUNCTIONS............................................................... 122
4.5 MIKROC PRO FOR PIC LIBRARIES ............................................................................. 123
4.6 USING THE MIKROC PRO FOR PIC COMPILER.............................................................. 124
4.6.1 mikroC Pro for PIC IDE ............................................................................. 125
4.6.2 Creating a New Source File ...................................................................... 127
4.6.3 Compiling the Source File......................................................................... 130
4.7 SUMMARY ......................................................................................................... 131
4.8 EXERCISES .......................................................................................................... 132
CHAPTER 5 - INTRODUCTION TO MATLAB ................................................. 135
5.1 GETTING STARTED ............................................................................................... 135
5.1.1 disp Command ........................................................................................ 137
5.1.2 format Command .................................................................................... 138
5.1.3 input Command....................................................................................... 139
5.1.4 Comment lines......................................................................................... 139
5.1.5 Programming in MATLAB ........................................................................ 139
5.1.6 The Working Environment ....................................................................... 149
5.1.7 Vectors in MATLAB .................................................................................. 149
5.1.8 Matrices in MATLAB ................................................................................ 154
5.1.9 Graphics Plotting Using MATLAB ............................................................. 157
5.2 SUMMARY ......................................................................................................... 170
5.3 EXERCISES .......................................................................................................... 170

7
CHAPTER 6 - DISCRETE TIME SIGNALS ....................................................... 173
6.1 THE SAMPLING PROCESS ....................................................................................... 173
6.2 SOME DIGITAL SIGNAL TYPES.................................................................................. 174
6.2.1 Unit Step Function ................................................................................... 174
6.2.2 Unit Impulse Function.............................................................................. 175
6.2.3 Sinusoidal Signal...................................................................................... 175
6.2.4 Exponential Signal ................................................................................... 177
6.2.5 Complex Exponential Signal ..................................................................... 177
6.2.6 Exponential Sinusoidal Decay Signal ........................................................ 178
6.3 OPERATIONS ON DISCRETE TIME SIGNALS.................................................................. 179
6.3.1 Delay or Shift ........................................................................................... 179
6.3.2 Vector Addition and Subtraction .............................................................. 181
6.3.3 Scalar Addition and Subtraction .............................................................. 182
6.3.4 Scalar Multiplication and Division ............................................................ 182
6.3.5 Vector Multiplication and Division ........................................................... 183
6.4 BLOCK DIAGRAM REPRESENTATION.......................................................................... 184
6.4.1 Block Diagram Manipulation ................................................................... 184
6.5 DISCRETE SYSTEM CLASSIFICATION ........................................................................... 186
6.5.1 Linear and Non-linear .............................................................................. 186
6.5.2 Time-variant and Time-invariant ............................................................. 186
6.5.3 Causal and Non-causal ............................................................................ 186
6.5.4 Stable and Unstable ................................................................................ 187
6.5.5 Linear Time-invariant Systems ................................................................. 187
6.6 THE CONVOLUTION PROCESS.................................................................................. 187
6.7 EXERCISES .......................................................................................................... 192
CHAPTER 7 - THE Z-TRANSFORM .................................................................. 195
7.1 UNIT STEP FUNCTION ........................................................................................... 195
7.2 UNIT RAMP FUNCTION.......................................................................................... 196
7.3 EXPONENTIAL FUNCTION ....................................................................................... 197
7.4 SINE FUNCTION ................................................................................................... 198
7.5 DISCRETE IMPULSE FUNCTION................................................................................. 199
7.6 TABLES OF Z-TRANSFORMS .................................................................................... 199
7.7 THE Z-TRANSFORM OF A FUNCTION EXPRESSED AS A LAPLACE TRANSFORM ....................... 200
7.8 PROPERTIES OF THE Z-TRANSFORM .......................................................................... 201
7.9 INVERSE Z-TRANSFORMS ....................................................................................... 204
7.9.1 Coefficients of Partial Fraction Expansion ................................................ 211

8
7.10 EXERCISES .......................................................................................................... 214
CHAPTER 8 - THE DISCRETE FOURIER TRANSFORM ............................... 217
8.1 THE SPECTRA OF PERIODIC SIGNALS ......................................................................... 217
8.2 PROPERTIES OF THE DFT ....................................................................................... 231
8.3 FOURIER TRANSFORM OF APERIODIC DIGITAL SIGNALS ................................................. 232
8.4 EXERCISES .......................................................................................................... 235
CHAPTER 9 - DIGITAL FILTERS ...................................................................... 237
9.1 FIR FILTERS AND IIR FILTERS .................................................................................. 238
9.2 THE DIGITAL FILTER DESIGN PROCESS ....................................................................... 239
CHAPTER 10 - DESIGN OF FIR DIGITAL FILTERS ........................................ 245
10.1 THE FOURIER TRANSFORM METHOD ........................................................................ 245
10.2 TRUNCATION AND WINDOWING.............................................................................. 249
10.3 SOME COMMONLY USED WINDOWING FUNCTIONS..................................................... 250
10.3.1 Rectangular Window ............................................................................... 250
10.3.2 Hamming Window................................................................................... 252
10.3.3 Hanning Window..................................................................................... 256
10.3.4 Blackman Window................................................................................... 256
10.3.5 Remez Exchange Based Design ................................................................ 260
10.4 USING COMPUTER AIDED TECHNIQUES FOR THE DESIGN OF FIR FILTERS .......................... 260
10.4.1 The ScopeFIR Software ............................................................................ 260
10.5 FIR DIGITAL FILTER STRUCTURES ............................................................................. 268
10.5.1 Direct FIR Structures ................................................................................ 268
10.5.2 Cascade FIR Structures ............................................................................ 269
10.6 EXERCISES .......................................................................................................... 269
CHAPTER 11 - DESIGN OF IIR DIGITAL FILTERS ......................................... 271
11.1 IIR FILTER TRANSFER FUNCTION .............................................................................. 271
11.2 ANALOG FILTER DESIGN REVIEW ............................................................................. 272
11.3 BUTTERWORTH FILTERS......................................................................................... 273
11.3.1 Bilinear transformation method .............................................................. 275
11.4 CHEBYSHEV FILTERS.............................................................................................. 282
11.5 ELLIPTIC FILTERS .................................................................................................. 286
11.6 THE SCOPEIIR FILTER DESIGN PROGRAM................................................................... 288
11.7 IIR FILTER STRUCTURES ......................................................................................... 289
11.7.1 Direct Structure ....................................................................................... 290

9
11.7.2 Cascade Structure.................................................................................... 290
11.8 EXERCISES .......................................................................................................... 292
CHAPTER 12 - DESIGN OF FIR DIGITAL FILTERS USING
MICROCONTROLLERS ................................................................ 295
12.1 DESIGN OF A LOW-PASS FILTER ............................................................................... 295
12.1.1 The Project Hardware .............................................................................. 295
12.1.2 Calculating the Filter Coefficients with Scope FIR Filter Design Program .. 301
12.1.3 Implementing the FIR Filter ..................................................................... 304
12.1.4 The Algorithm.......................................................................................... 305
12.1.5 Program Listing ....................................................................................... 306
12.2 DESIGN OF A BAND-PASS FILTER ............................................................................. 310
12.3 MORE EFFICIENT ALGORITHM................................................................................. 311
12.3.1 Filter Specifications.................................................................................. 315
12.4 DESIGNING A BAND-PASS FILTER WITH MORE EFFICIENT ALGORITHM .............................. 318
12.5 CALCULATING THE TIME IN THE FIR FILTER LOOP......................................................... 320
CHAPTER 13 - DESIGN OF IIR DIGITAL FILTERS USING
MICROCONTROLLERS ................................................................ 323
13.1 DESIGN OF A LOW-PASS FILTER ............................................................................... 323
13.1.1 The Project Hardware .............................................................................. 323
13.1.2 Cascade Implementation ......................................................................... 324
13.1.3 The Filter Coefficients .............................................................................. 326
13.1.4 The Filter Program ................................................................................... 328
13.2 SECOND ORDER HIGH-PASS FILTER .......................................................................... 331
13.3 SIXTH ORDER LOW-PASS FILTER .............................................................................. 332
13.4 PROGRAM FOR ANY EVEN ORDER IIR FILTER.............................................................. 335
13.5 IIR FILTERS OF ANY ORDER .................................................................................... 337
13.6 CALCULATING THE TIME IN THE IIR FILTER LOOP ......................................................... 341
CHAPTER 14 - GETTING STARTED WITH DEDICATED DSPS ..................... 343
14.1 THE DEDICATED DSP MARKET ................................................................................ 343
14.2 THE ADSP-21469 DSP PROCESSOR ....................................................................... 344
14.3 THE ADSP-21469 EZ-BOARD DEVELOPMENT KIT ...................................................... 347
14.4 AUDIO INPUT-OUTPUT CONNECTIONS ...................................................................... 351
14.5 THE SHARC FAMILY DEVELOPMENT TOOLS ............................................................... 353
14.6 THE VISUALDSP++ .............................................................................................. 356

10
APPENDIX A BUTTERWORTH DIGITAL FILTER COEFFICIENTS .......... 365
APPENDIX B CHEBYSHEV DIGITAL FILTER COEFFICIENTS ................. 371
APPENDIX C ARCHITECTURE OF THE PIC18F45K22
MICROCONTROLLER .................................................................. 377
C.1 THE PIC18F45K22 MICROCONTROLLER .................................................................. 377
C.2 PIC18F45K22 ARCHITECTURE............................................................................... 378
C.2.1 The Program Memory ............................................................................. 380
C.2.2 The Data Memory ................................................................................... 381
C.2.3 Oscillator Configurations ......................................................................... 382
C.2.4 The Reset................................................................................................. 382
C.2.5 Parallel I/O Ports ..................................................................................... 383
C.2.6 Timer Modules ........................................................................................ 384
C.2.7 Analog-to-Digital Converter Module ........................................................ 387
C.2.8 Interrupts ................................................................................................ 391
APPENDIX D PROGRAM LISTING FIR1.C ..................................................... 397
APPENDIX E PROGRAM LISTING FIR1.C (INPUT BUFFER)...................... 401
APPENDIX F PROGRAM LISTING IIR1.C ...................................................... 405
APPENDIX G 6TH ORDER IIR DIGITAL FILTER PROGRAM ....................... 409
APPENDIX H PROGRAM LISTING EVEN NUMBER IIR FILTER ............... 413
APPENDIX I PROGRAM LISTING: MODIFIED IIR FILTER DESIGN ....... 417
INDEX .......................................................................................................................... 423

11
PREFACE
Digital Signal Processing (DSP) is the process of capturing, analysing, and manipulation of
an analog signal by a digital processor, e.g. a digital computer.

The theory of DSP is quite complex and requires good understanding of high level of
mathematics. Students new to DSP are usually taught the theory in great detail with very
little or no practical applications. For example, in many cases a student can derive complex
equations for digital filters, but is unable to implement a digital filter in real life. Some
institutions use tools such as MATLAB to derive the coefficients of digital filters and then
to simulate the behaviour of these filters on a PC. Although simulation can be an invaluable
tool in teaching, it is never the same as real-time and real-life implementations.

The aim of this book is to teach the basic principles of DSP and to introduce DSP from a

or
practical point of view using minimum of mathematics. Only the basic level of theory is
given just enough to implement DSP applications in real-time. The emphasis of the book is
kt
on practical aspects of DSP, such as design issues and real-time implementation issues. The
e
practical implementation is described using the widely available low-cost general purpose
El
microcontrollers so that the readers can very easily and quickly design and implement DSP
applications in real-time. The architectures of dedicated DSP processors are complex and
ht

this adds additional difficulty to students who may want to implement DSP applications
using such tools.
rig

In this book the popular and highly powerful PIC18F45K22 microcontroller is used as the
y

processor to implement DSP applications in real-time. Using this microcontroller the


op

readers should be able to implement DSP applications with sampling frequencies within the
C

audio range. Programming is done using the popular and powerful mikroC PRO for PIC,
which is a C language and compiler developed specifically for the PIC family of
microcontrollers. The DSP projects given in the book are based on using the EasyPIC 7
microcontroller development kit, although any other development kit could also be used.

The DSP development environment used in the book consists of:

EasyPIC 7 microcontroller development board with PIC18F45K22 chip


A/D converter (built-in on the microcontroller chip)
D/A converter (MCP4921)
PCSGU250 Frequency generator and Bode plotter
mikroC PRO for PIC compiler

This book is primarily intended for students and practising engineers who may want to
learn the practical implementation of DSPs, such as digital filters in real-time.

13
The structure of the book is as follows:

Chapter 1 is an introduction to the world of DSPs and gives a brief overview of the basic
parts forming a typical DSP system.

Chapter 2 is about the important topic of number systems which describes the various
number systems used in microcontroller and DSP applications.

Chapter 3 is an introduction to the processor architectures used in DSP applications. The


features of various hardware and software development tools are given in this chapter.

Chapter 4 is about C programming and describes the features of the popular mikroC PRO
for PIC language and compiler in detail and with many examples.

Chapter 5 is an introduction to the powerful engineering design and simulation tool


MATLAB. The basic programming and graph plotting details are given with examples.

or
Chapter 6 provides the basic principles of discrete time systems required for the
understanding of DSP systems in general. kt
e
Chapter 7 is about the z-transforms and covers the principles of this important topic,
El

including the inverse transformations.


ht

Chapter 8 is an introduction to the important topic of Discrete Fourier Transforms and gives
rig

examples of finding the transform of some common functions.


y

Chapter 9 is about the features of digital filters and provides a comparison of various types
op

of filters used in practice.


C

Chapter 10 provides the theory of designing FIR digital filters. The design of low-pass and
high-pass filters is given with examples. In addition, the ScopeFIR digital filter design
software package is described with examples.

Chapter 11 provides the theory of designing IIR digital filters. The design of Butterworth
and Chebyshev type digital filters are given with examples. In addition, the ScopeIIR
digital filter design software package is described with examples.

Chapter 12 is about the implementation of FIR digital filters using general purpose
microcontrollers. Various tested and working example projects are given in this chapter,
including the implementation of several different windowed designs.

Chapter 13 is about the implementation of IIR digital filters using general purpose
microcontrollers. Various tested and working examples are given in this chapter, including
the implementation of Butterworth and Chebyshev type filters.

14
Chapter 14 is an introduction to the dedicated DSP processors where the use of
VisualDSP++ software package is given with a simple example.

Finally, Appendix A and Appendix B give tables for the design of Butterworth and
Chebyshev type digital filters respectively. Appendix C provides the architectural details of
the PIC18F45K22 microcontroller used in the projects in this book. Appendix D to
Appendix I give program listings of designed digital filters.

Prof Dr Dogan Ibrahim


London, 2013

or
e kt
El
ht
y rig
op
C

15
6.4 | Block Diagram Representation

6.4 Block Diagram Representation


Operations on discrete time sequences can be represented by using block diagrams
as shown in Figure 6-14. Block diagrams can be useful when discrete time
sequences are used in systems with discrete time inputs and outputs.

or
e kt
El
ht

Figure 6-14 Block diagram representation of discrete time sequences


y rig
op

6.4.1 Block Diagram Manipulation


C

Block diagram manipulation is useful for deriving the equations at various parts of
the system. An example is given below.

Example 6.1

The block diagram of a discrete time system is shown in Figure 6-15. Derive an
expression for the output y[n].

184
7.8 | Properties of the z-Transform

[()] = [()] = []

2. Left shift property


Suppose that the z-transform of x[n] is X[z] and let y[n] = x(n + m). Then,
1

[] = [] ()
=0

If the initial conditions are all zero, i.e. x(i) = 0, i = 0,1,2,.,m-1, then,

[( + )] = []

3. Right shift property


Suppose that the z-transform of x[n] is X[z] and let y[n] = x(n - m). Then,
1

or

[ ] = [] ( )
=0
e kt
If the initial conditions are all zero, i.e. x(i) = 0, i = 0,1,2,.,m-1, then,
El

[( )] = []
ht
rig

4. Attenuation property
Suppose that the z-transform of x[n] is X[z], then,
y
op

[ ()] = [ ]
C

This result states that if a function is multiplied by the exponential


then in the z-transform of this function z is replaced by .

5. Initial value theorem


Suppose that the z-transform of x[n] is X[z], then the initial value of the
time response is given by:

lim () = lim []
0

6. Final value theorem


Suppose that the z-transform of x[n] is X[z], then the initial value of the
time response is given by:

lim () = lim [1 1 ][]


1

202
Chapter 10 - | Design of FIR Digital Filters

Figure 10-2 shows a graph of the impulse response of the filter.

or
e kt
El
Figure 10-2 Impulse response of the filter
ht

In practice, it is impossible to realize a filter with the ideal characteristics of Figure


10-1, as the impulse response is not causal and is of infinite length. In order to
rig

develop stable and realizable filters, the frequency response is relaxed and the sharp
y

edges are removed and replaced with a transition band, and small ripple is allowed
op

in the pass-band and stop band.


C

As seen from Figure 10-2, the impulse response decays to either side of the vertical
axis, but is never 0. This is because we have defined the frequency response with
very sharp edges. To realize the ideal filter we would need infinite number of
impulse response coefficients which is not practical. In practice, the small sample
values at the tails of the response are ignored and then h[n] is set to begin from n =
0, so that we have a causal, realizable, linear phase filter. Typically depending upon
the applications between 10 and 100 coefficients are taken in practical applications.

10.2 Truncation and Windowing


As we have seen in Example 10.1, the impulse response of an ideal filter has
infinite number of coefficients and is not realizable. A finite length filter is obtained
from the ideal response by setting all its coefficients to zero outside the range of
M n M , thus giving a filter with a length of N = 2 M + 1 . If we then

249
Chapter 13 - | Design of IIR Digital Filters using Microcontrollers

There are basically two methods that we can implement a second-order section in
cascade and these are described below.

In the first method the filter transfer function is assumed to be as follows:

b0 + b1 z 1 + b2 z 2
H ( z) = (13.1)
1 + a1 z 1 + a 2 z 2

Using equation (13.1), the second order section is implemented as shown in Figure
13-4, requiring 2 delays, 5 multiplications, and 2 summations.

or
e kt
El
Figure 13-4 Implementing a second order section

In the second method, the transfer function is written as in equation (13.2) below.
ht
rig

G (b0 + b1 z 1 + b2 z 2 )
H ( z) = (13.2)
1 + a1 z 1 + a 2 z 2
y
op

Where G is the gain and b0 = 1 and equation (13.2) reduces to


C

G (1 + b1 z 1 + b2 z 2 )
H ( z) = (13.3)
1 + a1 z 1 + a 2 z 2

Figure 13-5 shows a second order filter implemented using the second method. The
ScopeIIR digital filter design program gives the filter parameters as shown in Figure
13-5.

325
Index

Index
Butterworth, 19, 271, 365
8 Butterworth Filters, 273
8-Bit Mode, 384 Butterworth Polynomials, 275

A C
A/D converter, 21, 387 C language, 87
A/D converters, 23 Cascade FIR, 269
Adding Binary Numbers, 42 Cascade Implementation, 324
ADSP-21469 DSP Processor, 344 Cascade Structure, 290
ADSP-21469 EZ, 80 Causal, 186
ADSP-21469 EZ-Board, 347 CCS C compiler, 88
Analog Filter, 18 Character Arrays, 99
Character Constants, 95

or
Analog-to-digital converters, 173
Anti-aliasing, 18 Chebyshev, 19, 271, 371
Aperiodic Digital Signals, 232
e kt
Chebyshev Filters, 282
Arithmetic format, 66 Code Assistant, 125
El

Arrays, 97 Code Composer, 86


ASCII characters Code Editor Window, 125
ht

Extended, 59 Code Explorer Window, 126


rig

Standard, 59 Code Template, 125, 126


ASCII Table, 58 Comment lines, 139
y

Audio Blackfin, 78 Comments, 90


op

Complex Exponential Signal, 177


C

B Connector locations, 350


const, 95
Band-Pass Filter, 310 Constant Strings, 100
band-pass filters, 237 Constants, 95
BCD numbers, 57 Converting Binary, 30, 33, 40
Bessel, 19, 271 Converting Decimal, 31, 36, 38
Bilinear transformation, 275 Converting Hexadecimal, 34, 35
Binary Number System, 28 Converting Octal, 37, 39
Bit Fields, 104 Convolution Process, 187
bit Type, 97 Cost and system complexity, 68
Blackman Window, 256 CrossCore, 85
Bode plotter, 300
Bode Plotter, 301 D
Bookmarks, 125
Built-in Functions, 122 D/A Converter, 24

423
Data Memory, 381
E
Data width, 67
DDSP processor, 66 EasyPIC 7, 295, 296
Debug Agent, 359 EasyPIC Fusion V7 Development Board,
Decimal equivalent, 31 76
Decimal Number System, 28 EasyPIC V7 Development Board, 74
Dedicated DSP, 85 Elliptic Filters, 286
Dedicated DSP processors, 66 Escape Sequences, 96
Dedicated DSPs, 343 Even Order IIR Filter, 335
Development time, 67 EXOR, 53
DFT Exponential Function, 197
Differentiation, 232 Exponential signal, 177
Linearity, 231 Extended ASCII characters, 59
Parseval's Relation, 232 EZ-Kit Lite, 79
Periodicity, 231
Real Sequences, 231 F

or
Time delay, 232
Diagram Manipulation, 184
e kt
FFT implementations, 343
Digital Filters, 237 Filter Algorithm, 326
El

frequency spectrum, 237 Filter Coefficients, 301, 326


Digital Signal Processing, 17 Filter order, 241, 273, 283
ht

Digital Signal Processors, 65 Filter Program, 328


rig

Digital-to-analog converter, 173 Filter response, 239


Direct FIR Structures, 268 Filter Specifications, 315
y

Direct Structure, 290 Filter type, 241


op

Discrete Fourier Transform, 217 FilterLab, 20


Discrete Impulse Function, 199 Finite Impulse Response filter, 238
C

Discrete time signals, 173 FIR Digital Filters, 245


disp Command, 137 FIR Filter Loop, 320
Distinct real roots, 211 FIR Filters, 238
Division of Binary Numbers, 45 Fixed Point, 27
do while Statements, 115 Fixed Point Numbers, 27
DS1843, 21 float, double, 94
DSP, 24 Floating Point, 27, 49
DSP algorithms, 56 Floating Point Constants, 95
DSP Application, 18 for Statements, 115
DSP applications, 195 format Command, 138
DSP Hardware, 68 Fourier Series, 217
DSP-Enhanced Processor, 75 Fourier Transform, 232
DSP-enhanced processors, 66 Fourier Transform Method, 245
dsPIC33E Starter Kit, 77 Fraction Expansion, 211

424
Index

Fractional Fixed Point Numbers, 47 LED connections, 361


function declaration, 118 LEDs, 361
LF398, 21
G Library Manager Window, 127
Linear, 186
General purpose processors, 66 Linear Time-invariant, 187
goto Statement, 118 Low-Pass Filter, 295, 323, 332
Graphics Plotting, 157
M
H
mantissa, 55
Hamming Window, 252 MATLAB, 135
Hanning Window, 256 matrix operations, 154
Hexadecimal equivalent, 34 MCP4921, 299
Hexadecimal Number System, 29 Memory, 67
High-Pass Filter, 331 Message Window, 126

or
high-pass filters, 237 Microcontroller, 173, 377
HS2420, 21 kt
Microcontrollers, 295, 323
e
mikroC PRO, 83, 84
I
El

MPLAB C18, 84
MSC8156ADS StarCore DSP, 82
ht

I/O Ports, 383 MT090, 21


IDE, 88
rig

Multi-channel, 23
IEEE 754, 27 Multi-dimensional array, 99
y

IIR Digital Filters, 271 Multiple order roots, 212


op

IIR Filter Loop, 341 Multiplication of Binary Numbers, 43


IIR Filter Structures, 289
C

IIR filters, 371


IIR Filters, 238, 337
N
Illegal names, 92 Negative Numbers, 40
Impulse function, 175 New project window, 128
Infinite Impulse Response filters, 238 Non-causal, 186
input Command, 139 Non-linear, 186
Integer Constants, 95 non-recursive filters, 238
Interrupt Processing, 121 Normalizing, 51
Interrupts, 395 Number Systems, 27
Inverse z-Transforms, 204
O
L
Octal equivalent, 38
Laplace transform, 195, 200 Octal Number System, 29

425
Offset Binary, 46
R
Operators, 105
Arithmetic Operators, 105 random noise, 23
Bitwise, 107 Rectangular Window, 250
Conditional, 107 Remez Exchange, 260
Logical, 107 Repetition Statements, 113
Preprocessor, 108 Reserved names, 92
Relational, 107 Reserved Names, 92
Oscillator Configurations, 382 Reset, 382

P S
Parallel converters, 24 Sampling frequency, 243
Parameter Assistant, 125 Sampling Process, 173
Passing Arrays, 120 sbit Type, 97
Passing Parameters, 119 Scalar addition, 182

or
PCSGU250, 300 Scalar division, 182
Periodic Signals, 217
e kt
Scalar multiplication, 182
PIC Compiler, 124 Scalar subtraction, 182
El

PIC IDE, 125 ScopeFIR, 260


PIC Libraries, 123 ScopeIIR Filter, 288
ht

PIC Program, 89 Selection Statements, 109


rig

PIC variable types, 93 Shannon sampling theorem, 18


PIC18 Explorer Board, 69 Shannon theorem, 174
y

PIC18F45K22, 295, 297 SHARC family, 345


op

PIC18F45K22 Development Kit, 72 signed char, 94


PIC18F4XK20 Starter Kit, 70 signed long int, 94
C

PICDEM 4 Demo Board, 71 Signed Magnitude, 45


PIC-USB-STK Development Board, 73 Sine Function, 198
Pointer Arithmetic, 101 Sinusoidal Decay, 178
Pointers, 100 Sinusoidal function, 175
Power consumption, 68 Special Matrices, 156
Program Memory, 380 Speed, 67
Project Hardware, 295 Stable, 187
Project Manager Window, 127 Standard ASCII characters, 59
String Constants, 96
Q String Operations, 101
Strings, 99
Q-Format, 47 Structures, 102
quantization error, 23 Subtracting Binary Numbers, 43
Switch Selection Statements, 110

426
Index

Symphony Studio, 86 Vector Addition, 181


Syntax, 89 Vector arithmetic operators, 153
System Classification, 186 Vector division, 183
Vector multiplication, 183
T Vector Subtraction, 181
Vectors in MATLAB, 149
Time-invariant, 186 Velleman PCSGU250, 295
Timer Modules, 384 VisualDSP++, 356
Time-variant, 186 void, 90
TMS320C5416 DSP, 81 void Functions, 119
Transfer Function, 271
Truncation, 249
W
Types
Derived, 93 while Statement, 113
Fundamental types, 93 White spaces, 91
Windowing, 249

or
U kt
Z
e
Unit Ramp Function, 196
El

Unit step function, 174 z-Transform


Unit Step Function, 195 Attentuation property, 202
ht

unsigned int, 94 Final value theorem, 202


rig

unsigned long int, 94 Initial value theorem, 202


Unstable, 187 iztrans, 204
y

Left shift property, 202


op

V Linearity property, 201


Right shift property, 202
C

Variable Names, 92 Z-transform, 195


Variable Types, 93 Z-transforms tables, 199

427

You might also like