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
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 x n = x(nt ) 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
Analog-to-digital conversion Real-world signal Electronic Signal Conditioner Track & hold Circuit ADC µc 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
Ideal sampling of signals Continuous-time signal x(t) Continuous values of x, t Discrete-time signal x n Continuous x, integer n A sequence x(t) x n t Sampled-data signal x s (t) Continuous x, t Modeled by a pulse train -2-1 0 1 2 3 4 5 6 7 n x s (t) 1X 1X x s (t) = x n (t nt )=x(t) n= 1 n= 1 0 T 2T 3T 4T 5T 6T 7T MAE143A Signals & Systems Winter 2016 4-2T -T (t nt ) t
The Fourier transform (Roberts Chap 10) Generalization of the Fourier series to non-periodic function only one single, very long period T!1 X( )= 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 x(t) = 1 2 Z 1 1 Z 1 x(t)e j 1 t dt X(!)e j!t d! MAE143A Signals & Systems Winter 2016 5
The Fourier transform - example Two-sided decaying exponential x(t) =e t 5, t 2 ( 1, 1) X(!) = = = X(!) = Z 1 1 Z 0 1 1 j! 1 e t 5 e j!t dt e t 5 j!t dt + 5 2 5! 2 + 1 25 + 1 j! + 1 5 Z 1 0 e t 5 j!t dt MAE143A Signals & Systems Winter 2016 6
The Fourier and Laplace transforms For a one-sided signal x(t)with Laplace transform X (s) X(!) =X (s) s=j! Note that this is a signal property It mimics the Laplace transform and frequency response relationship for causal systems Y (!) =H(j!)U(!), H(!) =F(h(t)) The interest in Fourier transforms is in the infinite-time response to periodic inputs Special Fourier transforms F[ (t)] = 1, F[cos! 0 t]= [ (!! 0 )+ (! +! 0 )] F[1] = 2 (!), F[sin! 0 t]=j [ (!! 0 )+ (! +! 0 )] MAE143A Signals & Systems Winter 2016 7
Bandlimited signals Signals, x(t), whose Fourier transform, X(ω), is zero for frequencies outside a value, the bandwidth, B, i.e. X(!) = 0 for {! >B} [ {! < B} 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
Fourier transform of a sampled signal The spectrum of a perfectly sampled signal x s (t) is a repeated and scaled version of X(ω) Bandlimited signal bandwidth B<ω s /2 X(ω) X s (ω) ω -ω s 0 Signal with bandwidth B>ω s /2 ω s 2ω s ω X(ω) X s (ω) ω -ω s 0 Expect trouble in reconstruction of x(t) from x s (t) ω s 2ω s ω MAE143A Signals & Systems Winter 2016 9
Reconstructing sampled bandlimited signals Reconstruction of the original signal from samples X s (ω) x s (t) x(t) -ω s 0 -B ω s We can reconstruct using an ideal lowpass filter This only works if B 2ω s ω! s 2B H(!) Lowpass Filter Bandwidth B 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 is called the Nyquist sampling frequency MAE143A Signals & Systems Winter 2016 10
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
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 f s =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
Aliasing II MAE143A Signals & Systems Winter 2016 13
Dealing with aliasing Anti-aliasing filters Before we sample a signal x(t) at f s we lowpass filter it through a filter of bandwidth B f s /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 f s /2 2. We have to back off from f s /2 3. Fast roll-off is accompanied by passband ripple You cannot remove aliasing after sampling MAE143A Signals & Systems Winter 2016 14
Aliasing in practice Any data-logging equipment worth a dime has antialiasing 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
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
Downsampling 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 MAE143A Signals & Systems Winter 2016 17
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
Matlab s decimate >> 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. MAE143A Signals & Systems Winter 2016 19
Matlab s downsample >> 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]. 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
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
Discrete Fourier transform X k = NX 1 n=0 x[n] = 1 N x[n]e jk 2 N n, k =0, 1,...,N 1 NX 1 k=0 X k e jn 2 N k, n =0, 1,...,N 1 DFT: N signal samples in and N transform values out Related to DTFT X k = X( ) = 2 k N Inverse DFT: N in values and N time samples out N is referred to as the record length If {x[n]} is real then X k = X k MAE143A Signals & Systems Winter 2016 22
Interpretation of the DFT N-sample data record {x 0,x 1,...,x N 1 } x 0 x 1 x 2 x N 1 x 0 x 0 x 0 0 T 2T (N-1)T } time Periodic repetition forever What is the Fourier series? Period of this repetition is NT time } } } period NT period NT period NT period NT x rep (t) = 1X n= 1 x[n mod N] (t nt ) MAE143A Signals & Systems Winter 2016 23
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 X k = X k Plotting Xk is a line spectrum as if the data were N-periodic MAE143A Signals & Systems Winter 2016 24
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