Transcript
Page 1: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Moving from continuous- to discrete-time

Sampling ideas Uniform, periodic sampling rate, e.g. CDs at 44.1KHz

First we will need to consider periodic signals in order to appreciate how to interpret discrete-time signals as representative of continuous-time

Fourier series and transforms

Discrete-time Fourier transform (DTFT)

Discrete Fourier transform (DFT) & the fast Fourier transform (FFT)

Aliasing and signal reconstruction

Discrete-time signals then discrete-time systems Matlab tools and digital signal processing

Nothing on digital (finite bit-length) signals

MAE143A Signals & Systems Winter 2016 1

Page 2: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Sampled signals – discrete time

For computer use we need to sample signals Most commonly this is periodic sampling every T seconds we take a sample of the continuous signal This yields a sequence

A continuous-time signal is a function of time t A discrete-time signal is a sequence indexed by t

T is the sampling period (sec)

1/T is the sample rate (Hz)

Often we also quantize the samples to yield a digital signal of a fixed number of bits representation

This is a subject for the next course

MAE143A Signals & Systems Winter 2016 2

xn = x(nT )

Page 3: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Analog-to-digital conversion

Signal conditioning Filtering (anti-aliasing), offset, ranging

Track and hold circuit Enabled by the rising edge trigger Holds the signal at the latched value

Analog-to-digital converter Converts held signal to 8-bit, 16-bit, 24-bit digital

Computer – coordinates sampling, storage, 1/T sec MAE143A Signals & Systems Winter 2016 3

Electronic Signal

Conditioner Real-world signal

Track & hold Circuit ADC µC

Page 4: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Ideal sampling of signals

Continuous-time signal x(t) Continuous values of x, t

Discrete-time signal xn

Continuous x, integer n A sequence

Sampled-data signal xs(t) Continuous x, t Modeled by a pulse train

MAE143A Signals & Systems Winter 2016 4

t

x(t)

t

xs(t)

0 T 2T 3T 4T 5T 6T 7T -T -2T

xn

0 1 2 3 4 5 6 7 -1 -2 n

xs(t) =1X

n=�1xn�(t� nT ) = x(t)⇥

1X

n=�1�(t� nT )

Page 5: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

The Fourier transform (Roberts Chap 10)

Generalization of the Fourier series to non-periodic function – only one single, very long period

X(ω) is like the line spectrum with zero spacing between harmonic elements

Still represents the signal as a sum of exponentials Requires absolute integrability of x(t)- finite energy

Inverse Fourier transform

MAE143A Signals & Systems Winter 2016 5

T ! 1

X(�) =

Z 1

�1x(t)e�j�t dt

x(t) =1

2⇡

Z 1

�1X(!)ej!t

d!

Page 6: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

The Fourier transform - example

Two-sided decaying exponential

MAE143A Signals & Systems Winter 2016 6

X(!) =

Z 1

�1e�

|t|5 e�j!t dt

=

Z 0

�1e

t5�j!t dt+

Z 1

0e�

t5�j!t dt

=�1

j! � 15

+1

j! + 15

|X(!)| =25

!2 + 125

x(t) = e

� |t|5, t 2 (�1,1)

Page 7: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

The Fourier and Laplace transforms

For a one-sided signal x(t)with Laplace transform

Note that this is a signal property It mimics the Laplace transform and frequency response relationship for causal systems

The interest in Fourier transforms is in the infinite-time response to periodic inputs

Special Fourier transforms

MAE143A Signals & Systems Winter 2016 7

X(!) = X (s)|s=j!

X (s)

Y (!) = H(j!)U(!), H(!) = F(h(t))

F [�(t)] = 1, F [cos!0t] = ⇡[�(! � !0) + �(! + !0)]

F [1] = 2⇡�(!), F [sin!0t] = j⇡[��(! � !0) + �(! + !0)]

Page 8: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Bandlimited signals

Signals, x(t), whose Fourier transform, X(ω), is zero for frequencies outside a value, the bandwidth, B, i.e.

is referred to as bandlimited

A periodic signal with line spectrum zero outside the bandwidth B is also referred to as bandlimited

Bandlimited implies a level of smoothness

Fourier series: finite power, periodic

Fourier transform: finite energy, one-shot

MAE143A Signals & Systems Winter 2016 8

X(!) = 0 for {! > B} [ {! < �B}

Page 9: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Fourier transform of a sampled signal

The spectrum of a perfectly sampled signal xs(t) is a repeated and scaled version of X(ω)

Bandlimited signal bandwidth B<ωs/2 Signal with bandwidth B>ωs/2

Expect trouble in reconstruction of x(t) from xs(t)

MAE143A Signals & Systems Winter 2016 9

X(ω)

ω

Xs(ω)

ωωs 2ωs-ωs 0

X(ω)

ω

Xs(ω)

ωωs 2ωs-ωs 0

Page 10: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Reconstructing sampled bandlimited signals

Reconstruction of the original signal from samples

We can reconstruct using an ideal lowpass filter This only works if

is called the Nyquist sampling frequency

MAE143A Signals & Systems Winter 2016 10

Xs(ω)

ωωs 2ωs-ωs 0B -B

H(!)x(t)xs(t)

Lowpass Filter Bandwidth B

!s � 2B

A signal of bandwidth B can be reconstructed completely and exactly from the sampled signal if the sampling frequency ωs is greater than 2B

Nyquist’s Sampling Theorem

!s = 2B

Page 11: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Sampling and reconstruction

If the continuous-time signal is bandlimited to B and we sample faster than the Nyquist frequency

Then we can exactly reconstruct the original signal from the sample sequence

Conversely: if we sample at or more slowly than the Nyquist frequency then we cannot reconstruct the original signal from the samples alone

We might have other information that helps the reconstruction. Without such extra information we suffer from Aliasing – some frequencies masquerading as others

MAE143A Signals & Systems Winter 2016 11

Page 12: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Aliasing

Sampling rate is less than the Nyquist rate Spectra overlap in sampled signal Impossible to disentangle

Signals from above ωs/2 masquerade as signals of a lower frequency

This is what happens to wagon wheels in western movies

fs=30Hz but the passing rate of the spokes is greater than this

Dopplegänger and impersonation

Alias: a false or assumed identity

Samuel Langhorne Clemens alias Mark Twain

5.5KHz sampled at 10KHz a.k.a. 4.5KHz

MAE143A Signals & Systems Winter 2016 12

Page 13: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Aliasing II

MAE143A Signals & Systems Winter 2016 13

Page 14: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Dealing with aliasing

Anti-aliasing filters Before we sample a signal x(t) at fs we lowpass filter it through a filter of bandwidth B≤fs/2

This is straightforward but not simple 1.  An ideal lowpass filter has non-timelimited

non-causal response 2.  A timelimited signal has a Fourier transform of

unbounded support in frequency 3.  We can only approximately lowpass filter

1.  We need to worry about roll-off near fs/2

2.  We have to back off from fs/2

3.  Fast roll-off is accompanied by passband ripple

You cannot remove aliasing after sampling

MAE143A Signals & Systems Winter 2016 14

Page 15: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Aliasing in practice

Any data-logging equipment worth a dime has anti-aliasing filtering built in

It is switched in at sample-rate selection time and is handled by the equipment software

DSpace, LabView, HP analyzers Often this (and timing questions) limits the available sampling rates High-performance data acquisition is an art The data quality near Nyquist is dodgy

So why do we need to know about aliasing? Because of the mistakes you can/might/will make!!

MAE143A Signals & Systems Winter 2016 15

Page 16: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Downsampling scenario

An email arrives containing two columns of data sampled at 44.1KHz

You look at it and figure that it is oversampled and that most of the interesting information is in the range less than 10KHz in the signal

This would be captured by data sampled at 22.5KHz

So you toss out every second sample Now it is the same data sampled at half the rate

Let us try this out with a former Hilltop High student

MAE143A Signals & Systems Winter 2016 16

Page 17: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Downsampling

MAE143A Signals & Systems Winter 2016 17

Original data at 44.1KHz

Downsampled data at 22.05KHz

Decimated data at 22.05 KHz

Difference at 22.05 KHz Between downsample and decimate

Page 18: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Decimation instead of downsampling

The mistake earlier was that the reconstructed content of the 44.1KHz data contains signals in the range 0-20KHz roughly

Downsampling to 22KHz and then reconstructing should yield signals in the 0-10KHz range

The 10-20KHz material has been aliased into 0-10KHz

Before downsampling we should filter the data with a lowpass digital filter of bandwidth ~10KHz

This is called decimation

MAE143A Signals & Systems Winter 2016 18

Page 19: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Matlab’s ‘decimate’

MAE143A Signals & Systems Winter 2016 19

>> help decimate decimate Resample data at a lower rate after lowpass filtering. Y = decimate(X,R) resamples the sequence in vector X at 1/R times the original sample rate. The resulting resampled vector Y is R times shorter, i.e., LENGTH(Y) = CEIL(LENGTH(X)/R). By default, decimate filters the data with an 8th order Chebyshev Type I lowpass filter with cutoff frequency .8*(Fs/2)/R, before resampling. Y = decimate(X,R,N) uses an N'th order Chebyshev filter. For N greater than 13, decimate will produce a warning regarding the unreliability of the results. See NOTE below. Y = decimate(X,R,'FIR') uses a 30th order FIR filter generated by FIR1(30,1/R) to filter the data. Y = decimate(X,R,N,'FIR') uses an Nth FIR filter. Note: For better results when R is large (i.e., R > 13), it is recommended to break R up into its factors and calling decimate several times.

Page 20: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Matlab’s ‘downsample’

Downsampling is asking for trouble with physical signals It is a common mistake made by people

It is not really forgivable though No graduate of MAE143A has ever admitted to me to making this mistake

MAE143A Signals & Systems Winter 2016 20

>> help downsample downsample Downsample input signal. downsample(X,N) downsamples input signal X by keeping every N-th sample starting with the first. If X is a matrix, the downsampling is done along the columns of X. downsample(X,N,PHASE) specifies an optional sample offset. PHASE must be an integer in the range [0, N-1].

Page 21: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

A chirp example in Matlab

A chirp from100 Hz to 11,250 Hz over 4 seconds

Sampled at 22,500 Hz

Sampled at 11,250 Hz

Sampled at 5,625 Hz

Downsampling and decimation

MAE143A Signals & Systems Winter 2016 21

Page 22: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Discrete Fourier transform

DFT: N signal samples in and N transform values out Related to DTFT

Inverse DFT: N in values and N time samples out N is referred to as the record length If {x[n]} is real then

MAE143A Signals & Systems Winter 2016 22

Xk =N�1X

n=0

x[n]e�jk 2⇡N n

, k = 0, 1, ..., N � 1

x[n] =1

N

N�1X

k=0

Xkejn 2⇡

N k, n = 0, 1, ..., N � 1

Xk = X(⌦)|⌦= 2⇡kN

X�k = X̄k

Page 23: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

Interpretation of the DFT

N-sample data record

Periodic repetition – forever What is the Fourier series?

Period of this repetition is NT

MAE143A Signals & Systems Winter 2016 23

{x0, x1, . . . , xN�1}x0

x1x2

xN�1

T 2T (N-1)T 0

time time

x0 x0x0

… … } } } }period NT period NT period NT period NT

xrep(t) =

1X

n=�1x[n mod N ]�(t� nT )

Page 24: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

The Discrete Fourier Transform

The DFT of an N-sample (real) signal record is an N element (complex) transform record is the Fourier series of the periodic (sampled) signal repeated over and over again in both directions is N-periodic in frequency bin (k)

We cannot resolve frequency more finely because there are only N data The frequency data have a conjugate relation Plotting |Xk| is a line spectrum as if the data were N-periodic

MAE143A Signals & Systems Winter 2016 24

X�k = X̄k

Page 25: Moving from continuous- to discrete-timenumbat.ucsd.edu/~bob/signals2016Winter/Signals_&_Systems_2016... · Moving from continuous- to discrete-time ... Discrete Fourier transform

DFT

The DFT allows analysis of a data record by computing the Fourier series as if the data record were one period of an infinite periodic sequence

This is good for capturing periodic phenomena in the data provided you have an integer number of periods in the data

It is easy to be misled Especially if you forget the above explanation

The DFT is a fundamental tool in data analysis There is a huge number of helper functions in matlab

MAE143A Signals & Systems Winter 2016 25


Recommended