 So in our last lecture we were looking at Z transforms I just briefly introduced Z transforms so Z transforms are defined for a sequence of vectors or a sequence of scalars infinite sequence going from time 0 to time infinity it is a discrete sequence the set of values which are collected at uniform sampling interval whatever it is could be as I said it could be 1 second it could be 0.1 second it could be 1 minute depending upon the application. And Z transform of this infinite sequence is defined by what is given here and correspondingly you define so Z transform converts a signal from time domain to Z domain and you can define inverse Z transform which converts a signal from Z domain to time domain. The relationship between S and Z transform I am going to derive it in this class I am going to leave it to you to read about it I have given two references at the end of this notes I uploaded new notes slightly revised notes we made all of corrections in the last lecture so I uploaded those notes you can have a look at it at the end I have put three references which so at the end I have given these three references the first text book here is Astrome and Wittenmark you can say this is like Bible of digital control if you want to know if you want to pursue career in control systems this is a book which you must have this has this was what I have given here is the one which was published by Prentice Hall India no longer Indian edition is available international edition of this book is of course available you should buy edition 3 if you are interested the second book is also equally important reference a very good book Franklin and Pavel on digital control systems well throughout this course I am not going to refer to one book I am going to use multiple books I will keep giving you references it is not possible to come with one single reference for this course because this is an advanced control course which is my version okay so advanced control is a notion and then I am picking up a few things from it and putting and giving it to you because what I think is relevant is what is being presented so it is going to be collection of you know material from variety of sources so for this part I have referred to this particular textbook okay so let us go back and have a look at Z transforms okay so we looked at the properties just a quick review that linearity holds if you add two signals or if you take two signals and you take linear combination of two signals and take Z transform is nothing but Z transform of a linear combination of Z transform of individual signals then time shift this was an important property for us this time shift property is used to convert difference equation into an algebraic equation just like analogy is use Laplace operator to convert differential equation into an algebraic equation the likewise here Z transforms are used to convert a difference equation into an algebraic algebraic equation linear difference equation so this is this is the fundamental result which is used for converting and you can see similarities between the result in Laplace domain in Laplace if you have nth derivative you will get s to the power n if you remember you will get s to the power n here you have a difference operator which is n steps ahead in future you will get Z to the power n Z to the power n you see that there is quite close resemblance between you know the then you have initial value theorem and the final value theorem which are analogous to what you have in continuous time or in Laplace domain in the last class I gave some examples of Z transforms the simple signal which is you need step it is 0 before time 0 and it becomes value alpha at time 0 to infinity such a signal if you take Z transform you will get alpha upon 1 minus Z to the power minus 1 and likewise if you if you open this book computer control systems or Franklin and Powell you will see examples or you will see tables of Z transforms of variety of signals what we are interested in this pulse transfer function and this is where we were in the last lecture this is what I wanted to so I said the reason why we want to introduce Z transforms is because you want to convert difference equations into algebraic operators or transfer function matrix that is what it would mean okay here instead of Laplace transfer function matrix it will be a Z transfer function matrix what I have done here is I am starting with this difference equation and I am taking Z transform on both the sides if you see here I am taking Z transform on both the sides okay I am just going to use this time shift formula the one which is the second one I am going to use this formula here I am going to use this formula here in this particular case I am taking Laplace I am taking Z transform of X k plus 1 X k plus 1 would involve here X k plus 1 will involve here X 0 okay it will involve here X 0 okay if I if I just use that formula and come up with the Z transform I get summation k going from Z to infinity k to infinity X k Z power minus minus k so this is nothing but X Z and you have this term X 0 which is appearing and I am taking Z transform on the right hand side so if I actually combine this now if I combine this and make one more assumption that initial state initial perturbation at time 0 is 0 which is usually the case when you find out a transfer function matrix whether it is in continuous domain or in Laplace domain or in Z domain a usual assumption is that initial state is 0 with that you will get this transfer function matrix here all that I have done see here this is this term is nothing but X Z I am taking X 0 is equal to 0 so this term here collapses to Z X Z right hand side is Phi times X Z and gamma times U Z okay so this is just the next step just using the definition of Z transforms okay then I have just rearranged remember this Phi is a matrix so Zi minus Phi times X Z will you gamma Z and this gives me a relationship between the states and U Z when you derive a transfer function matrix your purpose is to come up with a relationship between input and output I want to eliminate the state okay so I am going to look at this relationship why are the measured outputs and X are the states C is the matrix that relates measure outputs with the states or perturbations in the measure output with the perturbations in the states and then if I just take Z transform of both the sites I get Y Z is equal to C X Z it is straight forward is everyone clear about this I am just applying the definition of Z transform now I am going to combine these two results I am going to combine these two results I want to eliminate X I want to have a relationship between measured outputs and manipulated inputs okay so what you get here is what you get here is this matrix C times Zi minus Phi inverse into gamma okay again you will notice that this is very very similar to what we had for Q transforms okay so shift operator transform this is very very similar and you get G Z U Z this is called as a pulse transfer function again same thing well if I do it for quadruple tying system I will get this transfer function matrix between two level perturbations H1 and H2 and two voltage input perturbations okay so these are my two now just remember right now what we are doing is going through developing a control delivered model starting from a mechanistic model starting from a first principle model or a gray box model you have a good model which is coming from physics or mixture of physics and correlations and then you are linearizing that model to come up with this control delivered model this model is control delivered model I can use this for controller synthesis okay yeah sampling time typically you choose based on what is called as you know dominant frequency or the fastest frequency in the signal okay that you have now what is the fastest frequency in the signal that you have some a priori idea about how fast your particular system behaves okay so one there are multiple ways of choosing a sampling time one way is that you find out the smallest time constant you understand what a time constant is yeah so find out the smallest time constant take one tenth of that or you find out the settling time you know what is the settling time you give a step change and find the settling time take one hundredth of the settling time so here I have chosen five seconds as you know one tenth of the shortest sampling time constant okay actually the tendency in the industry is to use very small time sampling time when it is not required okay people tend to sample temperature of a furnace at every one second where nothing is going to happen for a minute okay so actually you should choose sampling time based on the response time of the system itself okay so here five seconds is because is because the smallest time constant in this particular system is about 50 so I have taken one tenth of that roughly you can find out good discussions about choice of sampling time in Franklin and Powell or in Astroman metanmark okay so what we have got here let me come back what we have got here we have eliminated the state variables there are four state levels now this transfer function matrix relates only measured levels with manipulated inputs okay it does not it does not say anything about unmeasured levels okay now I want to go back and relate to time domain again okay so it should be very very comfortable going back from time domain to Laplace domain or Laplace domain to time domain or Z domain to time domain time domain to Z domain and so on okay we should know that these are only representations it is only one model which is being represented through you know which being viewed through different filters or different you know different specs it is the same thing ultimately so I want to show that this this model this is the model between some y and some u I am picking up this right now instead of saying h h1 v2 or h2 v1 and so on I am just saying just take one general transfer function between some output y okay look at some some some output y and some input u let us assume that there is a transfer function is given by b1 z plus b2 upon z square plus a1 z plus a2 now there is one more term appearing here okay z to the power minus d okay now this z to the power minus d actually represents time delay or dead time are you aware of what is a dead time how many of you know about what is a dead time everyone knows dead time is the time required for you know it has different different interpretations in different context it could be time required for the actuator to start moving after you give a signal it could also mean the time required for the measurement to reach the computer the delay in the measurement can a variety of interpretations so a time delay of d samples the model for that just turns out to be z to the power minus d okay if I have a dead time was of z samples d samples then the model is z to the power minus d so I combined this model which has a time delay of d samples and then I get this model in z to the power minus 1 I just want to convert it back into time domain so I am cross multiplying and then you take z inverse to z inverse to write the z inverse you don't have to compute the counter integral here you just you just go back using the formula for time shift if you see this formula you will see that it is very very easy to go back to time domain difference equation okay so here g to power minus 1 simply becomes y k minus 1 when z to the power minus 1 is operating on y z or z to the power minus d minus 1 operating on you simply becomes k minus d minus 1 okay k is the current time remember that k is my current time k minus 1 is 1 in past k minus 2 is 2 in past and so on okay I get this linear difference equation model starting from the original transfer function model is equivalent to this difference equation model I have written it as current equal to something in the past on the left hand side is y k y k is the current so what does it tell you it tells you that the new measurement is related to the past measurement and new inputs which are coming what are the new inputs u k minus d there is a time delay okay there is a time delay which means if I make a change in the input right now it is going to be reflected after some time what is happening now is the effect of something that has happened in the past okay where something that has happened in the past so this tells you that the current input u k is not going to influence y k or y k plus 1 it is a input in the past is influencing the current measurement okay that is because of the delay okay and then this is my difference equation model okay to solve this difference equation model is not at all difficult if I know u is the input sequence input is something which is given to you either by a controller or by a operator if you are operating the plan you are changing the input you know what is you okay and given you I can solve this linear difference equation marching in time if I if I know value at instant you know 0 and 1 I can find out value at instant 2 if I know at 1 and 2 I can find out at 3 I can go hopping in time this is a difference equation as k increases you will get okay so far so good so we got this model we started with mechanistic model we linearized it use Taylor series expansion then we got a state space model then we discretized it we got a difference equation which is computer relevant great now what is a practical problem if you go to an industry and say that well where is the mechanistic model you know people might laugh at you unless you are going to some R&D lab where they are aware of what is happening okay what is a mechanistic model and why it is required so you go to ISRO and or you go to some lab of you know where advanced controller development is going on they would of course know what what you are talking about but you know a general industry if you go and say when I want a mechanistic model for the system you will not get anything you will not have a mechanistic model now what to do so the question is well if I if I go to a industry I have a system to be controlled I do not have a mechanistic model can I simply develop model from data I can do you are allowed to do some experiment with this system okay you are allowed to tweak this system you are allowed to play with the system it is like the example that I keep giving is the model that we develop for a car when we start driving a new car or a new vehicle say motorcycle so you know we the manipulate variables are accelerator and a brake so we play with it you know initially we slightly increase the accelerator and see how it goes ahead and then we apply the brake and see after what distance it stops and then we develop a model which is input output model output is the speed or you know braking distance and then input is my you know the pressure I put on the accelerator or the pressure I put on the brake so these are my inputs and my outputs are you know the speed or the braking distance so can we develop these kind of models if I am allowed to play with the system I am allowed to drive my car but well I do not have a model coming from physics for the car so can I still work with it yeah so my approach from now on is going to be like this I am going to inject perturbations into the system okay I do not have a first principle model and I still want to get going with the controller design okay I cannot say that well call the engineer who will model this for me and then I will start I want to develop a model using some simple tools and you know what I am going to do is I am going to record the inputs that I give in and I want to record all the output measurements that are coming okay and then between this input and output I want to fit a model okay I want to fit a model just like you fit a correlation I can fit a differential equation I can fit a difference equation okay it is not necessary that you only have algebraic correlations between variables okay you can have you know some system is there you have some input some output you can develop you know differential equation a heuristic model which is a differential equation or a difference equation okay so let us look at this quadruple tank setup I have a setup in my line okay there are four tanks you can see them the way we saw this in the first few lectures there are two tanks stacked above each other and you can see here this is the control wall part of the flow goes to this time the remaining part of the flow goes to this this time so tank 1 and tank 4 get you know input that is coming from this control wall and tank 2 and tank 3 get flow which is coming from this control wall okay let us assume that I do not have a model coming from physics for this system but it is connected to my computer I can I can change the wall okay experiment that I am going to do is I am going to change the wall I am going to perturb the wall okay there are many questions do I perturb one ball at a time do I perturb both the walls simultaneously well if you want to save time I would perturb both the walls simultaneously you might find it a little difficult because if too many things are changing simultaneously how do you model and not that difficult as you will see so okay so this is a schematic diagram of the same setup okay I have four tanks there are two inputs and there are two outputs two outputs are two levels right I am not going to measure all four levels I am going to measure only level 1 and level 2 in tank 1 and tank 2 okay I actually conducted the experiment in my life okay so what I did was I took initially the system to a steady state and I have injected perturbations 0 here is not really 0 0 is 12 milliamps I have just plotted here perturbation inputs so I have given I have bought the system to a steady state okay by giving 12 milliamp volts to both the control balls the level has come to a steady state okay and then I inject perturbations I have just plotted here the perturbations you see the perturbations they are the perturbations in wall 1 and wall 2 how did the system respond okay these are the measured outputs we are the measured outputs again perturbations from the steady state level okay I have this data now with me for this particular system I have played with the system I have you know manipulated the walls according to certain according to certain scheme this particular signal which I have given here is called as pseudo random binary signal I am randomly changing between two values plus 1 milliamp to minus 1 milliamp okay my system the control wall take input between 4 to 20 milliamps okay if you give 20 milliamps the wall is full open if you give 4 milliamps the wall is full closed okay I am first taking the I am first taking the opening the wall to 12 milliamps so 12 milliamps is my baseline okay at 12 milliamps I wait till the system levels come to steady state the system is perfectly at the steady state at 12 milliamps okay now I start my perturbation studies okay and then around 12 milliamps so this when you say here plus or minus 1 it actually means it actually means I am put up in the input to the wall from 12 to 13 and 11 for each of the walls okay this is the perturbation I have injected it to the system and how does the levels react levels have reacted like this this is the perturbation in the level around the steady state okay so what I have done actually let me put it mathematically what I have done is I have collected data for y0 y1 yn y capital here is the absolute value u capital is the absolute value of the input absolute value of the input is between plus or minus 11 volts plus or minus 11 milliamps and the level is measured again in terms of milliamps okay the level is measured between milliamps now I am going to develop the input output model okay now what is input here the input here is the current input that goes to the control wall very very important input right now is not really the flow okay so whatever is going out of my computer is the input whatever is coming into the computer is the measurement so measurement includes level dynamics sensor dynamics everything okay the measured inputs the control you know the manipulate input here is the value which is sent out of the computer which means process includes wall dynamics process dynamics sensor dynamics everything okay it is not just okay then well I should know what is my operating steady state I can take a measurement initially what is the what is the steady state level then what is the steady state input I told you in this case is 12 milliamps input is the steady state input so u bar is 12 milliamp 12 milliamp and why I have to find out experimentally whatever I get I subtract that so I define this deviation variables and finally I generate perturbation inputs what I have plotted here is this perturbation inputs okay I have collected data which is the collect data collected is not in terms of perturbation data collected is absolute variables for the purpose of modeling I am going to convert it into perturbation variables why because we are going to develop a model using Taylor's approximation Taylor's approximation talks about perturbations in the input to perturbations in the output okay so yeah in this case we have for the level measurement we have differential pressure transmitters okay which convert the 0 to 100 centimeter water column into 4 to 20 milliamps so 100 centimeter water column is or 60 centimeter water column I think 60 centimeter water column is 20 milliamps 0 centimeter water column is 4 milliamps so that is how I and then that transmitter is connected to my analog to digital converter okay which is giving me measurements at every 5 second interval okay so every 5 seconds I get one measurement from because it is perturbation it is deviation so see here my original output is not negative values but if I take a steady state okay see my original output is h versus time is something like this so let us say my initially it is a steady state then it starts changing okay so this is the steady state now if I plot this in terms of you know h so let us call this this point as h bar so if I plot h-h bar versus time then it will look like this whatever this is negative this is positive okay but original signal is not like that original signal is you know let us say it is varying between some 10 milliamps to 14 milliamps or something like that okay it is varying between 10 to 14 milliamps I have removed the mean value or the steady state value then that gives me signal which is positive and negative okay is everyone with me on this you get perturbation signals which can be positive negative original signal may or may not be positive or negative depends upon the system okay if you have induction motor you may have currents which are negative or positive but if you have temperature temperature is not going to be I mean temperature can be negative if you take depending on the scale but some things like concentration is never going to be negative okay but perturbation concentration can be negative because it is perturbation around some mean value okay so that can be negative so okay yeah no I should not be drawing output as a continuous signal I should be drawing it as a discrete points okay it is only that I have connected the discrete points okay so idea of drawing this would be just points there are 250 measurements there should be 250 points okay just for the sake of so look at here this is my initial steady state this is my initial steady state okay so this is my this is my initial steady state because it is at 0 I have subtracted the steady state value and then this is the perturbation around the steady state these are the perturbation inputs okay well now what I can say is let us go back to this let us go back to the model that we had developed earlier and then connect we develop this model from linearization and finally yeah finally I got this I got this matrix okay I want you to look at this matrix closely okay there are certain elements which are 0 here why they are 0 because they are decoupled there is no relationship that is why those are 0 okay there are only few elements in fact if you look at 5 matrix there are only 6 elements which are nonzero right there are 6 elements how many it is a matrix which is 4 x 4 only 6 elements no not 6 yeah only 6 elements are nonzero okay out of 16 6 elements are nonzero okay look at gamma matrix as 2 elements which are 0 whatever sampling interval we choose for this particular system structurally these matrices are going to look same they are not going to look different is it clear structurally these matrices are going to look exactly like this whatever we do same is the case for C matrix I am measuring only 2 levels okay in that only 2 elements are going to be nonzero remaining are going to be 0 okay. So what if I treat these 6 elements here as unknowns to be estimated from data okay can I do that so what I am going to do now I have this data with me okay I have just plotted here y1 u1 there will be data for y2 u2 okay I have this data for 2 inputs 2 outputs I am just showing here 1 portion of it okay I also have data for y2 u2 okay now I am going to say that if I discretize a model coming from physics okay it has a certain structure and that structure is given by this you know matrix these 3 matrices now what do I mean by structure is given by 3 matrices I have put 0 where I know they are going to be nonzero okay and elements which earlier got determined through linearization of a model I am going to treat them as unknowns okay. So I am treating a1 a2 a3 a4 a5 a6 there are 6 unknowns in 5 matrix there are 6 unknowns in gamma matrix there are 2 unknowns in c matrix okay so now question is can I estimate these 6 plus 6 12 plus 2 14 parameters only from data without worrying about starting from physics coming with a nonlinear differential equation model nothing but starting from that model if I had a clue of what that model is I can come up with this structure okay if I know what is a model from physics is okay I can come up with this structure I am going to call this model as a gray box linear model why gray box because some information from first principle has been used but I do not know parameters of the first principle model okay but I have used the first principle information to arrive at a structure of this linear perturbation model okay the structure has been found from physics but the parameters values are unknown and I am going to estimate the model parameter values from data so how do I do that okay let me define a vector called theta this theta has 14 elements alpha 1 to 6 beta 1 to beta 6 and gamma 1 and gamma 2 all 14 elements put into this theta vector I am going to use least square estimation do you know least square estimation you fit curve fitting okay instead of curve fitting I am going to do a differential equation fitting or a difference equation fitting okay that is only the difference between what you know and what I am going to do now okay I want to fit a difference equation linear difference equation into this data of y1 y2 and you do okay between these 14 parameters as unknowns how do you do this if you are given if you are given some data and if you do fit a line what do you do do not tell me I use excel and I just click and I get a fit that is not the answer what do you do linear least square estimation remember what is linear least square estimation what do you minimize error between measurement predicted estimated output and actual measured output okay so I minimize difference between I minimize the difference between estimated output and the measured estimated by what estimated by the model okay estimated by the model what is the raw way of doing this you can guess the parameters okay you can guess parameters then for every guess you can generate model estimated model outputs you have measured model outputs you compare the two okay if you if you if you think that this the fit is not good you revise your estimate and you go on doing this till you know the estimated output goes close to the measured output okay so this is what I am going to do next okay I am going to do it through optimization optimization how to solve the optimization problem I am not going to get into that in this I am just going to formulate you can solve it using MATLAB toolbox okay so let us see how this can be done now what is known to you the inputs are known to you input sequence is known is you know you have introduced the inputs right you have changed the wall position so wall position as a function of time is known to you you also know that it is piecewise constant okay so you know the wall you know the wall positions okay what is not known to me what is my model so my model is okay this is my model let us say I am at time 0 okay so at k equal to 0 what is known to me I know you 0 I know you 0 okay I do not know okay so this is known what are the unknowns one thing which I do not know is right now is 5 matrix I do not know what is 5 matrix so I have to guess what I have to guess alpha 1 to alpha 6 I have to guess elements of gamma I do not know what is what are the elements of gamma right I also do not know what is x 0 I do not know what is x 0 what if I guess all three of them okay what if I guess all three of them let us see what we can do the initial state one way of eliminating is making a simplistic assumption that x 0 is 0 you are starting from steady state and x 0 is 0 that is typically done you cannot eliminate you cannot eliminate you can make a simplifying assumption that x 0 is 0 you cannot really eliminate x 0 but you are not measuring x you are only measuring y so I am only measuring two levels below I am not measuring all the four levels see because why is that because see a level transmitter costs okay a level transmitter a D2P transmitter would cost something of the order of a good quality D2P transmitter would cost something like 70 to 80,000 okay so I do not have money to put all four level transmitters okay so I cannot measure x 0 I can measure only two of them I can know initial levels for only two not for all four so x 0 has to be somehow guessed okay some part of it might be measured you can actually put those values other parts you have to guess or make a simplifying assumption initially you are starting from 0 steady state okay and x 0 is 0 the other two ways okay so coming back to this equation if you look here I have given a guess for this theta vector and what is my y 0 y 0 it now made the notation little bit complex because I want to just emphasize on this slide that c is guessed I guess theta then I get c I guess theta then I get phi I guess theta then I get gamma okay that is why I have made the notation little complex here okay so starting from this guess I know you know I have guessed this I have guessed this I have guessed this I can compute x 1 right it is a difference equation okay and then y 1 becomes y 1 becomes c theta c theta I have guessed x 1 now I have computed here okay so I get y 1 okay so I got x 1 now using x 1 using x 1 and u 1 I can estimate x 2 okay I can go marching in time now okay I know input sequence I know u 0 u 1 u 2 u 3 u 4 okay just see I have put this little notch above here y hat this is x hat y hat x 2 hat y hat because it is an estimate we do not know whether it is correct or not it is an estimate based on your guess theta because your guess theta your estimated x okay yeah theta is this parameter say let us go back theta is this parameters okay theta is this alpha 1 to alpha 6 beta 1 to beta 6 gamma 1 to gamma 1 gamma 2 so once I guess this look at this slide once I get this phi gamma and c get defined okay yeah that is because it is coming from physics so I am assuming that I have a model from physics but I do not know its parameters that I know enough to come up with this structure okay that is why I am calling it grey box okay afterwards I am going to relax this also I am going to say that I have this data and I do not know anything about the model structure then what that is the next question so I am going in a gradual manner you know I am starting from physics I have full model how do I get control relevant model okay second is well I have a model but I do not know its parameters but I do know something about the structure and how do I exploit it okay next is well I do not know anything okay then what do I do so three stages okay so everyone with me on this I can go on now marching in time for every guess of parameters and every guess and every time I guess parameters I also get x0 okay I can generate complete state sequence right if I can generate state sequence I can also estimate y okay and then well the conventional least square estimation what I want to minimize I want to minimize difference between y measured and y estimated I define an error epsilon which is difference between y measured and y estimated okay and now I have to minimize some of the square of errors trouble is epsilon is a vector what do I do take the norm like to norm I can take a weighted norm that was I can define a weighting matrix w and I can take a weighted norm weighted norm is because many times you know you will have this y consisting of variables of different magnitudes one could be pressure the other could be temperature third could be you know some concentration the physical values will be completely different if you just take some of the square of errors you know pressure values will be Newton per meter square 10 to the power 5 and you know concentration might be in fractions and then you will have problem numerical problems okay so we can use the weighting matrix to balance elements of this and then what I am going to do is to solve this parameter estimation problem as an optimization problem it is an optimization problem okay in which I am going to minimize this in this I am going to minimize this objective function this is the objective function it is some of the square of errors because because this is you know because this is a vector I am taking vector transpose w into vector so this will give me a scalar value okay some of this from time 0 to time n I have data 250 points okay I want to minimize this some of the square of errors with respect to theta and with respect to x0 one simplification I can do is assume x0 is 0 then it with respect to only theta okay this is the this is the optimization problem that I need to solve you can solve this using matlab toolbox you can solve this using any one of the known methods it is enough to understand the formulation you know there are tools to solve this problem so yeah w matrix is typically decided to balance between different magnitudes and bring them on the same scale okay so you know you would put it one simple way of doing it is find out the range or variability and then take elements of w matrix inverse of the range see for example if my pressure is changing between you know plus or minus 10 to the power 4 you know plus or minus 1 into 10 to the power 4 then you divide and bring it to plus or minus 1 variation okay so you try to scale it is the scaling matrix okay see because you may have a temperature in your in your model in your why estimated you may have a temperature value which is between you know plus or minus 10 degrees and pressure is varying between 10 to the power 4 to 10 to the power you know minus 4 deviation pressure okay if you take just temperature square plus pressure square you know the temperature square will get buried it will not be seen. So you came it in such a way that temperature variation becomes plus or minus 1 pressure variation becomes plus or minus 1 so you choose w matrix such that you sort of balance numerically the values okay is this clear is this optimization formulation clear I am going to find out these parameters by numerical optimization okay well like he said how do you know the structure of the matrix okay I do not know structure of the matrix so I am relaxing even that constraint now I am going a little one step ahead okay now let us look at I do not know structure of the matrix but let us assume that I know structure of the transfer function matrix this can be known because you know first order you know what is the first order and second order transfer function I can know whether between y1 and u1 whether transfer function is first order or second order see just go back to let us look at this figure okay now between input 1 and tank 1 what do you expect the transfer function order to be first order okay same thing between you know output input 2 and output 2 will be first order okay what do you expect between output 2 and tank 1 it will be second order because the input is going through this tank and then going through this dynamics okay so now I have come up with this model abstract model with unknown parameters this is a perturbation model okay I have come up with this abstract model with unknown parameters just by arguing like this you know this is this between this and this is only one tank okay so model should be first order so the diagonal elements are first order you see here elements are first order y1 u1 is first order y2 u2 is first order okay but y1 u2 is second order because it is going through two tanks the simple way of deriving this okay I am assuming each drag is first order I am neglecting dynamics of sensor I am neglecting dynamics of the control ball this is a simplification okay whether one should neglect it or not depends upon you know your judgment as an engineer whether you know this dynamics is negligible that depends upon the system okay this is yeah that is a good question we will answer that a little later whether a distillation model well you can count the number of trace and say it is hundred order model but it is implicated to develop a hundred order model okay then we do a reduced order modeling we approximately as a second order or third order model to the dead time and so on okay so now what I am going to do now is I am going to identify these parameters of this model this transfer function model okay the way I am going to go about is now you know I am going to look at one output at a time okay so in parlance of system identification I am going to develop MISO models MISO multiple input single output MISO you probably have word CISO what is CISO single output single input and single output right I am going to develop a MISO model between Y1 and U1 U2 and Y2 and U1 U2 I have defined two parameter vectors here theta 1 is A1 A2 A3 B1 B2 B3 so A1 A2 A3 and then B1 B2 B3 so for the first row estimation I am going to do okay I am considering this MISO model I am considering this MISO model okay now I have to convert this into time domain this is a I can use the algebra of you know transfer functions if you see here the next step is to convert this into operator Q to the power – 1 and then I have taken common denominator you see the common denominator okay and then after doing this I can multiply cross multiply and convert it into a difference equation because ultimately to computations for optimization I need a difference equation so I need to go back to difference equation okay so what is my equivalent difference equation very very easy to write if you look at the numerator and denominator you can just I mean the equation looks messy that is because there is a lot of algebra you multiply all the cross terms basically you know when you have Q to the power – 1 you know operating on UK you will get U1 K – 1 and you will get U2 K – 1 and so on if you understand that simple thing this is just an algebra and getting the difference equation starting from yeah we have to assume that Uf1 Uf2 Uf3 will be some input that you have given a time equal to 0 but there is a delay see this model will tell you that okay I will be doing it on the next page okay see because Uf1 affects only Uf3 and the second more technical answer to your problem is that you do not have to assume it to be equal to 0 you can do it in the list of unknown inputs or unknown variables and optimize if you decide to do that you do not have to make a assumption okay you can treat as y0 y1 y2 to be unknown optimize guess and optimize okay. So again same thing if I have input sequence okay if I give a guess for theta I can use the difference equation recursively in time I can estimate y1 hat what is y1 hat level perturbation as function of time okay estimated using the difference equation I find out the difference now it is a single output it is a scalar I do not need any weighting matrix okay. So answer to your problem is I am including y0 y1 y2 also as guess in that earlier case we had to guess x0 in this case I am guessing y0 y1 y2 if you want to assume it to be equal to 0 that you can do provided the system under consideration is open loop stable I will talk about stability aspect little later so I am not saying it right now okay it is open loop stable it is fine to assume them to be equal to 0 you will get some error initially but if your last data that initial error will vanish okay unstable systems you cannot do this but identification of an unstable system is a fairly complex business and still you know into the domain of research not really okay is this clear is this optimization problem clear what I am going to do yeah why is the height yeah that is a good question so you have to introduce constraints into this problem that is not so easy okay how do you make sure that the guesses that you give are you know meaningful okay that is a tough problem you probably have one way you can do it is to give constraints on theta okay but giving constraints on theta is also a difficult thing okay. So best thing here is to start with a good guess okay now how do you start with a good guess okay so well what I will do is I will demonstrate to you some of these things as using the toolbox beyond the point you know it is not just okay beyond the point it becomes an art you have to be proficient in the art you have to see a lot of data you have to see how to give good guesses okay fortunately MATLAB toolbox does a lot of it for you okay it will solve a problem which will keep it inside the meaningful range and so on but there are ways of initializing a model you know given a good guess for the model when particularly when the model is coming from physics see for example this kind of a model this kind of a model I can put a constraint that the steady state gain should be negative or positive that I know from physics if I increase the wall one whether the level is going to increase or decrease at the steady state okay. So to find out the gain here for this you put q equal to 1 you will get the gain so I can put a constraint that b1 upon 1 plus a2 okay the steady state gain so if I for this model the steady state gain for this model is obtained by setting q equal to 1 so the steady state gain is b2 upon 1 plus a1 okay now just argue from insights into the system if I change the wall one what is going to happen to level one it is going to increase or decrease it is going to increase always going to increase so the gain steady state gain between the wall one position and level one it is going to be positive okay so I could put the constraint that this is always greater than 0 okay so likewise you can argue about each element and put meaningful constraints you can give a constraint optimization problem which that is a good question and to get meaningful solutions you may have to do such all such tricks okay okay so this is the problem for level one and input 1 input 2 MISO model likewise I can develop same thing for level 2 input 1 input 2 MISO models I can combine them into one grand MIMO model and then use it for control okay what are the pros and cons of doing this in each case you have to solve an optimization problem and you have to give a good initial guess it is a highly nonlinear optimization problem not at all easy to solve even though looks straight forward here not at all easy to solve so giving good guess is very very important how to give a good guess trouble it is not so easy to give good guess next thing is now I assume that structure of phi model could be arrived at by some arguments okay you know these are zeros and these are non zeros so I had a gray box perturbation model what if for a complex system you cannot do that it is quite likely that for a complex system I cannot come up with this structure okay so in that case I have no clue as to how this phi matrix is going to look like okay it could be anything it could be full matrix it could be no sparse matrix god knows so this is one more thing I am just modeling here inputs that are known okay any system will have input that are unknown okay for example in this in this particular system okay you know there is a wall and there is a pump the pump gets voltage from the source and the source voltage is never perfectly constant at 220 volts it is fluctuating between 200 to 240 because of that the pump speed is varying because the pump speed is varying the flow is fluctuating so even if I keep the wall opening 50% actually flow is not constant so keeps you know fluctuating now this fluctuations have a impact on the level right it is not going to that you know the level is going to be constant because the flow is fluctuating even though the wall position is constant the level is going to fluctuate so my output measured has something else which is coming from some other input which is not measured I am not going to measure everything that happens right I am not going to measure the voltage in the sequence and it is not possible to measure everything so there are unknown disturbances and then I need to model them so what is the solution so I am going to now relax even the assumption that I know the structure of the model nothing I want to start from scratch okay I only have data I only have this data okay I have this toy with which I can play I can give inputs I can collect data now can I develop a model okay that is what we are going to see in next series of lectures yeah two different input sequence and have the identical output sequence mathematically yes no provided two different input sequence not mathematically because it depends upon how many number of inputs how many number of outputs are there if you have you know you know differential equation because of the uniqueness of the solutions okay you will not get if you have input sequence different you will get output sequence different yeah we assume that differential equation has a unique solution yeah even then having non unique solutions with the same it is possible in non linear systems it is possible in linear systems I cannot think of if you have number of inputs equal to number of outputs if you give the same inputs you will get the same outputs but in a non linear system it is possible to have same input sequence for example a non linear system can have multiple steady states for the same input okay very much possible in non linear systems and technically it is what you are saying same input multiple solutions so how the system will behave will depend upon locally where it is okay in the state space or where it goes now those kind of things are beyond the scope but it is only possible in real non linear systems in this ideal world of real systems you will get but even for linear systems if the disturbances are different every time then you will not get the same output even if you give the same input okay so in this system quadruple time setup if I give the same sequence every time I do not get exactly same output because you know the voltage fluctuations are every time different so the level fluctuations that is arising out of voltage fluctuations are every time different okay if there are no voltage fluctuations whatsoever perfect system if you introduce same input you should get the same output okay yeah I have a accurate black box model it is very difficult to give an often answer what do you mean by accurate black box model it is a oxymoron but if you can develop a black box model if you have a grey box structure you might as identify a grey box model again you will run the optimization problem you are saying that after optimization you do not get good grey box model then what you do use black box model which is yes yes but then you know if there is a mismatch between the plant and the model and if you use a grey box model that itself will be a fault okay your diagnosis algorithm will say that something is faulty all the time because there is a mismatch between the model and the plant so using grey box it is very very helpful but it has to be very good otherwise we had problem diagnosis using a grey box model we had lot of trouble because it is a mismatch for control there is no problem for diagnosis there is a problem control you can handle model plant match and do a good control as long as you know order of magnitude changes of the model and in the plant are safe okay but so control mismatch does not matter so much in diagnosis well in diagnosis if you are saying diagnosis is the application I would go for a grey box model and improve it for diagnosis it is very difficult to use black box model so it is application dependent what is in what is therefore control I can use black box model you start with the data input and output yeah but it also depends on the operating condition right yes so so does the linearization no if I change the linearization point I will get a different different model even on the same point you do the experiment under different operating conditions yeah like the plant is outside temperature is different the outside yes yes so every time you get a slightly different model yeah hopefully when you are developing a black box model you are assuming that you know your operating conditions remain more or less same then only you can use it for controller design otherwise you cannot but then if you have a situation where you are nothing you just have this motor car to drive and you do not have you know simulator coming in MATLAB then you just you know use simple models okay so I do not want to go into this today black box modeling I will start with the in the next class I just want to show you this tutorial problems which are uploaded this tutorial problems there are about 10 problems here these are about linearizing the differential equations then converting them into difference equations finding out Q transfer function matrix or Z transfer function matrix pulse transfer function matrix when out of 11 problems which have given you here 9 problems are mathematical problems just talking about x1 x2 y1 y2 okay like in the textbook last two problems are you know real physical problems okay those who are those of you who are chemical engineers can appreciate both the problems the second problem actually is not difficult to understand but you may you may face some difficulty in appreciating what is the second model the first one here is just a system which is I will just draw this we have this symbol means it is a well stirred system okay so cold fluid comes in and it moves out and then there is a jacket here is a jacket here the heating fluid heating fluid could be steam for example okay or some hot fluid in industry they use some hot fluid to let us say heat the contents inside this tank so the cold fluid here and this is hot fluid okay so the cold fluid becomes hot hot fluid becomes cold there is a exchange of heat between the two and the model for that is given by this two coupled differential equations okay so you have to linearize this these differential equations convert them into a model of this form x dot is equal to ax plus bu okay and I have given the perturbation variables you then you convert it into a difference equation by discretizing and then get the model okay for this last two problems which are coming from physics you may need to use Matlab okay first one to nine problems you can do by hand because in those problems I have given try matrices like one two three four and you know you will get some nice eigenvalues and eigenvectors you can see here so one one one one and you will get some so these toy problems are mainly for exam and for doing some practice hand practice and then the last two problems are real problems and I expect that all those were non chemical engineers should appreciate the problem 10 chemical engineers should appreciate both the problems 10 and 11 okay next time I will try to put some more problems from electrical mechanical some some other problems which are I had some models from electrical circuits but I do not have values because if you want to linearize at some point you need actually values of capacitances resistances and so on or spring mass damper systems which are modeling some car and all those models are available but I am trying to get values for physical parameters so whatever we learn here okay we actually implemented on the project in Matlab okay so it is a toy toy problem from different domains and then whatever you do if you do linearization here you do linearization on the toy problem in Matlab you design a controller you design a controller for your system and so on everything that you do on in the class we do it on the toy problem okay.