Amplitudine Discrete time systems (sampling data systems) Theoretical aspects Sampling theorem (Shannon s theorem) : Discretizing continuous time systems: Zero Order Hold element (zoh) Aims Obtain sampling data systems starting from the continuous time systems; Discretizing continuous transfer functions using Matlab tools; Simulate the time response of discrete time systems: step response, impulse response, ramp response and the time response to a sine wave of amplitude. 3 Establish the sampling period (Ts) When Shannon theorem is not respected, it will appear false frequencies inducing aliasing and folding effects. In the next graphic it can be seen the aliasing effect. x(t)=cos( ft) f=hz f=9hz f=hz - - - - -..3.5.7.9 timp (sec.) Figura Fenomenul de aliasing When dealing with sampling data control systems, the sampling period must be enough higher to assure not only data sampling and reconstruction but other different task like arithmetic calculations, memory allocation, etc. The sampling period will appear in the discrete (pulse) transfer function as a parameter.
Amplitudine To obtain correctly the behaviors of a discrete system (in comparison to the initial continuous time one, the sampling period must be connected to the time constants of the continuous transfer function. Having the continuous transfer function as a ratio of polynomials expressed by products of firs and second order terms: The sampling period value must be strictly smaller than the highest time constant in the considered transfer function: In practice, the sampling period is established times smaller than the highest time constant, or the smallest period of the input signal. When the sampling theorem is not respected, bad occurrence the real behavior is detected (figure )..8.6 Raspuns la treapta el. de ord. II el de ord. I.4..5.5.5 3 3.5 4 4.5 5 timp (sec.) (seconds) Figure Incorrect sampling vs. the continuous time response 4 Discrete time signal representation in Matlab To graphically represent sampled signals the suggestion is to use the stem function in Matlab. To put in evidence the sampled and reconstructed signal, use the Matlab function stairs; Became familiar with the use of the two functions (access Matlab help) and elaborate a Matlab script in order to obtain the next graphical representations in Figure 3.
Amplitudine - - - - stairs vs. stem stairs stem -..3.5.7.9 timp (sec.).5 -.5 -..3.5.7.9.5 -.5 esantioane -..3.5.7.9.5 -.5 de esantioane de esantioane -..3.5.7.9 Figura 3 Funcţia stem şi stairs din Matlab %% figura 3 f=; % frecventa semnalului n=; % numar de esantioane Te=/f/n ; % perioada de esantionare t=:te:; % timpul de simulare esantionat cu Te x=cos(*pi*f*t); % functia cosinus de frecventa f subplot(3,,[,3,5]); stem(t,x);hold;stairs(t,x,'r');hold;% comparatie stem vs stairs legend('stem','stairs'); title('stem vs. stairs'); ylabel('cos(\pift)');xlabel('timp (sec.)') Te=/f/;% de esantioane Te3=/f/;% de esantioane t=:te:;t3=:te3:; x=cos(*pi*f*t);% semnal cu de esantioane pe o perioada x3=cos(*pi*f*t3);% semnal cu de esantioane pe o perioada % se reprezinta grafic semnalele subplot(3,,);stem(t,x);title(' esantioane'); subplot(3,,4);stem(t,x);title(' de esantioane'); subplot(3,,6);stem(t3,x3);title(' de esantioane'); 3
5 Discretizing the transfer function in Matlab There are two functions available to discretize transfer functions in Matlab: a) cdm (continuous to discrete method, the old version) The function syntax is as follows: [nz,dz]=cdm(nc,dc,te, metoda ) - nz and dz (output parameters) the nominator and denominator of the discrete transfer function; - nc and dc are the nominator and denominator of the continuous transfer function; - Te is the sampling period - metoda represents the discretizing method with the following values 'zoh' Convert to discrete time assuming a zero order hold on the inputs. foh' Convert to discrete time assuming a first order hold on the inputs. 'tustin' Convert to discrete time using the bilinear (Tustin) approximation to the derivative. 'prewarp' Convert to discrete time using the bilinear (Tustin) approximation with frequency prewarping. Specify the critical frequency with an additional argument, i.e cdm(a,b,c,d,ts,'prewarp',wc) 'matched' Convert the SISO system to discrete time using the matched pole-zero method. b) cd (continuous to discrete) This alternative of discretizing offers the possibility of working directly with transfer function objects. The function syntax is quite similar to the old one: sist_discret=cd(sist_continuu,te, metoda ) - in addition to the methods presented at the previous function, in this case it is available also: o imp (based on impulse response invariance) 6 Dynamic behaviors for discrete time systems After mapping the left half plane s into the z plane through the transformation, the theoretical results can be extended to the step response type (overdamped, critically damped, underdamped, undamped) depending on the pole location - the real and negative axis (from s plane) is mapped into real, positive and under unity axis in the z plane (having only positive and under unity real poles, the overdamped case will occur); - the content of the primary strip is mapped inside the unity circle in the z plane ( having at least one pair of complex conjugated poles inside the unity circle, the underdamped case will occur); - the imaginary axis from the s plane is mapped into the z plane exactly on the contour of the unity circle (having at least one pole situated on the unity circle, the system is only simple stable) for one pole in =, step response will be a ramp for a pair of complex conjugated poles on the unity circle, the undamped case will occur; - for the case when at least one pole of the pulse transfer function in situated outside the unity circle, the discrete system is unstable. 4
7 Solved problems For the continuous time system with the transfer function. Obtain the pulse transfer function using the zero order hold element. Hc=tf(5*[ 4],conv([ ],[ 3])); Te=max([/,/3])/;% establish sampling period Hd=cd(Hc,Te,'zoh'). Obtain the pulse transfer function as a ratio of polynomials expressed as products of first and second order; then the poles and zeros of the transfer function can be observed; for this case, the transfer function singularities (all real and negative) results after discretizing on the real and under unity axis. zpk(hd) 3. Modify the number representation format from default (4 decimals) into the long format (6 decimals) and reconsider the values of the pulse transfer function coefficients. format long [num,den]=tfdata(hd,'v') 4. Make the comparison between the step response from continuous and discrete time systems. Notice the stairs of the discrete time response that can be increased by increasing the sampling period. Step(Hc,Hd); legend('hc','hd') 5
3.5 Step Response Hc Hd 3.5.5.5.5..5..5.3.35.4.45.5 5. Represent the step response of discrete time systems by discrete values and not by constant stairs. The syntax for the step function is the same as the one for the continuous case; when calling the step function with output parameters, there will no longer be a graphical representation but a memory allocation in order to make additional computations on the numerical response. [y,t]=step(hd); step(hc);hold;stem(t,y,'r');hold legend('hc','hd'); 3.5 Step Response Hc Hd 3.5.5.5.5..5..5.3 6. Compare the step response for the cases when the transfer function coefficients are rounded to the first 4 decimals, respectively to the first decimals. 6
Hd4=tf([ 3 -.9],[ -.7634.7769],Te); Hd3=tf([ 3 -.9],[ -.763.776],Te); Hd=tf([ 3 -.9],[ -.76.77],Te); step(hd,hd4,hd3,hd);shg legend('5 zecimale','4 zecimale','3 zecimale',' zecimale') 4 3.5 Step Response 5 zecimale 4 zecimale 3 zecimale zecimale 3.5.5.5...3.4.5.6.7.8 7. Make a function script in order to represent graphically the poles and zeros of the pulse transfer function together with the unity circle; call the function script with one parameter represent(hd), where the parameter is the pulse transfer function. function []=reprezentare(hd) x=:.:*pi; plot(sin(x),cos(x),'r');% cercul de raza unitate [num,den]=tfdata(hd,'v'); poli=roots(den); zerouri=roots(num); hold; plot([ ],[-..],'--k',[-..],[ ],'--k') plot(real(poli),imag(poli),'x','markersize',6); plot(real(zerouri),imag(zerouri),'o','markersize',6); title('') axis([-.. -..]) hold;shg 7
^z =.9484 ^z = 5866 z _ = 58 - - - - - - - - - - 8. Compare the pulse transfer functions obtaing after discretizing the next continuous transfer functions with the specified sampling period: sampled with and sampled with clear all;clc Hc=tf(5*[ 4],conv([ ],[ 3]));Te=/; Hc=tf(5*[ 4],conv([ ],[ 3]));Te=/; Hd=cd(Hc,Te,'zoh') Hd=cd(Hc,Te,'zoh') Notice that both pulse transfer functions have the same coefficients; the difference is made only by the sampling period. 8
8 Problems to be solved. Reconsider the solved problems for the case of a second order transfer function with complex conjugated poles:. Make a matlab script divided in sections in order to understand the connection between the poles locations and the behavior of the system (for the step response) ----------------- (z-.95) (z-.75) 8 7 6 Regim aperiodic amortizat ^z =.95 ^z =.75 Sample time:. seconds Discrete-time zero/pole/gain model. 5 4 3 - - - - - 5 - -.5.5 H = ------------------- z^ -.9 z +.95 6 5 4 Regim oscilant amortizat ^z =.95+.5i ^z =.95-.5i Sample time:. seconds 3 - roots([ -.9.95]) - - - ans =.95 +.5i.95 -.5i.5 - - -.5.5 9
H = ----------------- z^ -.86 z + 8 Regim oscilant intretinut ^z =.995+ 88i ^z =.995-88i Sample time:. seconds >> roots([ -.86 ]) 6 4 - ans = - -.93 + 8i.93-8i -..3 - - - -.5.5 ----- z - 9 Limita de stabilitate Sample time:. seconds 8 7 ^z = 6 5 4 3 - - - - -.5. - -.5.5 ---------------------- z^ +.795 z +.64 Sample time:. seconds roots([.795.64]) ans = 3 - Regim oscilant neamortizat - - ^z = -.3965+.954i ^z = -.3965-.954i -.396 +.954i -.396 -.954i - - - - -3.5.5 - -.5.5
9 References []. Hăngănuţ Marius. Teoria Sistemelor. vol. II, Ed. Univ. Tehnice din Cluj-Napoca (996). []. Kuo, Benjamin C. Automatic control systems. Prentice Hall PTR, 98. [3]. Leonard, Naomi Ehrich, and William S. Levine. Using MATLAB to analyze and design Control Systems. Benjamin-Cummings Publishing Co., Inc., 995. [4]. Nise, Norman S. Control systems engineering, (With CD). John Wiley & Sons, 7. [5]. Ogata, Katsuhiko, and Yanjuan Yang. Modern control engineering. Prentice Hall, 97.