Professional Documents
Culture Documents
Prepared by:
Prepared for:
October 2010
Submitted to the Department of Electrical Engineering at the University of Cape Town in partial fulfilment of the academic requirements for a Bachelor of Science degree in Mechatronics
Declaration
1. I know that plagiarism is wrong. Plagiarism is to use another's work and pretend that it is one's own. 2. I have used the IEEE convention for citation and referencing. Each contribution to, and quotation in, this thesis report from the work(s) of other people has been attributed, and has been cited and referenced. 3. This thesis report is my own work. 4. I have not allowed, and will not allow, anyone to copy my work with the intention of passing it off as their own work or part thereof
Name: Signature:
Acknowledgements
I would like to express thanks and gratitude to the following for their help throughout the duration of my thesis Prof. Martin Braae for allowing me to do this thesis under his supervision. Mr Moholo Tseou Masters student, Chris Cecchini My parents for their love and support. All my friends for their encouragement and support, it has been much appreciated. Allah (SWT)
ii
Abstract
This thesis evaluates the role of Model Predictive Control (MPC) in controlling non-integral dead time processes. Specifically it looks at the movement of poles and zeros in the z-plane when applying a method in MPC known as General Predictive Control (GPC).
It is shown that when this method is applied to a non-integral dead time system, pole-zero cancellation occurs; also that when the value of lambda (the penalty constant of the GPC model) is varied the pole-zero cancellation is eliminated. It is also shown that in some cases for certain values of lambda this cancellation causes instability and ringing within the control system.
A range of values for lambda which give stability to the system for different values of theta is then given.
iii
Table of Contents
Ringing Poles in Model Predictive Control ........................................................................................................ 1 Prepared by: .................................................................................................................................................................. 1 Department of Electrical Engineering ..................................................................................................................... 1 Prepared for: ................................................................................................................................................................. 1 General Predictive Control, Non-Integral Dead Time ........................................................................................ 1 Declaration .....................................................................................................................................................................i Acknowledgements.................................................................................................................................................... ii Abstract ......................................................................................................................................................................... iii Table of Contents ....................................................................................................................................................... iv List of Figures .............................................................................................................................................................. vi 1. Introduction ......................................................................................................................................................... 1 1.1 1.2 Background to the study .......................................................................................................................................... 1 Objectives of this study............................................................................................................................................. 1
1.2.1 Problems to be investigated ......................................................................................................................... 1 1.2.2 Purpose of the study ........................................................................................................................................ 1 1.3 Scope and Limitations ............................................................................................................................................... 1 1.4 2. Plan of development .................................................................................................................................................. 1 Dead time processes and the z-transform ........................................................................................................ 2 Background and Literature Review ............................................................................................................ 2 2.1 2.1.1 Dead Time ............................................................................................................................................................. 2 2.1.2 z-Transform........................................................................................................................................................... 2 2.1.3 Modified z-Transform ....................................................................................................................................... 3 2.2 Model Predictive Control ......................................................................................................................................... 3 2.2.1 Generalized Predictive Control ....................................................................................................................... 4 2.3 Effect of dead time on GPC .......................................................................Error! Bookmark not defined. 3. Methodology ........................................................................................................................................................ 6 3.1 3.2 3.3 3.4 3.5 4. z-Transform................................................................................................................................................................... 6 General Predictive Control (GPC) Algorithm................................................................................................... 7 Check for Pole-Zero cancellation .......................................................................................................................... 8 Closed Loop Function ................................................................................................................................................ 9 Simulation ...................................................................................................................................................................... 9 First Order System................................................................................................................................................... 10 Advanced First Order (N=1) ................................................................................................................................ 13 Second Order System ............................................................................................................................................. 16
iv
4.4 5. 6. 7. 8.
Conclusions ........................................................................................................................................................ 21 Recommendations ........................................................................................................................................... 22 List of References ............................................................................................................................................. 23 Appendices ......................................................................................................................................................... 24 8.1 Appendix A.................................................................................................................................................................. 24 8.1.1 A.1. First Order System N=0 ...................................................................................................................... 24 8.1.2 A.2. First order system with dead time of N=1 .................................................................................. 29 8.1.3 A.3. Second order system with no pole ................................................................................................. 34 8.1.4 A.3.Second Order System with pole at ........................................................................................... 38 8.2 Appendix B - MATLAB CODE ............................................................................................................................ 40 8.2.1 B.1. First Order System ................................................................................................................................ 40 8.2.2 B.2. Advanced First Order N=1 ................................................................................................................. 41 8.2.3 B.3. Second Order System with no pole ................................................................................................ 42 8.2.4 B3. Second Order System with no pole ................................................................................................. 43 EBE Faculty: Assessment of Ethics in Research Projects ................................................................... 44
9.
List of Figures
List of Illustrations
Figure 4-1: Pole-Zero mapping for different values of theta........................................................................................... 10 Figure 4-2: Pole-Zero mapping with with varying lambda ......................................................................... 11 Figure 4-3: Pole-Zero map and Step Response with and .................................................. 12 Figure 4-4: Pole-Zero map for and varying.................................................................................................. 12 Figure 4-5: Pole-Zero map for Advanced First Order and varying theta ....................................................... 14 Figure 4-6: Ringing Poles ......................................................................................................................................................... 15 Figure 4-7: Pole-Zero map of second order system ...................................................................................................... 17 Figure 4-8: Pole-Zero map for second order with open loop pole.......................................................................... 19
List of Tables
Table 4-1: Theta-Lambda values which stabilise the closed loop ................................................................................. 13 Table 4-2: First Order System (N=1)................................................................................................................................... 16 Table 4-3: Theta values with corresponding lambda constraints .......................................................................... 18 Table 4-4: Values of theta and lambda that stabilise the system ............................................................................ 20
vi
1. Introduction
1.1 Background to the study
Model Predictive Control (MPC) is a powerful tool in the control toolbox, and is used extensively in the chemical industry. Over the years there have been a great many enquiries into General Predictive Control (GPC), as to its advantages and disadvantages as used in industry. This investigation deals with one of its disadvantages, namely, how GPC model deals with a plant with non-integral dead time. Previous studies have shown that when dealing with non-integral dead time, GPC tends to position a pole on the open loop zero of the system.[1]
1.2
1.2.1
1.2.2
The purpose of this thesis is to try and shed some light on what happens to the poles and zeros of a system with non integral dead time that is controlled by GPC.
1.3
This thesis specifically covers the investigation of lambda, the penalty constant of the cost function, and also the non-integral part of the dead time and how these constants interact with one another. Due to time constraints only simulation was done, and no actual experiments were carried out.
1.4
Plan of development
The investigation will start with a simple first order plant model. The value of the dead time as well as the value of lambda will then be varied and by using pole-zero maps as well as simulation a correlation between the variables would hope to be found with regards to the stability of the system. This will then be done for higher order systems to see whether there is a general relationship between the two variables.
A process exhibiting dead time is a process such that, every action in the input of the process will only affect the output after a certain time delay. This type of phenomena is in general bad for control systems, and can make them very difficult to control accurately.
The effect of dead time is difficult to control using standard controllers for the following reasons: The effect of disturbances is only felt after a considerable lapse in time The control action applied to the system is based on actual errors and tries to correct a situation that happened some time before The effect of the control action takes some time to be felt in the control variable [2] The dead time in the time domain is shown as thus any equations with given in the form . This corresponds to in the Laplace domain and
will have a dead time corresponding to . With real coefficients, and of the form
and where
is a polynomial in s having
numerator, if this were not the case the system would then be non causal. 2.1.2
z-Transform
The z-transform is the method used to study discrete time signals. It is the equivalent of the Laplace transform for continuous signals. The z-transform of a continuous function is defined by[3]
This definition of the z-transform is rarely used in practice as there are comprehensive z-transform tables which have been drawn up for a wide range of functions. We can see form the definition that the accuracy of the signal obtained from the z-transform is greatly dependant on (sampling time). Intuitively, it would then
make sense that the greater the sampling time, the better the z-transform and thus this would lead to better performance. This however, is not quite true. Other factors such as, the Nyquist sampling criteria and the dead time in the system would have to be taken into account.
The Nyquist sampling criteria is the minimum sampling criteria needed to avoid aliasing of the signal. To fulfil this criteria there are a number of ways of sampling the sampled, such as the Zero Order Hold (ZOH) and the First Order Hold (FOH). Both these methods help against problems associated with aliasing of the signals. The ZOH will be used for the calculations that form part of this thesis.
When taking the z transform of a function with dead time, it is important to check whether or not the dead time is a factor of sampling time. If the dead time is in fact a factor of the sampling time then the ztransform cam simply be taken, if not, the modified z-transform would have to be used.[4]
2.1.3
Modified z-Transform
The modified z-transform uses a fictitious delay in the sampling time that allows us to take the z-transform of the process; it is defined by [3]
As with the z-transform, the modified z-transform definition is rarely used, as there is a comprehensive list of modified z-transform tables for a wide variety of functions.
2.2
Model Predictive Control (MPC) is not a specific control strategy; it is a range of control methods which make use of a model of a process to obtain the control signal by minimising the cost/objective function. MPC makes use of a few main ideas, these are A prediction model to predict the process output at future time instances A calculation of the control sequence which minimises the cost function Receding horizon strategy[5] The different strategies that form part of MPC only differ from each other in the way the model is set up with the idea stated above. The strategy that this thesis uses is Generalizes Predictive Control (GPC).
2.2.1
The basic idea of GPC is to calculate a sequence of future control signals in such a way that it minimizes a multistage cost function defined over a prediction horizon.[5].
There are a number of ways of formulating the GPC model, such as those using Diophantine equations, Transfer Functions and State Space Models.[6] In each of these the controller is obtained by minimising the cost function which is given by
In this function
and
represent the penalty constants used to constrain the cost function. and represent the error (given by
and )
represent the control and prediction horizons respectively, and the incremental input.
When the cost function is minimised it yields the following controller, K. [7]
is
the matrix formed using the prediction model. The way in which G is formed is different depending on which of the methods one uses to formulate the GPC model. The size of these matrixes is determined by the denominator and numerator (transfer function method) or by the prediction horizon and the control horizon ( and ) of the system as chosen by the designer.
When using Diophantine equations, this matrix can be formed directly from the differential equations, the rows of the matrix are given by
Where
and
the product of the Hankel/Toeplitz[8] prediction matrixes which is taken from the prediction model. The prediction model is given by
and output,
and
are the
inputs and outputs. Using the future components of the prediction model the matrix
From the controller K the incremental control action is formed and is given by
Here
This control action is then applied to the system to produce the closed loop system. The closed loop system is now a function of lambda, thus depending on the value of lambda (penalty on the incremental input) the system would behave differently as will be seen later.
3. Methodology
The method employed in this thesis will be shown by using a first order system. The same method will then be applied to the systems of higher order. The first order system is taken due to its simplicity and it will be a good indication as to what to expect with regards to higher order systems when the same GPC algorithm is applied.
3.1
z-Transform
The system g(s) is taken as a polynomial in s multiplied by the dead time as discussed earlier. The first order system, g(s), is given by
Where
Tau () is the dead time and is broken up into two components, as shown above. The first term of the dead time term ( ) is the term that shows the exact delay, given as a factor of sampling time, while the second
term is the term which shows the non-integral part of this dead time.
For simplicity we will let A and T equal to 1, and take the case where the multiple of the dead time is equal to zero (N=0).
The z-transform of the system is taken, with zero order hold (ZOH) and with the sampling time equal 1 ( . Due to the non-integral dead time, the modified z-transform is then needed (as will be the case of
3.2
The GPC algorithm is now applied to the model. As discussed earlier, there are a number of ways of doing this. The method used here will be the transfer function method.
The first step in doing this is to obtain the CARIMA (Controlled Auto-Regressive Integrated Moving Average) model of the system and convert to negative powers of z
We now cross multiply and take the inverse z-transform of the system to convert the system into difference equations. The prediction model of the system is then taken, looking one step into the future. For this, both the prediction horizon (Ny) and control horizon (Nu) will equal to one. The reason for this choice of prediction and control horizons is firstly, choosing them as higher values would not impact on the area in GPC being investigated, and secondly, this choice of values greatly simplifies the calculations involved.
In the above equation the arrows above y and u are used to show whether the elements of the matrix refer to past or future values. The forward arrow indicates looking into the future, while the backwards arrow refers to the past inputs and outputs. The coefficients of these matrices are the Hankel/Toeplitz [8] matrices discussed earlier and are in this case given as
= C2 ) = C1
Where here
and
Also,
Where K corresponds to the first row of the matrix K (in this case K is a constant), trajectory and is the free response of the system and is given by
is the reference
3.3
Now what is needed is to check if there is in fact pole zero cancellation. To do this we need to check that the pole in the open loop function is the same as the zero for the closed loop function.
3.4
From the prediction model the closed loop function is formed and is given by
For the closed loop function we now have to test for stability with varying values of theta (the non integral dead time term) and lambda (the penalty constant of the cost function). This was done with the help of MATLAB.
3.5
Simulation
All simulations will be done using MATLAB. In MATLAB the closed loop function poles and zeros are plotted for varying values of theta and lambda. This would give an indication of whether or not the system was likely to be stable or unstable, and with or without ringing. It would also give indication as to what the settling time is or after how long it was expected that the ringing or instability would occur. From these plots the values of theta and lambda can then be determined for the system such that it is always stable.
4. Results
4.1 First Order System
The first order system has been explained in detail in the methodology, consequently all that will be done here is to plot the MATLAB graphs and simulate them in order to find the corresponding values of lambda and theta for ringing and instability as well as to see whether they correlate in any way. The full derivation of the GPC model for this system and the ones to follow can be found in appendix A, while the MATLAB codes used to plot the pole-zero maps and step responses can be found in appendix B.
The first thing noted about this first order system, is the movement of the open loop zero as the non-integral dead-time is varied from zero to a factor of sampling time. As this happens we find that the zero moves off to infinity. Figure 4-1 shows the pole-zero map of the closed loop transfer function for different values of theta with lambda equal to zero. The points on the graph where the rectangular boxes appear are of particular importance. These are the places at which the pole-zero cancellation for the different values of theta occur. It can be seen from here, that the closed loop zero follows the open loop pole to infinity as the dead-time comes closer to the sampling time.
to
for the lower values of theta, with the pole lying inside the unit circle, the system will be stable, but as soon as the pole leaves the unit circle, the pole-zero cancellation will most likely cause instability in the system.
10
The next step is to vary the value of the penalty constraint, lambda, in these uncertain regions of theta and to see what effect this has on the poles of the system. (It can be seen clearly from the closed loop equation that zero is not dependant on the value of lambda.)
In Figure 4-2 the pole-zero map for different values of lambda is shown. As can be seen when lambda increases from to the pole moves to inside the unit circle. For all values of lambda which
position the pole outside the unit circle, the system is expected to be unstable. Due to the fact that the pole is so close to the unit circle, the system may seem stable, but eventually becomes unstable after a relatively long period of time. Also because the pole is positioned on the left hand side of the z-plane ringing is expected in the output. This is shown in the figures that follow.
and
close to the unit circle it is seen in the step response that there is ringing and that it takes a substantial amount of time before the amplitude of the ringing increases significantly. For most control systems however, even if the ringing amplitude did not increase, this amount of ringing would be unsatisfactory. In order to stop the ringing all together, the value of lambda would have to increase significantly, however, once lambda is increased beyond a certain point the system then becomes unstable.
11
and
and
varying
12
As lambda increases the poles move through the z-plane, eventually, once lambda is greater than 0.7 the poles again move outside of the unit circle, as can be seen in Figure 4-4. Thus, it can be shown that for the system will only be stable for .
This same method can then be applied for different values of theta, giving the same basic result. For a given value of theta there will be a range of values of lambda for which the system will be stable, a few are shown in the Table 1 on the next page. The results shown are estimates which are dependant on pole positions, also some of the values of lambda shown do eventually stabilise but suffer from severe ringing, which most likely would make them unusable in normal control systems.
Theta
Lambda
4.2
This system is the same as the previous one but differs in that it has a standing dead time of between one and two sampling periods. The
to
transfer function. The same method of GPC is followed as before. The key point to note while applying the GPC algorithm is that the controller (K) has its first column as a zero column. This is expected as nothing has happened in the first time instance, so there is nothing to control. What is found after working through this system is that the exact same control law results as before, but it is applied one step in the future. This corresponds to the time delay of the system.
13
of which only the first row is used in the control action to compute the control law. From this we then check the characteristic function of the closed loop to see if there is in fact pole zero cancellation.
Setting lambda equal to zero we find that there is in fact a common factor in this equation and that it is equal to that of the open pole position. Thus pole-zero cancellation does occur. The closed loop transfer function is then given by
As expected there is an extra zero positioned at the origin. Now simulations are run as before to see the effect of varying the value of lambda and theta, also to see whether or not the extra zero at the origin has any affect on the system as well as to see how they differ from the results achieved in the simple first order case.
14
Figure 5 shows the Pole-Zero map for lambda equal to zero and different values of theta. The map is identical to the one plotted before. Theta is varied here from to . Once again it is seen that the
closed loop zero follows the open loop pole to infinity as theta varies.
The results of this system were almost identical to that of the system before. It was however interesting to note that for a given theta, any small change in lambda will cause the system to start ringing. This ringing will either become unstable or stable depending on the position of the pole. This small change in magnitude of lambda is of the nano-unit degree i.e. would be enough to cause this ringing in the system.
An example of this is shown in the figure 4-6. Here the step response is plotted for respectively.
15
The table for stability of the system for theta and corresponding lambda is now drawn.
Theta
Lambda
4.3
A second order system is now taken and the same procedure is applied as with the first order. The second order system has the following form
The reason for alpha and beta being as they are is that it gives us a system with ringing. This is part of the phenomenon being investigated. From here the system becomes
The z-transform of the system is now taken as before after which the GPC algorithm is applied to obtain the controller
16
It is noted to be the same form as the one for the first order system. Here are as defined above. Also , .
Here
are all constants. The full derivation and value of these constants is shown in the appendix.
It can be seen from the closed loop function that there once again pole-zero cancellation when the value of lambda is set as zero. The pole-zero map for the varying theta while setting lambda as zero is now plotted to give an indication of how the poles and zeros react to a change in the dead time of the system.
17
to
exactly as is expected, and as before, by varying the value of theta from 0 to 1 the pole of the open loop along with the zero of the closed loop runs from within the unit circle to infinity.
The table shows how lambda can vary for corresponding values of theta. However, it should be pointed out that the maximum value for each of these values of lambda is in fact infinity. The reason for the upper bounds in some of the cases is due to the settling time. The upper bounds placed on lambda would in fact give settling times of under 200 seconds. Also in the majority of cases in this table ringing is likely to occur.
Theta
Lambda
4.4
The exact system as before is taken, but this time a zero is added to see what effect this will have on the system. The system is given by
When this system is discretized using the z-transform with ZOH it is seen that the form is exactly that of the system without the pole, but varying by few constants. Thus the controller is once again given by
18
The pole-zero map for varying theta when lambda is set as zero is shown in Figure 4-8. This is the same as before, with the open loop zero being followed by the closed loop pole to infinity as theta runs from zero to one. It is also seen that pole-zero cancellation does also occur
Figure 4-8: Pole-Zero map for second order with open loop pole
19
The table for the values of lambda which stabilise the system for different values of theta is shown below. This system is seen to be stable for almost all values of lambda, although with the majority of cases ringing will occur.
Theta
Lambda
20
5. Conclusions
From the results above it can be seen that the GPC algorithm is well suited to dealing with the nonintegral dead time which forms part of certain control systems. However, it should be noted that care should be taken when varying the penalty constraint, lambda, which forms part of the cost function in the GPC algorithm. As the non-integral part of the dead time, theta, increases and comes closer to being a factor of sampling time, it is found that small changes in lambda will have a big impact on the system stability. Values of theta that allow the open loop pole to lie within the unit circle of the z-plane react to very small values of lambda. If lambda is increased to just above zero, (nano-units), then ringing can be expected in the system output. If the same value of lambda is applied to a system with theta high enough such that the zero lies outside the unit circle, the system will then be unstable. For these values of theta higher values of lambda are needed for stability.
21
6. Recommendations
The problem associated with non-integral dead time and ringing in control systems using the GPC algorithm can be substantially overcome by setting the penalty constant, lambda, of the GPC model to the correct value. Lambda has a great influence on the closed loop poles of the system and can thus offer great stability in the system. In order to investigate this matter further, attention should be applied to the input and output disturbance attenuation of these control systems with the non-integral dead-time.
22
7. List of References
[1] D.W.Clarke., "General Predicitve Control-Part 1. The Basic Algorithm." Automatica, 1987, pp. pp 137-148. [2] E.F.Camacho, J.E>Normey-Rico and., Control of Dead-time Processes. 2007. [3] E.I.Jury., Theory and Application of the z-Transform method. New York : Robert E. Kruiger Publishing Co., Inc., 1973. [4] M.Braae., Control Engineering - 2. s.l. : M.Braae, 2004. [5] E.F.Camacho., "Model Predictive Control." [book auth.] E.F.Camacho and C.Bordans. Model Predictive Control. 2007, pp. 47-60. [6] J.A.Rossiter., Model Base Predictive Control: A Practical Approach. s.l. : CRC Press, 2003. pp. 53-64. [7] M.Tseou., "EEE4093F - Model Predictive Control (MPC)." s.l. : Electrical Engineering Department Control and Instrumentation UCT, 2010. [8] Ying Xu, Bin Liu and Kang-ling Fang., "Generalized Predictive Control based on Toeplitz equation." 2008.
23
8. Appendices
8.1
8.1.1
Appendix A
A.1. First Order System N=0
For
In negative powers of z
CARIMA model
24
and C2 =
A=
and B =
) )
Formulating the prediction model with the prediction horizon set at 1, we get
25
So we have
= C1 ) = C2
The controller K is given by, where Q and R are penalty matrixes, for our purposes Q=1 and and .
If the prediction horizon were bigger all values would become matrixes
Where K corresponds to the first row of the matrix K (in this case K is a constant), trajectory and is the free response of the system and is given by
is the reference
Substituting, we get
This is now our closed loop function, whose characteristic equation is given by
26
Where S and R are taking from the control action equation put in the form
So
Here is where we see something interesting, if we let lambda () equal zero, K then reduces to
Thus
comes out as a closed loop pole, this is exactly the same position as the
open loop zero, and thus tends to cancel this zero, causing a potentially internally unstable system.
Now
27
And
28
8.1.2
Where
and N=1
In negative powers of z
and
and
CARIMA model
Where C1 =
and C2 =
29
and
30
With
Therefore
Now with
We put this in the form below to produce the elements of the equation of the closed loop function
31
From here it is not at first obvious, but with some quick manipulation it can be seen that when There is a common factor in the characteristic function; this common factor is at the exact position of the open loop zero.
, and is in the same position as the open loop zero. The difference between
this, the process with N=1, and the process discussed earlier, N=0, is that an extra zero is placed at the origin. Need to check what kind of effect this will have on the response of the system. The closed loop function is given by
32
--------------------------------------------------------------------
33
8.1.3
Here alpha and beta are chosen such that they give rise to ringing zeros for the system. Tau ( Thus we have And ) is chosen with N=0 and theta lying in between zero and the sampling time.
, and
and ,
becomes
Grouping terms
Let
34
In the form
From here
35
Controller
Substituting, we get
This is now our closed loop function, whose characteristic equation is given by
Where S and R are taking from the control action equation put in the form
36
From here it can be seen that putting lambda = 0, R & B are then identical, i.e. the closed loop pole lies directly on the open loop zero.
--------------------------------------------------------------------------------
37
8.1.4
And it follows that only the constants change, but the rest of the systems stays the same as the above calculation. The new system proceeds as follows The value of phi now becomes, where
The constant of 0.5 is absorbed into the numerator. Constants now change slightly to
38
In the characteristic function the values of A and R are double, thus we have
Once again with lambda equal to zero, the common factor exists!
39
8.2
8.2.1
%% First Order System clear clc tic %% Constants i = 1;HP=[];H2P=[];QZ=[]; z = tf('z'); %% for loop for different lambda and theta values for lambda = 0:0.5:7.5 theta = 0.; A1 = 1+exp(-1); A2 = exp(-1); C1(i) = exp(theta-1)-exp(-1); C2(i) = 1- exp(theta-1); K(i) = (C2(i)/(C2(i)^2+lambda));
%% Open Loop Transfer Function H(i) = (K(i)*z^2*(z.*C2(i)+C1(i)))/(K(i)*(z-1)*(z-A2)*(z+K(i).*C1(i))+(z*A1A2)*(z.*C2(i)+C1(i))); subplot(2,1,1) pzmap(H(i)) hold on subplot(2,1,2) step(H(i)) hold on % HZ(i,:) = pole(H(i)); % HZ3 = HZ(i,3) % HP(i,:) = pole(H); % % toc H2P(i,:) = pole(H2); QZ(i) = zero(Q); end
40
8.2.2
%% First Order System with N=1 clear clc i=1; z = tf('z'); %% for loop for different lambda and theta values for theta =0.9%:0.1:0.9 lambda = 02; C1(i) = exp(theta-1)-exp(-1); C2(i) = 1- exp(theta-1); K1 = (C2(i)/(C2(i)^2+lambda)); %% open loop is function % % % % % g = (z*C2(i)+C1(i))/((z^2)*(z-exp(-1))); pzmap(g) hold on subplot(2,1,1) step(g)
%% open loop is function f(i)= (K1*z^2*(z*C1(i)+ z^2*C2(i)))/((z^2+K1*(C1(i)+(exp(-1)+1)*C2(i))*z... +K1*(exp(-1)+1)*C1(i))*(z-exp(-1))*(z-1)+(K1*((exp(-1)+1)^2-exp(1))*z... -K1*exp(-1)*(exp(-1)+1))*(C1(i)+ z*C2(i))); subplot(2,1,2) pzmap(f(i)) hold on pole(f(i)) subplot(2,1,1) step(f(i)) hold on end
41
8.2.3
%% Second Order System with no pole clear clc %% Constants z = tf('z'); alpha = 0.5; s = tf('s'); beta = sqrt(0.75);
phi2 = atan((alpha+beta^2-0.5*alpha)/0.5*beta); sq = sec(phi2);%theta = 0.5 i=1;p=[]; %% Continous Function % gp = ((s+0.5)/((s+0.5)^2+0.75))*exp(-s*(theta)); % gjp=c2d(gp,1,'zoh') % step(gjp) %% for loop for different lambda and theta values for lambda = 0.025%.000:10:200 theta = 0.7; m = 1-theta; C0(i) = 0.5*(1-exp(-m/2)*sq*cos((m*beta)+phi2)); C1(i) = -0.5*(2*exp(-0.5)*cos(beta)-exp(-m/2)*sq*(exp(-0.5)*cos((beta*(1-m))phi2)+cos((beta*m)+phi2))); C2(i) = -0.5*(-exp(-1)+exp(-m/2)*exp(-0.5)*sq*cos((beta*(1-m))-phi2)); C3(i) = -2*exp(-alpha)*cos(beta); K = (C0(i)/(C0(i)^2+lambda)); %% Open Loop Transfer Function % gh = (z^2*C0(i)+z*C1(i)+C2(i))/(z*(z^2+z*C3(i)+exp(-1))) % pzmap(gh) % hold on % subplot(2,1,1) % step(gh) %% Closed Loop Transfer Fucntion f(i) = ((K*(z^2*C0(i)+z*C1(i)+C2(i))*z^3)/... ((z^3+z^2*(C3(i)-1)+z*(exp(-1)-C3(i))-exp(-1))*(z^2+K*C1(i)*z+K*C2(i))-... ((K*(C3(i)-1)*z^2)+(K*(exp(-1)-C3(i))*z)-exp(1))*(z^2*C0(i)+z*C1(i)+C2(i)))); subplot(2,1,1) step(f(i)) subplot(2,1,2) pzmap(f(i)) hold on
end
42
8.2.4
%% Second Order System with Pole clear clc %% Constants z = tf('z'); alpha = 0.5; sq = sec(phi1); i=1; %% Continous Function % g = (1/((s+0.5)^2+0.75))*exp(-s*(theta)); % gj=c2d(g,1,'zoh') % step(gj) %% for loop for different lambda and theta values for lambda =10 theta = 0.3; m = 1-theta; C0(i) = (1-exp(-m/2)*sq*cos((m*beta)+phi1)); C1(i) = -(2*exp(-0.5)*cos(beta)-exp(-m/2)*sq*(exp(-0.5)*cos((beta*(1-m))phi1)+cos((beta*m)+phi1))); C2(i) = -(-exp(-1)+exp(-m/2)*exp(-0.5)*sq*cos((beta*(1-m))-phi1)); C3(i) = -2*exp(-alpha)*cos(beta); K = (C0(i)/(C0(i)^2+lambda)); %% Open Loop Transfer Function % gh = (z^2*C0(i)+z*C1(i)+C2(i))/(z*(z^2+z*C3(i)+exp(-1))) % pzmap(gh) % hold on % end % step(gh) %% Closed Loop Transfer Fucntion f = ((K*(z^2*C0+z*C1+C2)*z^3)/... ((z^3+z^2*(C3-1)+z*(exp(-1)-C3)-exp(-1))*(z^2+K*C1*z+K*C2)-... ((K*(C3-1)*z^2)+(K*(exp(-1)-C3)*z)-exp(-1))*(z^2*C0+z*C1+C2))); subplot(2,1,1) step(f) subplot(2,1,2) pzmap(f) hold on end s = tf('s'); beta = sqrt(0.75);
phi1 = atan(-alpha/beta);
43
as well as any
44