EE 354 Fall 2013 Lecture 10 The Sampling Process and Evaluation of Difference Equations

Similar documents
Design of IIR filters

EE482: Digital Signal Processing Applications

Digital Signal Processing Lecture 8 - Filter Design - IIR

Filter Analysis and Design

Like bilateral Laplace transforms, ROC must be used to determine a unique inverse z-transform.

Digital Signal Processing: Signal Transforms

EE482: Digital Signal Processing Applications

IIR digital filter design for low pass filter based on impulse invariance and bilinear transformation methods using butterworth analog filter

NCU EE -- DSP VLSI Design. Tsung-Han Tsai 1

UNIT - III PART A. 2. Mention any two techniques for digitizing the transfer function of an analog filter?

EE 311 February 22, 2019 Lecture 13

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EC2314- DIGITAL SIGNAL PROCESSING UNIT I INTRODUCTION PART A

DFT & Fast Fourier Transform PART-A. 7. Calculate the number of multiplications needed in the calculation of DFT and FFT with 64 point sequence.

The Fourier Transform (and more )

DSP Configurations. responded with: thus the system function for this filter would be

DIGITAL SIGNAL PROCESSING UNIT III INFINITE IMPULSE RESPONSE DIGITAL FILTERS. 3.6 Design of Digital Filter using Digital to Digital

Digital Signal Processing

Chapter 7: Filter Design 7.1 Practical Filter Terminology

Analysis of Finite Wordlength Effects

PS403 - Digital Signal processing

E : Lecture 1 Introduction

Fourier Analysis of Signals Using the DFT

Lecture 16 FREQUENCY RESPONSE OF SIMPLE CIRCUITS

Review of Linear Time-Invariant Network Analysis

ECE4270 Fundamentals of DSP Lecture 20. Fixed-Point Arithmetic in FIR and IIR Filters (part I) Overview of Lecture. Overflow. FIR Digital Filter

Signals & Systems. Lecture 5 Continuous-Time Fourier Transform. Alp Ertürk

Lecture 16: Filter Design: Impulse Invariance and Bilinear Transform

Lecture 3 - Design of Digital Filters

1 1.27z z 2. 1 z H 2

INFINITE-IMPULSE RESPONSE DIGITAL FILTERS Classical analog filters and their conversion to digital filters 4. THE BUTTERWORTH ANALOG FILTER

Question Bank. UNIT 1 Part-A

Digital Control & Digital Filters. Lectures 21 & 22

Discrete-Time David Johns and Ken Martin University of Toronto

FINITE PRECISION EFFECTS 1. FLOATING POINT VERSUS FIXED POINT 3. TYPES OF FINITE PRECISION EFFECTS 4. FACTORS INFLUENCING FINITE PRECISION EFFECTS

Discrete Time Systems

Notes on L (Optimal) Filters

Cast of Characters. Some Symbols, Functions, and Variables Used in the Book

Recursive, Infinite Impulse Response (IIR) Digital Filters:

Methods for analysis and control of. Lecture 6: Introduction to digital control

FPGA Resource Utilization Estimates for NI PXI-7854R. LabVIEW FPGA Version: 8.6 NI-RIO Version: 3.0 Date: 8/5/2008

IT DIGITAL SIGNAL PROCESSING (2013 regulation) UNIT-1 SIGNALS AND SYSTEMS PART-A

A system that is both linear and time-invariant is called linear time-invariant (LTI).

Signals and Systems. Lecture 11 Wednesday 22 nd November 2017 DR TANIA STATHAKI

(Refer Slide Time: 01:28 03:51 min)

Butterworth Filter Properties

Multimedia Signals and Systems - Audio and Video. Signal, Image, Video Processing Review-Introduction, MP3 and MPEG2

Course Name: Digital Signal Processing Course Code: EE 605A Credit: 3

ESS Finite Impulse Response Filters and the Z-transform

DIGITAL SIGNAL PROCESSING. Chapter 6 IIR Filter Design

Discrete Time Fourier Transform (DTFT) Digital Signal Processing, 2011 Robi Polikar, Rowan University

Each problem is worth 25 points, and you may solve the problems in any order.

ECE 410 DIGITAL SIGNAL PROCESSING D. Munson University of Illinois Chapter 12

Analog and Digital Filter Design

Chapter 7: The z-transform

FPGA Resource Utilization Estimates for NI crio LabVIEW FPGA Version: 8.6 NI-RIO Version: 3.0 Date: 8/5/2008

EE 435. Lecture 28. Data Converters Linearity INL/DNL Spectral Performance

Lecture 5 - Assembly Programming(II), Intro to Digital Filters

Fall 2011, EE123 Digital Signal Processing

EE 225D LECTURE ON DIGITAL FILTERS. University of California Berkeley

In this Lecture. Frequency domain analysis

Frequency-domain representation of discrete-time signals

THE clock driving a digital-to-analog converter (DAC)

x[n] = x a (nt ) x a (t)e jωt dt while the discrete time signal x[n] has the discrete-time Fourier transform x[n]e jωn

Lecture 2 OKAN UNIVERSITY FACULTY OF ENGINEERING AND ARCHITECTURE

Filters and Tuned Amplifiers

Lecture 9 Infinite Impulse Response Filters

EE 435. Lecture 30. Data Converters. Spectral Performance

16.362: Signals and Systems: 1.0

EE 505 Lecture 10. Spectral Characterization. Part 2 of 2

FFT Octave Codes (1B) Young Won Lim 7/6/17

(Refer Slide Time: 02:11 to 04:19)

CMPT 889: Lecture 5 Filters

Signals, Instruments, and Systems W5. Introduction to Signal Processing Sampling, Reconstruction, and Filters

Digital Filters. Linearity and Time Invariance. Linear Time-Invariant (LTI) Filters: CMPT 889: Lecture 5 Filters

Frequency Response DR. GYURCSEK ISTVÁN

Hilbert Transformator IP Cores

Analogue Filters Design and Simulation by Carsten Kristiansen Napier University. November 2004

LAB 6: FIR Filter Design Summer 2011

CMPT 318: Lecture 5 Complex Exponentials, Spectrum Representation

EE 435. Lecture 29. Data Converters. Linearity Measures Spectral Performance

Aspects of Continuous- and Discrete-Time Signals and Systems

DFT Octave Codes (0B) Young Won Lim 4/15/17

The Discrete-Time Fourier

ELEC2400 Signals & Systems

EE123 Digital Signal Processing. M. Lustig, EECS UC Berkeley

EECS150 - Digital Design Lecture 25 Shifters and Counters. Recap

E2.5 Signals & Linear Systems. Tutorial Sheet 1 Introduction to Signals & Systems (Lectures 1 & 2)

Chapter 3 Data Acquisition and Manipulation

! Circular Convolution. " Linear convolution with circular convolution. ! Discrete Fourier Transform. " Linear convolution through circular

Chapter 7. Digital Control Systems

EE-210. Signals and Systems Homework 7 Solutions

/ (2π) X(e jω ) dω. 4. An 8 point sequence is given by x(n) = {2,2,2,2,1,1,1,1}. Compute 8 point DFT of x(n) by

Chapter 5 Frequency Domain Analysis of Systems

EEO 401 Digital Signal Processing Prof. Mark Fowler

Evaluating Fourier Transforms with MATLAB

Dynamic circuits: Frequency domain analysis

EA2.3 - Electronics 2 1

REAL TIME DIGITAL SIGNAL PROCESSING

Lecture 5. The Digital Fourier Transform. (Based, in part, on The Scientist and Engineer's Guide to Digital Signal Processing by Steven Smith)

SIGNAL PROCESSING. B14 Option 4 lectures. Stephen Roberts

Transcription:

EE 354 Fall 203 Lecture 0 The Sampling Process and Evaluation of Difference Equations Digital Signal Processing (DSP) is centered around the idea that you can convert an analog signal to a digital signal that is discrete in both time and amplitude, process the resulting digital signal with a computer, and convert the digital result back to an analog signal (usually). A typical DSP system consists of the blocks shown below. Fundamental elements of a DSP System The sample and hold, represented above by a switch, samples an analog signal and holds the sampled value long enough so that the A to D converter can make a conversion of the signal. The sampling frequency fs = /T. Thus the computer receives a new sample of the data every T seconds so that any numeric processing that it is doing must be done in that amount of time. Typically the computer evaluates a difference equation of the form y = b u + b u + + b u a y a y a y k 0 k k m k M k 2 k N k N In this equation k is the time counting variable so that samples are taken at 0, T, 2T, 3T kt. The variable yk is the output variable at the time kt. The variables yk-, yk-2, yk-n are the previous output variables. The variables uk, uk-, uk-m are the input variables both past and present. The coefficients ax and bx are constants. The computer program which evaluates this difference equation might look something like this in pseudocode. Initialize Variables DO Forever Call AtoD(Vi) Vo = {difference equation} Call DtoA(Vo) Vo = Vo Wait for T seconds to pass Loop End ;Get a sample from the A to D ;Output Vo to D to A ;Reset the value of the old variable. 0-

The loop runs forever and the loop timing is typically governed by a polled or interrupt driven timer. The processing time for the difference equation evaluation is the most time consuming part of the operation and it is this processing time which determines the fastest sampling period since samples cannot be brought in faster than the machine can process them. Looking at the difference equation we see that it consists of a sequence of multiplies and adds. Such operations are a mainstay of DSP systems and nearly all specialized DSP chips have a single hardware unit which does a multiply and add operation which is called a MAC for multiply and accumulate. A few general purpose processors have become fast enough to do DSP algorithms and some have added MAC units as part of the CPU make up. The ARM7 processor is one such CPU that has a MAC unit (in addition to its barrel shifter). The MAC unit on the ARM7 can multiply two signed 32-bit integers and add the product to a third register. The ARM7 also has long integer version of this instruction. In assembly language the multiply and accumulate instruction looks like this mla rd, rm, rs, rn This instruction multiplies does the following rd rm x rs + rn Unfortunately, the Keil C compiler does not make use of the mla instruction when it evaluates a difference equations but creates code which does the multiplies and as separate assembly operations. So to take advantage of the mac unit on the ARM7 you have to write assembler code. Creating a digital filter using MatLab While this is not a course on DSP (for that you need to take EE 3), we can use Matlab as a tool to create useful difference equations which represent digital filters. We will look at two types: Butterworth filters and Chebyshev filters. Butterworth filters in MatLab A Butterworth low pass filter is maximally flat in the passband, has a relatively long transition band, and is monotonic in the stop band. In Matlab the relevant function is [num den] = butter(n, wn); In this equation num and den are the numerator and denominator polynomials in z for the Butterworth filter, N is the filter order, and wn is the normalized cutoff frequency. (The cutoff frequency is normalized so that fs/2 =.) For example, N = 3 fs = 050; wn = 3000/(fs/2); [num den] = butter(n, wn); disp(num); disp(den); %filter order %sample frequency %normalized cutoff frequency %calculate filter %display numerator and denominator 0-2

gives >> butter 0.2025 0.6075 0.6075 0.2025.0000 0.2477 0.3496 0.0228 which translates into the following transfer function in z 3 2.2025z +.2025 H ( = = 3 2 z +.2477z +.3496z +.0228 To translate this into a difference equation we first multiply numerator and denominator by z -3. This gives.2025 +.2025z H ( = = +.2477z +.3496z +.0228z Cross multiply this equation to get +.2477z +.3496z +.0228z =.2025 +.2025z Noting that the inverse z transform of yk and the inverse transform of z -x y-x we can transform this equation to the time domain and solve for yk. This gives: yk =.2025uk +.6075uk +.6075uk +.2025uk.2477y.3496y.0228y k k This equation can be implemented on the ARM7 board in floating point mode or, if it is rescaled, in integer mode. Integer mode is faster but is sometimes difficult to scale without producing overflow. Floating point mode is slower but overflow is seldom a problem. We can also use MatLab to look at the expected frequency response of this filter by plotting the filter gain vs. frequency. The following Matlab code does this. %Butter.m N = 3; %filter order fs = 050; %sample frequency wn = 3000/(fs/2); %normalized cutoff frequency [num den] = butter(n, wn); %calculate filter disp(num); %display numerator and denominator disp(den); %freqz finds the frequency response for 52 points between 0 and fs/2 [H f] = freqz(num, den, 52, fs); figure();clf; plot(f, abs(h)); xlabel('frequency in Hz'); ylabel('filter gain'); title('3rd Order Butterworth filter'); k 0-3

Note that the cutoff frequency is at the point where the gain is.707 (the half power point). Chebyshev filters in MatLab A Chebyshev low pass filter is has some ripple in the passband, has a faster transition band than does the Butterworth filter, and is monotonic in the stop band. In Matlab the relevant function is [num den] = cheby(n, Rdb, wn); In this equation num and den are the numerator and denominator polynomials in z for the type Chebyshev filter, N is the filter order, Rdb is the passband ripple in decibels, and wn is the normalized passband edge frequency. (The passband edge frequency is normalized so that fs/2 =.) Here is a Matlab program to calculate and plot a 3 rd order Chebyshev low pass filter. %Chebyshev.m N = 3; %filter order fs = 050; %sample frequency wn = 3000/(fs/2); %normalized passband edge frequency ripple = 0.05; %pass band peak to peak ripple rdb = -20*log0(-ripple); %convert ripple to decibels [num den] = cheby(n, rdb, wn); %calculate filter disp(num); %display numerator and denominator disp(den); %freqz finds the frequency response for 52 points between 0 and fs/2 [H f] = freqz(num, den, 52, fs); figure();clf; plot(f, abs(h)); xlabel('frequency in Hz'); ylabel('filter gain'); title('3rd Order Chebyshev filter'); 0-4

The numberator and denominator polynomials are 0.997 0.5992 0.5992 0.997.0000 0.798 0.4985-0.0804 The resulting frequency plot for the filter is shown below. Class exercise 0-: The program ChebF3.c implements the 3 rd order Chebyshev filter above as a digital filter running on the ARM7 processor but it has no timer to make the sample time correct. Modify this program to use a timer0 either in the polled mode or in the interrupt mode to get a sample frequency of 025Hz. 0-5

//ChebyF3.c Fall 2007 /*This program implements a filter in floating point This is for ARM7 processor board. 0.99727Z^3 + 0.59986Z^2 + 0.59986Z + 0.99727 H(Z) = ------------------------------------------------------ Z^3 +.79752Z^2 + 0.4985085Z^2-0.080443 This filter was designed in MatLab as a 3rd order Chebyshev filter with fpass = 3000; Rp = 0.05;N = 3; wn = 3000; */ #include <LPC23X.H> const float b0 = 0.997272; const float b = 0.59986; const float b2 = 0.59986; const float b3 = 0.997272; const float a = 0.79752; const float a2 = 0.4985085; const float a3 = -0.080443; void main(void) {unsigned int uint; unsigned int dtoaout; float u, y; float u, u2, u3; float y, y2, y3; VPBDIV = 0x02; //Set the Pclk to 30 Mhz AD0CR = 0x0020060; //Setup A/D:0-bit AIN0 @ 4.28MHz software cntr AD0CR = 0x0000000;// Start A/D Conversion PINSEL = 0x00480000;// P0.25 set to DA Out, P0.27 set to input AD0. dtoaout = 0; while() {uint = AD0DR; // Read A/D Data Register while ((uint & 0x80000000) == 0) //Wait for the conversion to end uint = AD0DR; uint = ((uint >> 6) & 0x000003FF);//Shift into position for 0-bi u = (float)uint; ///024.0; u = u/024.0; y = b0*(u + u3) + b*(u + u2); y = y - a*y - a2*y2 - a3*y3; DACR = ((int)(y*024.0)) << 6; y3 = y2; //Shift variables for next y2 = y; // iteration y = y; u3 = u2; u2 = u; u = u; AD0CR = 0x0000000; // Restart A/D Conversion } } 0-6

Discrete in Frequency Fourier Transform Summary Continuous in Time Discrete in Time Fourier Series Discrete Fourier transform The Fourier series expresses "almost any" periodic function in terms of an infinite sum The DFT is the same as the Fourier transform if both the time and frequency variables of sinusoids. The time function is continuous and the sinusoids have discrete are made discrete. For the DFT both the time and frequency domains become frequency values. periodic. Since all variables are discrete, the DFT is convenient for computer calculations. The fast Fourier Transform (FFT) provides and efficient algorithm for calculating the DFT. f t = C e jkω0t ( ) k k = Continuous in time Periodic jk t C = 0 k f ( t) e ω T T Discrete in frequency Not periodic dt f ( nt ) = NT Discrete in time Periodic N k = 0 F( k) e 2πkn j T N F( k) = T N n= 0 Discrete in frequency Periodic f ( n) e 2πkn j T N Continuous in Frequency Fourier transform The Fourier transform can be derived from the Fourier series by allowing the period to go to infinity. The Fourier transform shows the frequency make up of non-periodic signals. The time function is continuous as is the frequency domain transform. If C k is the value of the Fourier series coefficients for a function with period T, then the Fourier transform is the limit of TC k as T goes to infinity. The Fourier transform can be "generalized" by replacing jω with the complex variable s. The result is the Laplace transform. Discrete Time Fourier transform The DTFT is the same as the Fourier transform except that the time variable is discrete. The frequency spectrum of the resulting non-periodic discrete time signal is continuous and periodic. The DTFT can be "generalized" by allowing a new complex j T variable, z, to replace. This results in the z-transform. e ω j f t = F ω e ω t jωt jωnt ( ) ( ) dω F( ω ) = 2π f ( t) e dt f ( nt ) = F( ωt ) e dω 2π F( ω T ) = T f ( nt ) e T n= Continuous in time Not periodic Continuous in frequency Not periodic Discrete in time Not periodic Continuous in frequency Periodic jωnt 0-7

The LaPlace Transform The LaPlace transform is derived from the Fourier transform by replacing jω by s where s is an arbitrary complex number having both a real part, σ, and an imaginary part ω. e st F( s) = f ( t) dt This is the defining equation for the LaPlace transform. It s counterpart, the inverse LaPlace transform, is: σ + j st f ( t) = F( s)e ds 2πj σ j The Z transform The z-transform is derived from the DTFT where we generalize and replace e jωt with z where z is an arbitrary complex number. F( = f ( nt) z n n= The inverse z transform can be derived using the Cauchy integral theorem from complex variables. The inverse z transform is: n f ( n) = F z z dz j ( ) 2π C 0-8