Report

SEMMA13 Signals / Transforms This covers Fourier Series and Transforms, Laplace Transforms, Z transforms and Correlation and Convolution In effect we are looking at representing signals in different ways. A signal may vary with time, f(t) That signal, however, is made up of signals of different frequencies, so we can see how f varies with frequency. We can transform between the time and frequency domains The Laplace domain/operator can be used for modelling systems For sampled systems, the sampled data z operator is used. Convolution is relevant as the output of a system is in fact the convolution of its input and the system transfer function. Correlation is important in processing signals… 17/07/2015 SEMMA13 Eng Maths and Stats 1 Fourier Series By way of introduction, consider the signals below, comprising one or more sinusoids superimposed…. As more sinusoids are added, we start to approximate a square wave 1 1 0 0 -1 -1 0 4π 1 1 0 0 -1 -1 0 17/07/2015 2π 2π 4π SEMMA13 Eng Maths and Stats 0 2π 4π 0 2π 4π 2 Fourier Series The square wave was approx by the “Fourier Series”: 1 0 4 sin(3t) sin(5t) sin(7t) sin(t) + + + 3 5 7 -1 0 2π 4π Here a sawtooth is approximated sin(t) - sin(2t) sin(3t) sin(4t) + 2 3 4 In general, series of sin and/or cos functions are needed 17/07/2015 SEMMA13 Eng Maths and Stats 3 Finding Fourier Series Any repetitive signal f(t) with period T can be expressed by a0 f(t) = an cos(n2 t/T) + bn sin(n2 t/T) 2 n=1 n=1 where an = T 2 2 f(t) cos (n2 t/T) dt T T 2 T 2 2 bn = f(t) sin (n2 t/T) dt T T 2 n is constant integer NB an and bn are functions of n 17/07/2015 SEMMA13 Eng Maths and Stats 4 Using Complex Numbers It is generally easier, however to use complex numbers If we defined cn = 1 (an jbn ), so c0 = 1 a0 2 2 T 2 2 cn = 1 f(t) cos (n2 t/T)-j f(t) sin (n2 t/T) dt 2 T T = T 2 2 1 f(t) exp(-j n2 t/T) dt T T 2 So the Fourier Series is given by f(t) cn exp(j n2 t/T) n - 17/07/2015 SEMMA13 Eng Maths and Stats 5 For Squarewave 1 Square wave is 1 for t = 0 to π and -1 from – π to 0 (or from π to 2 π) 0 -1 0 2π 4π T 2 2 1 0 1 cn = f(t) exp(-jnt) dt = -exp(-jnt) dt exp(-jnt) dt T T 0 2 0 1 exp(-jnt) 1 exp(-jnt) 1 = + = 1-exp(jn )-exp(-jn )+1 jn jn 0 jn 2 1 cos(n ) 1 = 2 2cos(n ) = jn jn 17/07/2015 SEMMA13 Eng Maths and Stats 6 Continued cn = 2 1 cos(n ) jn If n is even, cos(n) = 1, so cn = 0. 4 If n is odd, cos(n) = -1, so cn = . jn d 1-cos(n ) sin(n ) dn c0 = lim = lim =0 d j n 0 n 0 jn dn 4 f(t) = cn exp(j nt)= n - n(odd only) - jn L’Hopital’s rule cos(nt) + j sin(nt) As cos(nt) = cos(-nt), cos(nt)/n + cos(-nt)/-n = 0 So f(t) = 17/07/2015 4 sin(3t) sin(5t) sin(7t) sin(t) ... 3 5 7 SEMMA13 Eng Maths and Stats 7 Spectra If n is even, cn = 0; if n is odd, cn = 4 . jn Hence at most frequencies the signal amplitude is 0, But at odd frequencies it is defined by 4/jnπ At these frequencies, this has amplitude 4/nπ and phase –π/2 rads amplitude 4/π phase 1 3 5 7 1 3 5 7 f -π/2 17/07/2015 f SEMMA13 Eng Maths and Stats 8 Phase Shifted 1 Square wave is 1 for t = 0 to π/2, 0 -1 from π/2 to 3π/2 and 1 from to 3π/2 to 2π -1 0 Hence it is the previous square wave shifted by 90O. 2π 4π As should be expected, the amplitude spectrum is unchanged. The phase spectrum is 0 at frequencies 1, 3, 5, 7 … It can be shown that cn = 17/07/2015 2 1 cos(n ) n = SEMMA13 Eng Maths and Stats 4 at n = 1, 3, 5, ... n 9 FS of Rectangular Pulses 1 /2 A /2 cn = exp -jn2 t/T A exp -jn2 t/T dt = / 2 T / 2 Tjn2 /T = A exp jn /T exp -jn /T Asin(n /T) = n j2 n A sin(n /T) A n = = sinc T n / T T T sin x NB sinc(x) = x This is purely real, Phase spectrum is 0, amplitude spectrum is modulus of above If phase shift, amplitude spectrum unchanged… 17/07/2015 SEMMA13 Eng Maths and Stats 10 Amplitude Spectrum First note plot of A sinc x Then amplitude spectrum is as follows (note is |sinc|) |cn| cn = f 1/T 2/T 1/ 17/07/2015 A n sinc T T The ‘envelope’ is |sinc| function 2/ SEMMA13 Eng Maths and Stats 11 What if vary period Here period T = 0.4, 0.8 and 2, the pulse width is = 0.1, and the pulse height is 1. Spectra lines get closer as T becomes larger, but amplitude is reduced 17/07/2015 SEMMA13 Eng Maths and Stats 12 Fourier Transform Fourier Series can be used for repetitive signals. Signals have amplitude and phase at discrete frequencies Some signals are not repetitive, but it is still valid to consider their frequency properties In fact these have amplitude and phase at all frequencies. So signals can be represented as functions of time or of frequency A function f(t) can be transformed to one of frequency F(f) Similarly F(f) can be transformed to f(t) On the next slide is the derivation of these Fourier Transforms F(f) = f(t) exp(-j 2 f t) dt 17/07/2015 f(t) = F(f) exp(j 2 ft) df - SEMMA13 Eng Maths and Stats 13 Fourier Transform Let’s see what happens to Fourier Series integrals if period T ∞ cn = T 2 1 f(t) exp(-j n2 t/T) dt T T 2 Define f(t) cn exp(j n2 t/T) n - 1 = f, a small amount of frequency, so f = n f. T Frequency Specrum F(f) = lim CnT = lim T F(f) = f(t) exp(-j 2 f t) dt T 2 f(t) exp(-j n2f t) dt T T 2 For f(t) summation of cn terms becomes integral of F(f) … f(t) cn exp(j n2 t / T) = F(f) exp(j 2 ft) df n - - 17/07/2015 SEMMA13 Eng Maths and Stats 14 Properties of FT Various properties of FT follow from the definitions Suppose f1(t) transforms to F1(f) and f2(t) transforms to F2(f) Basic f1(t) + f2(t) transforms to F1(f) + F2(f) K f1(t) transforms to K F1(f), for a constant K. Time Shift f1(t-) transforms to F1(f) exp(-j2f) Freq Shift F1(f-) transforms to f1(t) exp(j2t) Differential df(t)/dt transforms to j 2 f F(f) Duality if f(t) transforms to F(f), F(t) transforms to f(-f) 17/07/2015 SEMMA13 Eng Maths and Stats 15 Fourier Transform of Pulse A A -T T 2T T F(f) = f(t) exp( -j 2 f t) dt = A exp( -j 2 f t) dt - T A A T = exp( -j 2 f t) = T exp( -j 2 fT)-exp(j 2 fT) -j 2 f -j 2 f = 2AT sin(2 f T) = 2AT sinc (2fT) 2 fT Second Pulse is first shifted by T, so … its FT is F(f) =2ATsinc(2fT) exp(-j2πfT) 17/07/2015 SEMMA13 Eng Maths and Stats 16 On Impulse A unit impulse, denoted , has area 1 and width 0. An Impulse of area A can be considered as the first pulse on last page whose area is 1 but whose width is zero: 2AT = A and T = 0, So, as T 0, F(f) = 2AT sinc(2fT) A sinc(0) = A By duality principle, if f(t) = A, a constant at all times, F(f) is a signal at frequency 0 only (the d.c. component) 17/07/2015 SEMMA13 Eng Maths and Stats 17 Impulse Train Fourier Series of Train of Pulses is cn = A n 1 sinc at intervals T T T Pulses become impulses if 0 and A = A. As 0, but A = A, cn A 1 1 sinc 0 = at intervals T T T Hence FT of a train of unit impulses at interval T is a series of impulses of height 1/T at frequency intervals 1/T 17/07/2015 SEMMA13 Eng Maths and Stats 18 Exponential exp(- t) Exponential f(t) = 0 t0 t<0 F(f) = exp(- t)exp( -j 2 f t) dt 0 = exp(-t j 2 f ) dt 0 17/07/2015 = 1 exp -t( j 2 f ) 0 j 2 f = 1 j 2 f = 1 j 2 f 0 1 SEMMA13 Eng Maths and Stats 19 Of a Step … We find this in stages … consider signum function A sgn(t) = -A t0 if t0 Not absolutely integrable | sgn(t) | dt = A dt = , so cant do its FT But can do FT of sgnexp and see what happens when 0 A t0 A exp(- t) sgn exp(t) = if t0 -A exp( t) t 1/ -A 17/07/2015 SEMMA13 Eng Maths and Stats 20 FT of SigExp 0 F(f) = -Aexp( t)exp( -j 2 f t) dt Aexp(- t)exp( -j 2 f t) dt - 0 A -A 0 = exp t(- +j2 f ) exp -t( +j2 f ) +j2 f 0 +j2 f = A A 1 0 j 2 f j 2 f = -Aj4 f A A = j 2 f j 2 f 2 (2 f)2 17/07/2015 0 1 SEMMA13 Eng Maths and Stats 21 FT of Signum and Step Hence FT of signum is that of above as -j4 f -j4 fA A lim A = = j f 0 2 (2 f)2 (2 f)2 0 A unit step is 0 before t = 0, and 1 after. It is in effect ½ + signum of height ½ Hence FT of a step is 0.5 + 0.5 j f 17/07/2015 SEMMA13 Eng Maths and Stats 22 Convolution Convolution is useful operation in Signal Theory. Sometimes called blurring. Can simplify Fourier Transforms Convolution of two funcs : c(t) = f1 (t) f2 (t) = f1 ( ) f2 (t- ) d - f1(t) times f2(t) transforms to F1(f)*F2(f) f1(t) * f2(t) transforms to F1(f) times F2(f) Suppose a system has a transfer function TF, and I is its input, then its output is the convolution of I and TF in time domain. 17/07/2015 SEMMA13 Eng Maths and Stats 23 Convolving Two Pulses Convolution is process of sliding second pulse across first pulse, multiplying and computing area for each amount of sliding. Where they don’t overlap, multiplication is 0, Where they partly overlap product rises / falls Where they totally overlap, product is A1 * A2 Hence convolution of pulses is trapezium 17/07/2015 SEMMA13 Eng Maths and Stats 24 Convolving Pulse Trains If convolve pulse and train of impulses, get series of pulses centred on impulses Is in effect a square wave 17/07/2015 SEMMA13 Eng Maths and Stats 25 FT of Repetitive Signal Given FT of Pulse is Sinc Also the FT of a train of impulses is a train of impulses of height 1/T at frequency interval 1/T. So FT of set of pulses is product of two, being a set of impulses whose envelope is the sinc This is same as that found by Fourier Series 17/07/2015 SEMMA13 Eng Maths and Stats 26 FT of Triangular Pulse A* 1 t T f(t) = A* 1 t T 0 -T t 0 0tT otherwise T 0 t F(f) = A 1 exp( j2 f t) dt 1 t exp( j2 f t) dt T T -T 0 Do-able, but tricky Much easier to use convolution 17/07/2015 SEMMA13 Eng Maths and Stats 27 By convolution = * Want this to be as follows, so B = A T But FT of Rect Pulse height A width 2T is F(f) =ATsinc(2fT) So the transform of the triangular pulse is then the product of the transform of each rectangular pulse, namely A A F(f) = Tsinc(2fT) Tsinc(2fT) = ATsinc2 (2fT) T T 17/07/2015 SEMMA13 Eng Maths and Stats 28 Correlation Signals are also processed by correlating them,. Suppose have two signals f1(t) and f2(t). Their correlation is 12 (t) = f1 ( ) f2 (t ) d - 12(t) is correlation of f1(t) & f2(t); 21(t) is that of f2(t) & f1(t). This can be compared with the integral for convolution. f1 (t) f2 (t) = f1 ( ) f2 (t- ) d - In both cases, f2 is delayed and slid across f1. For convolution it is reversed in the time axis, not so with correlation. If f1 = f2 process is autocorrelation, otherwise cross-correlation 17/07/2015 SEMMA13 Eng Maths and Stats 29 Autocorrelation Illustrates stages in autocorrelation of a pulse A Shows pulse and it shifted at a time A Blob shows the amount of shifting to justify the height on the last graph Last graph is result when shifted over all t Result has maximum when shift 0 A A f() T t f(-t) f()*f(-t) T 11(t) -t -T If f(t) repetitive with period T, its autocorrelation is a maximum at delay 0, T, 2T etc Hence autocorrelation is a measure of extent can predict a future value of a signal 17/07/2015 SEMMA13 Eng Maths and Stats 30 Cross-Correlation Process similar, but two functions. Here show two pulses Bottom graph illustrates general point 12(t) = 21(-t) Cross-correlation is a measure of similarity between signals 17/07/2015 SEMMA13 Eng Maths and Stats 31 Application Pattern Recognition Cross correlation can be used to find a signal affected by random noise Graph shows pulse at some time, to which noise added. Correlation of pulse and signal shown in bottom graph Peak in result indicates time where pulse can be found 17/07/2015 SEMMA13 Eng Maths and Stats 32 Energy Spectrum The energy of a signal f(t) can be expressed as the square of f(t) over all time or of its energy E(f) at all frequencies 2 E = f (t) dt = E(f) df - - Suppose f(t) has a Fourier transform F(f) F(f) = f(t) exp(-j2 f t) dt - We can define its complex conjugate F (f) = f(t) exp(j2 f t) dt - E = F(f) F * (f) df It can be shown that - But E = E(f) df, so E(f) = F(f) F*(f) = |F(f)|2 - * 17/07/2015 SEMMA13 Eng Maths and Stats 33 Autocorrelation and ES Now consider the autocorrelation of a function f(t), whose spectrum is F(f). 11 ( ) = f(t) f(t ) dt - It can be shown that this can be rearranged to 11 ( ) = F(f) F * (f) exp(j2 f ) df - But, E(f) = F(f) F*(f), so 11 ( ) = E(f) exp(j2 f ) df - Hence the autocorrelation of a signal f(t) is the Fourier transform of the energy spectrum of f(t). 17/07/2015 SEMMA13 Eng Maths and Stats 34 Example to confirm this Suppose f(t) is a pulse of height A between -T and T. Previous analysis has shown that F(f) = 2ATsinc(2fT) The total energy of the signal is, using the time domain T 2 E = f (t) dt = A2dt = 2A2T - -T In freq domain E(f) = F(f) F * (f) = 2ATsinc(2fT) * 2ATsinc(2fT) = 4A2T 2sinc2 (2fT) Using the spectrum of F(f) (and noting sinc2(x) = 1 for x = -∞ to ∞) 4A2T 2 * 2 2 2 E = F(f) F (f) df = 4A T sinc (2fT) df = = 2A2T 2T - - Result confirmed 17/07/2015 SEMMA13 Eng Maths and Stats 35 Continued When autocorrelate f(t) get triangular pulse, width -2T to 2T, max value 2A2T Its FT is 2*2A2T*Tsinc2(2FT) = 4A2T2sinc2(2FT) Hence, autocorrelation of rect pulse, is FT of its energy spectrum 17/07/2015 SEMMA13 Eng Maths and Stats 36 FT of Spatial Signals So far we have considered signals which vary with time and their corresponding frequency response. The Fourier Transform works between these domains. But a signal can vary spatially : the distance between points being analogous to difference in time. The points also have a Spatial frequency Again Fourier Transform can work between spatial distances and spatial frequency. If x represents distance and u is 1/x being spatial frequency The Fourier Transform is F(u) = f(x) e -j2 ux dx - 17/07/2015 SEMMA13 Eng Maths and Stats 37 Two dimensional Images Often images from a camera are processed These are typically two dimensional, so can be defined as f(x,y) They have spatial frequencies in two dimensions F(u,v), v = 1/y The transforms can be expressed in double integral pairs -j2 (ux vy) F(u,v) = f(x,y) e dx dy - - j2 (ux vy) f(x,y) = F(u,v) e du dv - - Note, can transform in one dimension then the other. So if Fy (u,y) = f(x,y) e-j2 ux dx - 17/07/2015 -j2 vy dy then F(u,v) = Fy (u,y) e - SEMMA13 Eng Maths and Stats 38 Example Consider a two dimensional pulse, of width 2 and height 1, centred at x=0, y=0. That is, f(x,y) = 1 only if -1 ≤ x ≤ 1 and -1 ≤ y ≤ 1 Fy (u,y) = f(x,y) e-j2 ux dx - 1 -j2 ux = e dx -1 -j2 ux 1 e = j2 u 1 e-j2 u e j2 u = j2 u = 17/07/2015 sin(2 u) u F(u,v) = Fy (u,y) e-j2 vy dy - sin(2 u) 1 -j2 vy = dy e u 1 -j2 vy 1 sin(2 u) e = u j2 v 1 sin(2 u) e-j2 v e j2 v = u j2 v = SEMMA13 Eng Maths and Stats sin(2 u) sin(2 v) u v 39 Discrete Fourier Transform When processing images, data are points at discrete positions. Similarly, when a computer samples a signal at different times, the sampled signal is known at discrete times, not at all times The signal being sampled is said to be continuous. The sampled signal is discrete Note signals are usually sampled at regular intervals Simplifies the Maths The original Fourier Transform assumes signals are continuous When discrete, the discrete Fourier Transform, DFT, is used. First we note the effect of sampling on frequency response. 17/07/2015 SEMMA13 Eng Maths and Stats 40 Sampling and Frequency Response Sampling at regular intervals is in effect multiplying the continuous signal by a set of impulses at regular intervals, call the interval T. Hence the frequency response of the sampled signal is that of the continuous signal convolved with the frequency response of the impulses, a set of impulses at frequency interval 1/T. In effect the Frequency Response is repeated, as illustrated below: This ok, but problems if F(f) has components > 1/T, spectra overlap 17/07/2015 SEMMA13 Eng Maths and Stats 41 Discrete Fourier Transfrom Hence, interested only in freq response of signal, not in the higher freqs where the spectrum is repeated. Suppose take N samples of the signal x(t) at intervals T. Thus x(kT) is the kth value of x, sampled at instance kT The spectrum produced will itself be discrete. There will be N values in the frequency spectrum, at interval v The rth value will be X(rv) Note, v and T are related, because v * T = 1/N As signals are now discrete, the Fourier integral becomes a summation. The rth frequency value of X is defined by a summation. N-1 X(rv) = T x(kT) exp (-j 2 r k / N) k=0 Done for r = 0..N-1. The values X(rv) are complex numbers 17/07/2015 SEMMA13 Eng Maths and Stats 42 MatLab Function function x = MyDFT (v); % x = MyDFT(v) % v = array of numbers to be processed % x = array which returns with the DFT of v % Dr Richard Mitchell, 13.3.00 x = []; % result set to zero for r = 1:length(v) % for all data ans = 0; % initialise sum to 0 for k = 1:length(v) % now perform the sum ans = ans + v(k)*exp(-2*j*pi*(r-1)*(k-1)/length(v)); end x = [x ans]; % add sum to result vector end; 17/07/2015 SEMMA13 Eng Maths and Stats 43 Example Shown below a square wave, 32 values at 1 and 32 values of 0, its amplitude and phase spectra (found by abs(x) and angle(x)) 17/07/2015 SEMMA13 Eng Maths and Stats 44 Two Dimensional DFT This is a sum of a sum: Input x(kT, lT) transformed to X(ru,sv) N 1 N-1 X(ru, sv) = T x(kT, lT) exp (-j 2 (r k s l) / N) l=0 k=0 eg 2D Rect Pulse Response is 2D sinc pulse, found by sinc(u)*sinc(v) 17/07/2015 SEMMA13 Eng Maths and Stats 45 Fast Fourier Transform FFT DFT involves (N-1)2 multiplications and N(N-1) additions FFT has log2(N)*N operations, but N must be power of 2. To illustrate consider four initial samples x0 transformed to x2 This is done by transforming x0 to x1 and then x1 to x2 as illustrated by the ‘butterfly’ figure Value in node at end of dashed line = value in node at start of dashed line + value in node at start of solid line * e-j2q/T q is value written in node and T = 2N Eg x1(0) = x0(0)+x0(2) e-j20/4 = x0(0)+x0(2) x2(1) = x1(0) + x1(1) e-j22/4 17/07/2015 SEMMA13 Eng Maths and Stats 46 It can be shown that x2(0) = x0(0) + x0(1) + x0(2) + x0(3) x2(1) = x0(0) - x0(1) + x0(2) - x0(3) x2(2) = x0(0) + jx0(1) + x0(2) - jx0(3) x2(3) = x0(0) - jx0(1) + x0(2) + jx0(3) But applying the DFT formula X(0) = x0(0) + x0(1) + x0(2) + x0(3) X(v) = x0(0) + j x0(1) - x0(2) - j x0(3) X(2v) = x0(0) - x0(1) + x0(2) - x0(3) X(3v) = x0(0) - j x0(1) -- x0(2) + j x0(3) Hence X(0) = x2(0), X(v) = x2(2), X(2v) = x2(1) and X(3v) = x2(3) In general X(pv) = x2(q) where binary p is the binary q reversed eg 2 = 10, reversed is 01 = 1 17/07/2015 SEMMA13 Eng Maths and Stats 47 In general In each operation, ‘pairs’ of nodes in one level are processed from pairs of nodes in the prev level. Sets of such pairs exist, which share the same q value When transforming from xL-1 to xL, • there are 2L-1 sets of 2T-L consecutive pairs, where a set contains nodes with the same q value • In each set, the pairs are separated by 2T-L nodes. • The q value of the first node in the s'th set is the bit reversal of 2*s; the q value in the second node in the pair is this number plus 2T-1. In final level, need to reorder nodes by bit reversing q values 17/07/2015 SEMMA13 Eng Maths and Stats 48 Laplace Transform The Laplace Transform is introduced as a means of modelling systems and solving differential equations for the time response of systems. Its relationship with Fourier Transforms will be considered later. First consider the RC circuit below, first introduced in calculus. RC circuit, At time 0, battery E volts connected, when V = 0 RC Instead of writing dV d we write sV, s meaning dt dt Hence RCsV + V = E or V = E * 17/07/2015 dV +V=E dt 1 1+sRC SEMMA13 Eng Maths and Stats 49 Continued V=E 1 1+sRC Means Output V = Input E * System Transfer Function A transfer function defines how input transferred to output Strictly, as the transfer function is a function of s, V and E should be also 1 V(s) = E(s) 1+sRC Here we are in the Laplace domain, s being the Laplace operator Generally V and E are functions of time, and we want to know how V varies with time, So we want to transform from Laplace to the time domain. Note signals are assumed to be 0 when t < 0 17/07/2015 SEMMA13 Eng Maths and Stats 50 Three Useful Transforms At this stage we will define the transformation for a few signals. 1 if t 0 u(t) is the unit step function, being 0 if t < 0 1 U(s) is the Laplace transform of u(t) being s Exponential function, u(t) e - t Laplace transform of this is 1 s+ Impulse, (t) is pulse of area 1, width 0 and time 0, 0 elsewhere Laplace transform of this is 1 NB if X(s) transforms to x(t), Y(s) to y(t), then X(s) + Y(s) transforms to x(t) + y(t). For constant k, k*X(s) transforms to k*x(t) 17/07/2015 SEMMA13 Eng Maths and Stats 51 Applied to Circuit V(s) = E(s) 1 1+sRC Switch closed at t = 0, so E is in effect 0 before t = 0, and E afterwards E s E 1 So V(s) = s 1+sRC We want E(t), but don’t know how to transform back. Therefore input is a step, so E(s) = However, can use partial fractions 17/07/2015 SEMMA13 Eng Maths and Stats 52 Continued E 1 A B = + s 1+sRC s 1+sRC E 1 A(1+sRC) Bs = + s 1+sRC s(1+sRC) s(1+sRC) V(s) = Equating numerators : E = A + sRCA + Bs Equating coefficients of s, E = A and 0 = RCA + B Hence A = E and B = -RCE V(s) = E ERC E E = s 1+sRC s s+ 1 RC We can transform to functions of time for both of these V(t) = u(t) E - Ee 17/07/2015 - t RC Same as found by solving ODE, except here include u(t) SEMMA13 Eng Maths and Stats 53 Formal Transform Formally there are transforms from t to s and s to t, just as there are from t to f and f to t in Fourier Transforms F(s) = f(t)e stdt 0 1 st f(t) = F(s)e ds 2 j - From these integrals the rules given earlier are clear if X(s) transforms to x(t), Y(s) to y(t), then X(s) + Y(s) transforms to x(t) + y(t). For constant k, k*X(s) transforms to k*x(t) Note, time signals are in effect assumed to be multiplied by u(t) as the F(s) integral is from time t = 0. 17/07/2015 SEMMA13 Eng Maths and Stats 54 Applying the integral Consider exponential f(t) = Ke-at NB, strictly this is u(t) Ke-at as signal 0 before t = 0 -at st st F(s) = Ke e dt = f t e dt = Ke-(s a)tdt 0 0 0 -(s a)t K = sa e 0 = sK a 0 1 = sK a So if f(t) = K e -at then F(s) = K sa Process reversible, if F(s) is K , then f(t) is Ke-at sa K If a = 0, f(t) = u(t)K e 0 = u(t) K a step of height K, so F(s) = s 17/07/2015 SEMMA13 Eng Maths and Stats 55 Laplace Transform of sin(ωt) It is tricky to do this, as the integral of e-st * sin(ωt) is awkward. It is however made easier using complex numbers, and we can find the transform of cos(ωt) as well as sin(ωt) K We know if f(t) = K e -at then F(s) = ; what if a = j ? s+a So if f(t) = K e -j t = K(cos( t) - jsin(t)) then F(s) = K(s-j ) K Ks K = = -j s j s2 2 s2 2 s2 2 Equating real and imaginary parts K cos( t) transforms to K sin( t) transforms to 17/07/2015 SEMMA13 Eng Maths and Stats Ks s2 2 K s2 2 56 RC Circuit and Sinusoid For the RC circuit, suppose E is E sin(t). Then we can say that: V(s) = 1 E 1 sRC s 2 2 Again, this is re-arranged slightly and then put into partial fractions: 1 E A Bs C RC RC = = 2 2 2 2 1 1 s s 2 2 s 1 s s s RC RC RC It can be shown that: V(s) = V(s) = So: E ERC E ERCs ERC ERCs E = 2 2 2 2 2 2 s 1 s 1 s s s RC RC -t V(t) = ERC e RC ERCcos( t) E sin (t) 17/07/2015 SEMMA13 Eng Maths and Stats 57 Initial Conditions In the above, it is assumed that the output is 0 at time 0. This may not be the case. Formally, for a function f(t), whose differential is f’(t), whose value at time 0 is f(0), and whose Laplace Transform is F(s), then The Laplace Transform of f'(t) = s F(s) - f(0) For the RC Circuit, where V = V0 at time 0 RC dV +V=E dt Is transformed to So 17/07/2015 RC(sV - E0 ) + V = E RCE0 1 V(s) = E(s) 1+sCR 1+sCR SEMMA13 Eng Maths and Stats 58 If E(s) is a Step of Height E V(s) = RCE0 E+sRCE0 E 1 A B = = s 1+sCR 1+sCR s(1+sCR) s 1+sCR Getting all over a common denominator and equating numerators E+sRCE0 = A(1+sCR) Bs Equating coefficients of s E = A and RCE0 = ACR B V(s) = E RCE0 -ECR E E0 -E = s 1+sCR s s+ 1 CR -t V(t) = u(t) E E0 -E e CR 17/07/2015 SEMMA13 Eng Maths and Stats 59 Transform Table f(t) F(s) f(t) F(s) (t), unit impulse 1 sin(ωt) u(t), unit height step 1 s 1 cos(ωt) s2 + 2 s e- tsin(ωt) n! e- tcos(ωt) (s+ )2 + 2 s+ 1 s+ 1 sinh (t) t, unit ramp tn e- t e17/07/2015 s2 sn 1 t t (s+ )2 cosh (t) SEMMA13 Eng Maths and Stats s2 + 2 (s+ )2 + 2 s2 - 2 s s2 - 2 60 Second Order Systems The same idea is extended for second order systems For zero initial conditions d2O dt2 becomes s2O d2O dO 9 2 So 0.01 + + 9O = 9 becomes 0.01s O + sO + 9O = 2 dt s dt Hence O(s) = 9 s(0.01s2 + s + 9) For non zero initial conditions, need initial values of f(t) and f’(t), then Transform of f''(t) = s2F(s) - s f(0) - f'(0) 17/07/2015 SEMMA13 Eng Maths and Stats 61 Solving This Example O(s) = 9 s(0.01s2 + s + 9) = 9 A B C = + + s(0.1s + 1)(0.1s + 9) s 0.1s+1 0.1s+9 Getting all over a common denominator and equating numerators 9 = A(0.01s2 +s+9) + B(0.1s2 +9s) + C(0.1s2 +s) Equating coefficients of s 9 = 9A; 0 = A + 9B + C; 0 = 0.01A + 0.1B + 0.1C Hence A = 1, B = -0.9/8 and C = 0.1/8 1 0.9/8 0.1/8 1 9/8 1/8 O(s) = + = + s 0.1s+1 0.1s+9 s s+10 s+90 O(t) = 1 17/07/2015 9 -10t 1 e + e-90t 8 8 SEMMA13 Eng Maths and Stats 62 Underdamped Example d2O dO 0.25 + + 10O = 10 2 dt dt O(s) = 10 2 0.25s + s + 10 O(s) = 10 s 0.25s2 + s + 10 = s A Bs+C s 0.25s2 + s + 10 Can show 10 = 0.25s2 + s + 10 A + Bs2 + Cs, so A = 1, C = -1, B = -0.25 O(s) = 1 0.25s+1 1 s+4 1 s+2 2 = = s (0.5s+1)2 + 32 s (s+2)2 + 62 s (s+2)2 + 62 (s+2)2 + 62 O(t) = 1 - e-2t cos(6t) - 17/07/2015 1 -2t e sin(6t) 3 SEMMA13 Eng Maths and Stats 63 Critically Damped Example 1 d2O dO 1 2 9 + + 9O = 9 s + s + 9 O(s) = 36 dt2 dt s 36 O(s) = 9 9 = = 324 = A B C + + s s + 18 s + 18 2 2 s s s +18 2 s + 3 6 Can show 324 = s2 + 36s + 324 A + Bs2 + 18Bs + Cs 1 2 s s +s+9 36 So A = 1, B = -1 and C = -18 O(s) = 1 1 18 s s+18 s + 18 2 O(t) = 1 - e-18t - 18te-18t 17/07/2015 SEMMA13 Eng Maths and Stats 64 Some Theorems Initial Value : f(0) = lim f(t) = lim s F(s) t 0 s Final Value Theorem f() = lim f(t) = lim s F(s) t s 0 1 Suppose system has step input and transfer function G(s). s G(s) Output is , so steady state value is s G(s) lim s = lim G(s) s s 0 s 0 17/07/2015 SEMMA13 Eng Maths and Stats 65 Continued First Shift : if f(t) F(s), for constant , f(t) e- t F(s+ ), As sin( t) s2 + 2 , therefore e - t sin(t) (s+ )2 + 2 Second Shift : if f(t) F(s), for constant , f(t- ) e-s F(s+ ) 1 -2s e s 1 Hence a unit pulse of 2 secs is u(t) - u(t-2) (1-e-2s ) s So a unit step starting at t = 2, is u(t-2) T If f(t) has period T, F(s) = * e-st f(t) dt 1-e-sT 0 1 17/07/2015 SEMMA13 Eng Maths and Stats 66 Impulse Response / Convolution For System with input I, output O and transfer function G O(s) = G(s) x I(s) If I is a unit impulse, then I(s) = 1, so O(s) = G(s) Hence, in the time domain o(t) = g(t) The Transfer function (in time domain) is also Impulse Response Re Fourier Transforms it was noted that if two functions are multiplied in the Fourier domain, there time domain functions are convolved. This is true also of Laplace. Hence, as O(s) = G(s) x I(s) So 17/07/2015 t o(t) = g(t) i(t) = g(t-q) i(q) dq 0 SEMMA13 Eng Maths and Stats 67 On s, jω, etc s can be used to represent differentiation wrt t The inverse of differentiation is integration So integration can be represented by 1/s For a capacitor of capacitance C, the voltage across it V, due to the current through it I is V(t) = V(s) 1 = ; I(s) sC 1 I(t) dt C or V(s) = 1 I(s) sC 1 is the transfer function of the capacitor sC This is also the impedance of the capacitor 17/07/2015 SEMMA13 Eng Maths and Stats 68 Applied to the RC Circuit Here the resistor has impedance R, the capacitor impedance 1/sC The relationship between V and E can be found by the potential divider rule, being impedance of C divided by that of C + that of R 1 V(s) 1 sC = = 1 E(s) sCR + 1 R+ sC This confirms the result already quoted 17/07/2015 SEMMA13 Eng Maths and Stats 69 When signals are sinusoids 1 1 cos(t ) sin(t )dt = C C 1 1 But cos(t ) = sin (t ) 2 C C If I(t) = sin(t ), V(t) = The output is a sinusoid shifted by –π/2 rads scaled by 1/ωC 1 1 But has modulus and argument - rads j C C 2 So for sinusoid signals 1 j C is the transfer function of the capacitor Hence s and jω are interchangeable, so for RC circuit V(j ) 1 = E(j ) jCR + 1 17/07/2015 SEMMA13 Eng Maths and Stats 70 On Steady State and Transient It should be noted that the output is a scaled/shifted sinusoid under steady state conditions only. This provides the easiest way of finding the steady state sinusoid If input is sin( t), system is 1 , output is jCR + 1 1 1 sin t = jCR + 1 jCR + 1 1 1+2C2R2 sin(t tan 1 CR) The transient response is found by modelling the system using s, and processing that… 17/07/2015 SEMMA13 Eng Maths and Stats 71 Time Response using FT Replacing by 2 f, Transfer function of RC circuit is Fourier Transform of battery (step input) = 1 j2 fCR + 1 E E (0) j2 f 2 1 (0) 1 1 1 E (0) V(f) = E =E j2 f 2 1 j2 fRC j2 f 1 j2 fRC 2 As impulse is 1 only at f = 0, when transfer function is 1 V(f) = E (0) 2 E ERC (0) E E =E j2 f 1 j2 fRC 2 j2 f 1 j2 f -t Taking Inverse Transform v(t) = E - Ee RC 17/07/2015 SEMMA13 Eng Maths and Stats RC Most people use Laplace though! 72 Z Transform Laplace Transform can be used for continuous signals, but often computers process signals, in which case they are sampled For these it is easier to use the z-transform Differential Equations then become Difference Equations. Sampling is usually done at regular intervals, 0, T, 2T, etc The sampled signal at one such time is in effect the value of the continuous signal multiplied by an impulse at that time The impulse at time nT is (t-nT) If the continuous signal is f(t), the sampled signal at the nth sampling instant is given by f[n] = f(nT) * (t-nT) A series of samples of a signal are termed a sequence 17/07/2015 SEMMA13 Eng Maths and Stats 73 Z operator and Transform The z operator defines relationship between signal at one instant and the next: z f[n+1] = f [n] or f[n+1] = z-1 f[n] The z transform of a sequence, F(z), is defined as F(z) = f[n]z-n n=0 Unit step signal, f[n] is 1 for all n 0, so its z transform is -n 1 F(z) = z = 1 z 1 z 2 z 3 z 4 .... = 1-z-1 n=0 Sampled exponential signal e-at, at sample n has value e-anT -an -n 1 F(z) = e z = 1 e-az 1 e-a2z 2 e-a3z 3 .... = 1 a n 0 1- ze 17/07/2015 SEMMA13 Eng Maths and Stats 74 Z Transform Table f(t) F(s) f(t) [n], impulse 1 sin(an) u[n], step a-n n 1 1 1 1-z-1cos(aT) cos(an) 1-2z-1cos(aT) z-2 1-z-1 1-z 1e-aT 17/07/2015 z-1sin(aT) 1-2z-1cos(aT) z-2 e- nsin(bn) 1 z 1 a T e- F(s) z-1e-aT sin(bT) 1-2z-1e-aT cos(aT) z-2e-2aT e- ncos(bn) 1-z-1e-aT cos(bT) 1-2z-1e-aT cos(aT) z-2e-2aT SEMMA13 Eng Maths and Stats 75 On Modelling Systems In s-domain, a system with input I, output, O and transfer function H: O(s) = H(s) * I(s) e.g. For a first order system, H(s) = K 1+sT Can form differential equation of O(t) and I(t): T dO +O=I dt In z-domain, functions are of z (or z -1 ): O(z) = H(z) * I(z) For a first order system, H(z) = az-1 1 - bz-1 Can rearrange into difference equation in sampled signals O[n] and I[n] O[n](1 - bz-1 ) = az-1I[n] or O[n] = a I[n-1] + b O[n-1] 17/07/2015 SEMMA13 Eng Maths and Stats 76 Second Order System az 2 H(z) = 1 bz 1 cz 2 This can be rearranged as: (1 - bz-1 - cz-2 )O[n] = a z 2 I[n] Hence Or 17/07/2015 O[n] - bO[n-1] - cO[n-2] = a I[n-2] O[n] = a I[n-2] + bO[n-1] + cO[n-2] SEMMA13 Eng Maths and Stats 77 Properties of Z Transform Assume f[n] transforms to F(z), g[n] to G(z) and c is a constant. c f[n] transforms to c F(z) f[n] + g[n] transforms to F(z) + G(z) The first shift theorem : for delayed signal: f[n+k] transforms to zk F(z) – (zk f[0] + zk-1 f[1] + .. + z f[k-1]) For k = 1, this becomes f[n+1] transforms to z F(z) – z f[0] For k = 2, this becomes f[n+2] transforms to z F(z) – z2 f[0] – z f[1] Similar to the differential properties of the Laplace transform: Laplace transform of f’(t) = sF(s) - f(0) Useful for handling the cases where initial conditions are not zero. 17/07/2015 SEMMA13 Eng Maths and Stats 78 Initial and Final Values For s domain Final Value is o() = lim o(t) = lim sO(s) t s 0 For z domain similar, except z tends to 1 not 0 o() = lim o* (t) = lim (1-z-1 )O(z) t z 1 In s-domain to find steady state value to unit step input, set s to 0 in system transfer function. In z-domain, therefore, set z to 1 in its transfer function For initial value, providing limit exists: o(0) = lim o* (t) = lim O(z) t 17/07/2015 z SEMMA13 Eng Maths and Stats 79 First Order Step Response For the RC circuit, the step response is of the form V = E – E e-t/RC. The transfer function has steady state gain of 1. Lets do z equivalent Assume Circuit modelled by H(z) = (1 - b)z-1 1 - bz 1 As input is step size E, O(z) = H(z) I(z) = Using Partial Fractions O(z) = A 1 - bz 1 1 - b z-1 [NB this is 1 if z = 1] E 1 - bz 1 1 - z 1 B 1 - z 1 Hence E(1-b)z 1 = A - Az 1 + B - Bbz 1 . Hence A = -E and B = E Hence O(z) = E 1 - z 1 E 1 - bz 1 so O[n] = E - Ebn If assume b = e-a, then O of form E – Ee-an 17/07/2015 SEMMA13 Eng Maths and Stats 80 Solving First Order Difference Eqn For H(z) = (1 - b)z-1 1 - bz 1 , O[n+1] - bO[n] = (1-b)I[n] To solve, follow similar procedure to linear differential eqn. Set RHS to zero, then form auxilliary equation, where O[n+r] = mr. Each root means transient response has term k * rootn: So O[n+1] – b O[n] = 0 m1 – b = 0, the root of this is m = b Hence, the transient solution is O[n] = k bn. For steady-state, if I[n] is a constant E, so O[n] = C This must be solution of difference equation O[n+1] - bO[n] = C - b C = (1-b) E, so C = E Complete solution is O[n] = E + k bn : Can show k = -E if O[0] = 0 17/07/2015 SEMMA13 Eng Maths and Stats 81 For Second Order Again have over-, critically- and under-damped responses Transient resp depends on roots of auxilliary equation: If characteristic eqn is (m-a)(m-b) = 0, O[n] = k1 an + k2 bn O[n] = k1 e-cn + k2 e-dn if a = e-c etc If characteristic eqn is (m-a)2 = 0, O[n] = (k1 + k2n) an If characteristic eqn has complex roots are r O[n] = rn (k1 cos(n ) + k2 sin(n )) 17/07/2015 SEMMA13 Eng Maths and Stats 82 Relating s and z Laplace Trans of delayed impulse, (t-nT), is 1 shifted by nT = e-nTs At the nth sampling instant, a sampled signal is (t-nT)f(nT) -nTs Then f(nT) is constant, so its Laplace transform is: f(nT) e Overall the sampled signal is f(nT) t-nT n 0 -nTs Whose Laplace Transform is f(nT)e = f[n]e-nTs n 0 n 0 But the z transform of f[n] is F(z) = f[n]z-n n=0 These must be equal, so z = eTs 17/07/2015 SEMMA13 Eng Maths and Stats 83 Other Mappings s to z Derived by approximating integral of a sampled signal = area: At an instant, area = prev area + extra are due to next sample 1 1 1 1 f[n] = f[n-1] extra area or f[n] = f[n]z -1 extra area s s s s In Euler Integration, extra area is f[n]*T 1 f[n] (1 - z-1 ) = f[n] *T s 1-z-1 s= T Trapezoidal Integration 1 f[n]+f[n-1] f[n] (1 - z-1 ) = *T s 2 2 1 z-1 s= T 1 z-1 17/07/2015 Tustin’s Rule SEMMA13 Eng Maths and Stats 84