Introduction to Time and Frequency: Using Digital...

23
c 2008 Dr. Jay Weitzen 1 Introduction to Time and Frequency: Using Digital Filters 25.108 Introduction to Engineering II Dr. Jay Weitzen

Transcript of Introduction to Time and Frequency: Using Digital...

Page 1: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 1

Introduction to Time and Frequency:

Using Digital Filters25.108 Introduction to Engineering

IIDr. Jay Weitzen

Page 2: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 2

Experiment Objectives:

• Introduce concepts of time and frequency• Build complicated waveforms from

harmonics• Introduce concepts of digital filtering• Reduce complicated waveform to simple

sinusoid

Page 3: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 3

Basic Theory

• In the early 1800’s Fourier showed that any periodic waveform could be expressed as an infinite sum of sine’s and cosines. – He developed a mathematical relationship

between a waveform in the time domain and it’s component sines and cosines called the Fourier Series and The Fourier Transform

Page 4: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 4

Time Frequency Plane

Page 5: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 5

Wave Generation from Components

Page 6: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 6

Example: Waveforms and Spectrum

A simple sinusoid in time and frequency

Page 7: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 7

Example: Spectrum of a Triangle Wave

Page 8: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 8

Basic Theory (You will learn this in 16.362 so do not worry now)

Page 9: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 9

What is a Digital Spectrum Analyzer

Page 10: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 10

An Example

Page 11: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 11

Try it Yourself

0 0.1 0 .2 0 .3 0 .4 0 .5 0 .6 0 .7 0 .8 0 .9 1-1

-0 .8

-0 .6

-0 .4

-0 .2

0

0 .2

0 .4

0 .6

0 .8

1

Time (sec)

- 4 0 - 2 0 0 2 0 4 0 6 0

- 2 5 0

- 2 0 0

- 1 5 0

- 1 0 0

- 5 0

0

F r e q u e n c y ( H z )

Pow

er

>> time=0:0.001:5;>> sin5=cos(time.*2*pi*5);>> plot(time,sin5)>> plot(time(1:1000),sin5(1:1000))>> SpectrumAnalyzer(sin5,1000)>>

Page 12: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 12

Square Wave has infinite bandwidth

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

>> sq5=sign(sin5);>> plot(time(1:1000),sq5(1:1000))>> SpectrumAnalyzer(sq5,1000)

-500 -400 -300 -200 -100 0 100 200 300 400 500-80

-70

-60

-50

-40

-30

-20

-10

0

10

Frequency (Hz)

Pow

er

Page 13: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 13

What is a Filter?

• Passes a band of frequencies and rejects other frequencies– Three Bands of Interest

• Pass band, The frequencies which get through• Stop band, the frequencies which don’t get through• Transition bands, the bands in which part of the

frequencies get through, between stop and pass bands

Page 14: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 14

Tuning a Radio, an example of Filtering

What does it do? Passes the frequencies you want and rejects those that you do not want.

Page 15: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 15

Types of Digital Filters

• Low Pass: Passes low frequencies, rejects high frequencies

• High Pass: Passes high frequencies, rejects low frequencies

• Band Pass: Passes a band of frequencies• Band Stop: Rejects a band of frequencies

Page 16: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 16

Filter Implementations

• Infinite Impulse Response (IIR)– Feedback filter

• Finite Impulse response– Feed Forward

• Hybrid IIR/FIR

Page 17: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 17

Key parameters in filter design

• Sampling rate• Number of Taps• Pass band• Stop Band

Page 18: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 18

Using FDA tool

• Type “FDATOOL” at command prompt

Filter Type

Don’t touch this

Pass band

Stop Band

Sampling Frequency

Compute Filter Button

Page 19: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 19

Step 2: Enter Parameters

• Enter Sampling Frequency• Pass Band• Stop Band• Leave Everything else the same

Page 20: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 20

Step 3: Design Filter

• Push “design Filter Button Filter Response Shown

Page 21: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 21

Step 4: Export Coefficients

• On “File Menu” Type Export

Create “Num”, and “Den”. If you have matlab 6.5, type “Den=1”

Page 22: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 22

Step 5: do the filtering

• Type

• “>> Output=filter(Num,Den,Input)” to apply the filter you have created. It is simple as that.

Page 23: Introduction to Time and Frequency: Using Digital Filtersfaculty.uml.edu/.../25.108_DigitalFilterDesignUsingFDATool.pdf · Introduction to Time and Frequency: Using Digital Filters

c 2008 Dr. Jay Weitzen 23

Quick Question?

• If you take a triangle wave with spectrum shown and low pass filter remove all frequencies except the fundamental, what will you see?

Answer: A sine wave at the fundamental frequency