lecture 6: digital systems and filteringffh8x/d/soi19s/lecture06.pdf · a system (call it t) takes...

29
Lecture 6: Digital systems and filtering DANIEL WELLER THURSDAY, JANUARY 31, 2019

Upload: others

Post on 12-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Lecture 6: Digital systems and filtering DANIEL WELLER

THURSDAY, JANUARY 31, 2019

Page 2: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

AgendaFiltering signals digitally

Applications of filtering

Linear systems and filters

Frequency and filters

This audio equalizer from Apple iTunes is made possible by a collection of digital frequency-selective filters.

2

Page 3: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Filtering signals digitallyOne of the main advantages of living in the computer/smartphone/wearable age is that digital processing power is widely available!

In the olden days, if we wanted to process information, we had to build a machine to accomplish a very specific task. The ability of the processing to adapt to the signal or task was very limited.

3

A mechanical clock contains a series of gears calibrated to tell time. What if we suddenly decided an hour was composed of 100 minutes instead of 60? We’d need a new clock! (Image credit: Jose Manuel/Wikipedia)

A sextant is specifically constructed to measure angles between objects in the sky and the horizon.

Page 4: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Filtering signals digitallyMany of these devices are programmable, allowing us to process signals how we see fit.

So what is filtering?◦ A filter is a system that permits some information to pass through the system while suppressing other

information.

What is a system?◦ A system performs a mathematical operation, or operations, on one or more input signals, to produce

one or more output signals.

A digital filter processes a digital input signal to produce the desired digital output signal.◦ There are many kinds of digital filters. The equalizer shown earlier is one example. What is an equalizer?

4

Page 5: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Applications of filteringLet’s think how we use digital filters in our everyday lives:

◦ Clean up noise in the video and audio we watch and listen to

◦ One way to allow multiple cell phones to communicate at the same time

◦ How a GPS receiver identifies satellites

◦ How movies play smoothly on high-frame-rate TV’s and computer monitors

What is being filtered in each of these examples?

5

Page 6: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Applications of filteringThe notion of filtering is not new to digital, however. It has shown up for a long time in many mundane places:

◦ Coffee filter

◦ Water purification

◦ Color filter on a camera (or even a stage light)

◦ Grain separation

◦ Chemical reactions

6

This filter separates the coffee grounds from the coffee.

Page 7: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Peer activityInstructions: Take few moments and discuss one of the digital filtering applications we identified with someone next to (or seated near) you. Note your answers to these three questions:

◦ What is the input signal?

◦ What is the desired output signal?

◦ What is removed from the input signal? (Or, what is preserved in the output?)

We will discuss your answers as a group.

7

Page 8: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Let’s talk about systemsA system (call it T) takes one or more inputs x1, x2, …, and produces one or more outputs y1, y2, …

◦ Let’s constrain ourselves to one input and one output to start.

We will work with digital systems, but it is more convenient to study discrete-time (DT) systems with continuous-valued inputs x[n] and outputs y[n].

◦ The following diagram describes such a system:

◦ The distinction of working with discrete-valued digital signals is important, but makes analysis much more complicated.

8

SystemInput x[n]

Output y[n]

Page 9: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Properties of systemsWhile a complete discussion of system properties is more appropriate for a later course, there are a couple of important properties that will make our study of filters much easier:

◦ Linearity

◦ Time invariance

We already saw linearity in another context: the spectrum of a signal.◦ Linearity of a system is the same principle: additivity and scaling

◦ For an input x[n], the system T produces the output y[n] = T(x[n])

◦ Then,

9

Page 10: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

More about linearityLinearity is a very powerful property that ensures systems are well-behaved:

◦ The system behaves the same no matter how the signal is scaled.

◦ Given a input composed of multiple signals, we can describe the output by processing those component signals individually.

Unfortunately, very little in the world is strictly linear:◦ Quantization is fundamentally nonlinear, so digital processing is inherently nonlinear.

◦ Real systems have physical limits on the range of possible inputs and outputs. These limits cause saturating, nonlinear behavior.

Fortunately, real systems can be approximately linear over a useful range.

10

Page 11: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Which is linear/nonlinear?Consider idealized examples of the following systems. Which are linear?

◦ Noise-cancelling headphones

◦ Resizing a photo

◦ EKG-based heart rate monitor

11

Page 12: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Which is linear/nonlinear?Now, some mathematical examples:

◦ T(x[n]) = (x[n])2

◦ T(x[n]) = x[n] – x[n-1]

◦ T(x[n]) = 2

12

Page 13: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Time invarianceTime invariance is another simplifying property that some systems have: processing a time-shifted input produces the output, time-shifted by the same amount.

Some examples:◦ T(x[n]) = x[n+1]

◦ T(x[n]) = (x[n])2

◦ T(x[n]) = (x[n]+x[n-1])/2

13

Page 14: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Time invarianceLet’s show the following are not time-invariant:

◦ T(x[n]) = (-1)n x[n]

◦ T(x[n]) = x[2n]

14

Page 15: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Time invarianceSome real-world examples of time-invariant systems:

◦ The audio equalizer

◦ Noise-cancelling headphones

A real-world example that is not time-invariant:◦ Image resizer

15

Page 16: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Linear, time invariant (LTI) systemsThe class of systems that are both linear and time-invariant is a very important class in signal processing theory. While a detailed discussion of these systems will wait for a future course, the frequency representation of these systems is very powerful.

◦ It allows us to describe a filter in terms of what it does to the spectrum of a signal.

16

Page 17: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Frequency response of LTI systemsSuppose a signal x(t) has a certain spectrum X(f). If our filter is an LTI system, it effectively scales individual frequencies by fixed values. We call these scaling values the frequency response H(f) of the filter:

17

Image credit: FaberAcoustical

Spectral response of Microphone from Three iPhones

Page 18: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Frequency response of LTI systemsRecall, real-valued signals have conjugate-symmetric spectra. For the same reason, a real system has a conjugate-symmetric frequency response.

◦ Thus, H(f) = H*(-f)

The spectrum of the filter output is the product of the input spectrum and the frequency response:

◦ If the input is real, the output of a real filter will also be real, with a symmetric spectrum: Y(f) = Y*(-f)

18

Page 19: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Frequency-selective filtersFrequency-selective filters are LTI filters that preserve some frequencies (the passband) and eliminate other frequencies (the stopband) in the signal:

These filters are especially useful when the desired signal occupies a limited set of frequencies.

19

Page 20: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Filtering a sinusoidConsider a three-tone signal x(t):

20

Page 21: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Filtering a sinusoidGiven a digital low pass filter that corresponds to an analog frequency of 400 Hz, only the lowest-frequency sinusoid will be preserved:

21

Page 22: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Filtering a sinusoidThus, we observe:

22

Low pass filter (400 Hz)

Page 23: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Filtering a sinusoidA high pass filter can preserve the highest-frequency sinusoid, while suppressing the others:

This filter has a 600 Hz cutoff.

23

Page 24: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Filtering a sinusoidObserve:

24

High pass filter (600 Hz)

Page 25: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Filtering a sawtooth waveA sawtooth wave can be constructed from a set of sinusoids of decreasing amplitude:

25

5 Hz Sawtooth Signal

2 5t floor 5t( )– y(t)

Y(f)

FFT

Page 26: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Filtering a sawtooth waveAfter filtering above the tenth harmonic (50 Hz):

26

Reconstruction of time-domain signal from frequency spectrum

Y(f)

y(t)

IFFT

Page 27: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

The graphic equalizerThis graphic equalizer can be considered a set of frequency selective filters:

Each of the frequencies along the horizontal axisrepresents a range corresponding tothe passband of a filter.

The decibel (dB) factor selected using the sliderrepresents the passband gain of that filter. Thedecibel scale is logarithmic, so a factor > 0 dBrepresents amplification (gain > 1), while a factor < 0 dB represents attenuation (gain < 1).

The equalizer inputs the sound into each of the filters and adds the outputs together to get the chosen equalizer characteristic. Choose your favorite music and try it out!

27

Page 28: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Next time… (and other announcements)Sampling, modulation, and digital vs. analog spectra

Next Tuesday – Homework #3, Lab #2 due

Next Thursday – Midterm exam (more about this in a moment)◦ We’ll have a review session during class on Tuesday and extra office hours

28

Page 29: Lecture 6: Digital systems and filteringffh8x/d/soi19S/Lecture06.pdf · A system (call it T) takes one or more inputs x 1, x 2, …, and produces one or more outputs y 1, y 2, …

Midterm exam #1When: Thursday, February 7, during class (9:30 – 10:45 AM)

Where: In class (Olsson 120)

What: All the material up through and including this lecture◦ We’ll review in class next week.

Policies:◦ Bring one sheet (single sided 8½ x 11”) of notes, no photocopies allowed on the note sheet

◦ No books or other course materials are allowed

◦ Calculators are welcome but unnecessary (this is not a test on how to use a calculator)

◦ Make-up: please notify Prof. Weller ahead of time (if possible); being busy is not an excuse

29