 So, in the last class we are looking at sampling and this application of the sampling theorem ok. So, the sampling we saw two aspects like one is the sampling theorem itself and other one is about the reconstruction ok. So, ideal reconstruction will be channel reconstruction and then this sampling theorem itself ok that the signal needs to be sampled at least twice its frequency contents to get it the final form which digital form which is representing the original signal content. If it is not done then the signal contents are all lost ideally we will need about 3 to 4 times the sampling frequency to really represent in the practical case scenario. So, now we began with you know further these we began with the digitization of a system. So, what it means is when you sample a system you represent them as this kind of a dot samples that are a point sample points that are represented here that we get most right and these samples are head constant over the sampling theorem which is p. Now, if this kind of a output or input goes to the actuator or your plant how the plant behaves is what we discussed in the digitization that is what will happen when the system is digitized or like you know if you want mathematically represent this continuous system which is like getting this kind of a input which is the p kind of a form of input this kind of static form with this value head constant over the time interval then what is its effect on a system that is what we started studying. And to that effect we saw that like now for any continuous domain system this is a solution of a system this is a system of the kind x dot is equal to a x plus b mu and this is solution. The solution has two parts one is the homogenous integral homogenous solution another is a particular integral part ok. Now, we apply this solution between the two time instances where we start off with like time instances k times capital T, capital T is a sampling time and we predict the state at k plus 1 times t ok. So, within this time the system would progress within this time interval k plus 1 t to k t to k plus 1 t which is the time interval of capital T and there we will get this contribution of the homogenous part of the solution and then this is a particular integral part of the solution. Now, notice here like we integrate not from 0 to t, but now there is since we are starting at k t this will be k t to k plus 1 t and this 0 state here is x of k t. And similarly, you will find that this final time is k plus 1 t and then tau remains as it is because it is an integral variable and then all this comes in the same. And then we shift the time to this time variable or tau variable defined in some different way shifted way and then we simplify this to get a get it to this final form. So, x of k plus 1 now is e to the power a t ok a is a system matrix for the original analog system x r to the power x plus b u kind of a system and t capital T is here something time ok. x of t k I mean e to the power a t times x of k and then integral 0 to t e to the power a s b times t s. So, this is how you get these two matrices which are independent of state ok there is no x coming in this at all. So, these are like system characteristics matrices then ok these characteristics will depend upon matrix A and the something time that we have used something time t ok. So, with these we have now the system coming in this form x of k plus 1 is equal to phi of t x of k plus psi of u of k ok psi times u of k ok. This phi is e to the power a t matrix and psi is integral of e to the power s b d s ok. So, s or like b is not a function of s. So, we can come out of the integral and this is integral of this matrix definite integral 0 to t and multiply with vector t which is a system input vector and y of k is equal to c times x of k that remains as it is. And now one can iterate this for the like say x of say we start at same state k 0 then k 0 plus 1 x of k 0 plus 1 will be x phi x k 0 plus psi u k 0. Then x of k 0 plus 2 will be a similar way and we substitute for phi of x x of k 0 plus 1 here and like you get this again like you know this kind of a function here. And you collect these terms in general for starting from k 0 ok. So, k 0 is equal to 0 to k k. So, this is it became some kind of a summation. Now, you see this power here it is phi square coming here or like you know k 0 plus 2 kind of a thing and that is how like you know this will become now. You just see this carefully, but each term there will be now higher and higher powers that will be coming up for phi and psi here ok. So, you can see this phi square x of k 0 and phi and psi u of k 0 is coming ok. And if you have this k 0 state the initial kind of a state of a system to be 0 ok. So, we consider many times for a transfer function also 0 initial conditions. Then like you know this will be just in terms of your case. So, this expression assumes that there is a 0 initial condition otherwise this term phi raise to k minus 1 times x of k 0 would be additional term that will be coming here ok. Now, let us what is the significance of this is that like we can get a state x of k given u and this is matrices alone ok. So, this matrices phi and psi are known then based on that those matrices we can get you know the response of the system to any input u ok. Now, all of this is now happening in the digital domain ok. So, we are getting this kind of discrete values of the state vector at every time instance or let me know this sampling time index which is k yeah. So, this is how the system response will come out. And if you see this carefully this is similar to what we have as a convolution in the discrete domain in the continuous domain. So, this is a convolution in the discrete domain similar to convolution in the continuous domain. So, this is part here if you see as k minus j kind of a k minus 1 minus j kind of a form and this is a j form ok. So, j and k minus j kind of a forms are there ok. So, with this one can predict what is this function with which input is convolved to get your final output. So, the same way we have convolution in the in the another domain you can see the convolution in the discrete domain and then then the function that is convolved becomes like a impulse response of a of that system. So, in the discrete case it is called pulse transfer function ok or pulse response function not transfer function pulse response function ok. So, if you see this in the convolution kind of a you can see that c times 5 raise to it is an only variable l minus 1 psi this function is pulse response function ok. So, this is like a input u of j and more with h of l which is impulse or pulse response function then you get your output y of that ok is one kind of a concept here. Now, further to that now we seek now a way to get some kind of a transfer function in the digital domain. Now, to get that we need to like define some new quantities ok we will come to that. So, to get our transfer function. So, we define this operator q which is called pulse transfer operator ok in such a way that when the q operates on some x of k then it shifts the state by one sampling in this sense ok. So, q square x of k will be x of k plus 2 like that ok. So, q is like some kind of operator which we have defined now to get some kind of a forms for the transfer function and we get now the way we get things in the in the continuous domain in terms of the variable s which is the Laplace variable Laplace domain available s we now get this you know equations are like the transfer functions in the in this operator in the operator variable in q ok. So, if you now see again our previous system ok we had x of k plus 1 is equal to this was our derived equation previously ok if you see these two steps right we had this equation x of k plus 1 is equal to phi of t x of k psi of u k ok. So, this equation now can be written in the form of this operator ok. So, q times x of k will be equal to all these things. So, if you combine terms with x like x of k together then q i minus phi ok times x of k will be equal to psi of u k and then is inverse times like when you get these. Now, we know the output is y of k is equal to c times x of k ok. So, we substitute for this x of k here and you get these as the output. So, now these become the input relationship ok and if we define the transfer function as a ratio of y of k over u of k then what we get on this side here is a transfer function in terms of this new operator q. So, this is a transfer function of a digital domain system. So, this is how we start out start getting now the similar kind of a analogies which we have in the similar to what we have in the continuous domain ok. So, one can see that look how we suppose we have the system x dot is equal to x with p u and y is equal to c x from there we can get to this kind of a transfer function h of q basically using phi which is equal to e to the power a t where t is a transfer function and where t is a sampling time and psi is let integral of e to the power phi s into a. So, that is the integral of this term ok. So, this a times b let me that b matrix is coming here and a matrix is coming here and c matrix is here like that we have used all these three a b c matrices to get to the transfer function in a digital domain ok. So, this is how we proceed to get a transfer function in the digital domain and this transfer function can then have definitions of poles and zeros and all those instability conditions will come out ok. So, we will not get into those details right now we what we will focus on is now how do we use this as in the in the in the application of of filters ok. So, this is one of the base one can see that this the continuous domain system can be converted into a digital domain system ok. And the issue remains like ok how do we implement such a such a system or suppose you want we have defined now say last class we saw that filter is nothing, but some kind of a transfer function through it is like when the input is passed then some output will be produced which is can be seen as a filtered output. So, similar way we have this digital domain transfer function we pass some input to this function and then like this may act as a filter also ok. So, so you can define this system to be a filter like you know x x dot is equal to x will be you can be your filter which is will have some certain kind of a form of matrix A and B and one can now look at this as a as a as a filter transfer function ok. So, we will see how this can be used in actual implementation of a filter we will look at that. So, we need to kind of have a sense of this shift operator layer here ok shift operator here and like this is same kind of a operation that happens with the with the definition of C transforms ok. So, we will not get into too much of a DZ transform domain things I mean there is formal definition mathematical definition of C transform and there are some certain conditions under which the system can be transformed from you know the discrete kind of a form to Z domain ok and get a lot of these details of like you know the digital domain system will appear there also. So, so this is this using pulse transfer function pulse transfer operator is one way of converting system from continuous domain to digital domain and Z transforms will be another way to do that ok. There are some certain differences although like you know this property is same for both the operator there are certain differences between the two which will not get into right now ok. For practical purposes they are not really so important ok. So, so as far as possible we will prefer to kind of use the system with this kind of a pulse transfer operator because it has some kind of a you know good physical sense of what is happening in actual practice ok that is a getting reflected in this in a very neat way ok which may not happen with the Z transforms ok. So, is one part that is what we will we observe here and we from here we will just move on to some some filters and use implementation ok. So, this is a function and then we will skip this part of the Z transforms and we will go to the filters eventually ok. So, you can these are like you know mainly mathematical kind of definitions and if you give some kind of properties which are similar to cube operator properties ok, but not exactly the same ok. So, that is what we will see ok. Now, we get to this some kind of a fundamentals of a filter. So, the system to transform from one domain to other domain ok. So, now we are using this Z as a similar to like you know cube operator we use this something called bilinear transformation ok where it pops up from is basically if you see the the eigenvalues of. So, you know this is like coming from how the poles get mapped ok. So, the bilinear we will be see what is this bilinear transformation will come to that in a in a while, but one can see now that there are these different domains that you started up with this differential equation, then you convert it into state space form or you can convert it into a transfer function or you can have a discrete domain transfer function with the shift operator cube or you can have discrete domain transformation with Z transforms or like you know using this bilinear transforms ok. So, so see you can either use this discrete domain transformation with the shift operator cube or like you know using this bilinear transform. These are the two ways like you know we can convert the S domain system to Z domain or to discrete domain. And so, discrete domain discrete time relationship between y i k and u k would be that what we derived for with the shift operator ok. So, there are different different kinds of domains of operation that we can see here. Let us talk little bit about a simplified way of of doing the thing with this you know the bilinear transform way of doing this, where this bilinear transform come from. So, let us go back to our basic derivation of this system. So, so the system in the in the discrete domain is x of k plus 1 is equal to phi of t x of k and psi of u k ok. Now, look is pi and psi are some kind of a function matrices. Now, if you if you see in a very similar to what we have in the continuous domain, this is like x dot is equal to A x plus B u ok. And we know that A matrix has is a very special matrix for the system, because the Eigen values of A would be the poles of a system. So, similarly in this case Eigen values of this phi matrix are going to the poles or of a discrete domain function ok and this phi matrix is nothing, but e to the power a t ok. So, Eigen values of phi or the poles of the system are going to get mapped to e to the power pole times t. So, if I say Eigen values of phi will be equal to Eigen value of e to the power a t and if I know Eigen values of a then like know it will be simply e to the power Eigen value of a times t ok. So, the poles get mapped. So, this is nothing, but Eigen value of a is nothing, but a pole ok. So, e to the power pole times t is going to be the new pole for discrete domain system ok. So, pole for a discrete domain system is nothing, but e to the power pole for a continuous domain system times like something time t ok. So, that is a basic nature here ok. So, with these you can see that e to the power. So, if I use s as a variable for the pole then e to the power s t is my pole for discrete domain system ok. So, this is like know it is termed as c here or q here ok. So, z is equal to e to the power s t ok and now if we simplify these in terms of it is exponential in terms of polynomial in the series expansion you get you know some first and second order terms based on that some approximation of the first order terms one can now get this relationship which is termed as bilinear transforms ok s is equal to 2 over t this comes from that ok. So, I leave it to you to derive that from that. So, this is this as a genesis at a relationship z is equal to e to the power s times capital t ok. So, the approximation to this relationship is I get gotten into for polynomial first order terms collecting all the first order terms for the polynomial expansion we get this relationship ok. So, I would leave it to you to derive this relation ok. So, now, we will see how do you use this relation for then implementation of filter or depth edge design of filters that is what is our whole point of discussion. So, we are doing this for finally, be able to implement filter in the discrete domain or in our microcontroller. Now, so these are like know with different ways to transform the system into one form to other form. So, you can look at this say for example, you want to transform system to discrete domain one can use backward difference formula or forward difference formula or like you can take a transfer function of that system and. So, this backward and forward difference formulae will be applicable to the differential equation ok. So, the differential equation operator d by d x will be approximated will be sorry d by d t will be approximated with backward or forward difference formulae and you can get the discrete domain system or you can use the state space representation and do it by shift operator way or you can use transfer function representation and s you replace that s by this value here in terms of z and you get like know that c domain or this can be also q domain ok. So, both are very similar type now we will start using the terminology of a c domain ok. So, for now we will not make much of a distinction between q and c both are similar kind of operator that we will construct ok. Then these are the questions about mapping of the poles and zeroes how will this. So, these are kind of questions one can think over and answer we are not going to kind of get to them right now. So, we will see right now like you know main focus is for the filter. So, this is so once we have a original system in s domain any system in s domain we wish we are able to transfer it into a discrete domain by using these different kinds of transformations ok. That is what is a is a main crux here to you know consider. Once we have this transformation available then how then it is easy to implement in a in a in a microcontroller how we will see that in a minute ok. So, this is what we are talking about mapping of mapping from s plane to z plane ok. So, we saw that in terms of poles it should it is like you know z is equal to e to the power s into t that is what is a mapping from s to z plane. Now, filter we need in mechanism system for between the noise in the system ok and to avoid the performance degradation when we when this noise goes into the feedback then. So, typically filters are used to remove the high frequency noise and the sources of noise you can have electromagnetic radiation coming from the fan, tubeless and other kind of elements which are around the mechanism or your motor itself will be generating a lot of electromagnetic signals which will act as a noise for your sensors ok. Then we have so, we have some operations that are going on in the in the time domain ok. So, what will happen with those operations in the frequency domain is another thing that we need to look at why because the filters have a role to play there also ok. What role the filter have to play say where we do this kind of operation differentiation is where like say for example, for your motor if you want to implement PD control what you do you take a value of your encoder and you use some kind of a difference formula or you are differentiating that numerically the encoder values and getting your speed ok. So, this numerical differentiation has some varying on the noise ok. So, it is very important to see what is there happening with this differentiation operation in the frequency domain. So, if you see differentiation operation like not d by d t of a signal f of t ok. If it is done then Laplace transform of this d by d t of f will be simply like s into Laplace transform of the f right. So, Laplace domain gives you this kind of a like you know multiplication of the original Laplace transform by s when you differentiate a particular function. Now, if you replace this s by j omega ok. So, typically if you know if you remember you have s is equal to j omega we use for getting a board plot of a system or getting a frequency domain response of a system ok. So, when you use s is equal to j omega then at that time like know what happens is differentiation if you see in terms of s is equal to j omega which is simply multiplication by j omega to the original f of j omega. So, f of j omega capital f of j omega is our nothing, but our signal content ok. So, if the signal content is f of j omega then the signal content for the differentiated version of the signal would be j omega times f of j omega magnitude of entire. So, one can see very easily if your signal is a sin omega t if you take a differentiation of this which is equal to time t then it becomes a omega plus of omega t ok. So, you can see that when you differentiate the signal the frequency content the frequency content would change and it would change in a way that you know it is whatever original frequency content it is getting multiplied by omega ok. So, this is of course, is in the time domain ok this is time domain signal you can see here we are just observing this time domain signal to see what is happening in the frequency domain ok. It is not we actually if you want to kind of see this ideally we need to take a take a the plus transform or Fourier transform of this signal to say that ok or look at the Fourier transform of this signal is indeed getting multiplied by omega to get a Fourier transform of this signal ok. So, when it is differentiated the Fourier transforms get multiplied by omega ok. So, what it means is graphically one can see that if you have a signal here ok and you are using this differential operation here. So, you differentiate and get a signal d y by d t here and let us say this operation is some kind of a continuous domain ideal I mean you know differentiation that is happening we are not really doing this approximation by using formal or backward difference formula or anything like that. I just say ok this is like a like a full you know differentiation then this differentiation operation would be this g of s will be s here. So, this is like a transform that is happening y of s coming here getting multiplied by s and then we are getting s times y of s as let us know Laplace domain function whose Laplace inverse will be d by d t ok. So, in the Laplace domain or in the frequency domain this is simply getting multiplied by omega ok this omega plotted on the omega axis will be like a 45 degree line here ok. So, this is what will happen to this signal now is when it passes through this filter is can be seen here that is signal will become 0 here it is it has value 1 it was there that value multiplied by this signal will become 0 and then at omega 0 there will be the signal this signal at 0 value and I know this has some final value but that will become 0 and then this is some kind of a response that we will get ok. So, this is a differentiated version of a signal. Now, so this is what the differentiation operation does to the signal ok. So, one can see that if the audio signal has some noise content now ok it has some typically the signals will have a noise at a high frequency ok and when you pass it now after differentiation kind of operation ok this is even if the ideal differentiation ok you will have you can find that ok now this noise is I say omega n frequency which is further away from omega 0 typically higher frequency noise higher the frequency that much is a is a amplification called the noise that is happening here ok. So, the noise in the signal will get amplified there ok that is what is a it is a main you know effect of operation of differentiation of the signal and because of this we need now filter to get rid of this otherwise your feedback differentiated feedback is going to be noisy in the PD control especially this is important because then the derivative part will get noisy and you will not be able to use very high gains in the derivative question ok. So, so this is how like then you will start off you do this differentiation operation and then you use a low pass filter to filter out this noise and you get like you know the filter of a differentiated signal ok. So, this is how like you can see what is happening in the frequency domain and use the filters appropriately to do the job that like we want to reduce the noise in the differentiation operation. So, sources of noise are not only like you know whatever ambient sources but your mathematical operations also can induce like you know enhance the noise that is already there in the in the signal ok. So, we have not yet talked about like you see this is ideal differentiation, but if you have a far more different the backward differences is some kind of a different kind of a form that will happen here which I am not getting bothered about for now. So, we just leave with this like no idea that ok we have doing like no continuous domain differentiation and we work with that kind of continuous domain system and then say that ok this is more or less similar to what will happen with that something time is fairly appropriate and we are doing it in any way ok. So, the filter if you see here is some kind of a transfer function which has some kind of a frequency response of board plot and then the signal passes through that and it produces the output ok that is a very simple concept of filter. So, you see this is like a first order filter here ok. So, it has some type of cutoff frequency beyond which like you know it has this tapering of some slope will happen here. You can have second order filter or like larger order filters will have like you know this is a sharper and sharper cutoff will happen here instead of this going in a in a gradual slope kind of a profession it will goes like you know down fast ok that will be a higher order filter. So, when we have implement this filter in the. So, we will see how this filter can be implemented. So, this is one of the ways of implementing filter is like you know this moving average kind of a filter ok. So, moving average filter will have a formula. So, what you will do is like you will at a given point you will consider previous 2 or 3 or more samples and take an average of all those samples and keep it at that value ok. And you need to typically update the previous values of the sample and we have seen that that update can be done by using this kind of a way. So, one previous value will be current value then second previous value will be previous current value like that we can go ahead and do the updates ok. These are the updates that we have seen when we implement like you know derivative control we need to do this kind of updates of the previous value. So, that we are ready for the next sampling instance derivative to be completed in the next sample. So, we will not worry about this frequency is one of such a filter, but like you know one of the ways of implementing filter is like you know moving average kind of a filter and you given a transfer function then one can use this one can use this suppose this transfer function is given 1 over tau s plus 1 kind of a transfer function. Then one can use s is equal to this binary transform formula and get that as a discrete domain transfer function and using a discrete domain transfer function you can transfer it to into the discrete domain time function time equations ok. So, how do we do that that will be done by using this shift operator. So, we will stop for here for now and I think this some of these concepts although you may find that there are a kind of a bit of a tough to grasp immediately you will need to ponder over you may need to go back and forth over the slides and listen carefully then he will be able to grasp this concept. I understand that these are like too much of a too many kind of a different concepts are packed here together, but there are like done in a manner to kind of see that you are able to kind of develop filters yourself or implement filters yourself, but these are the ideas that you will typically need for the you know defined implementation of a given a catalytic system ok. Because many times you will be bothered by the noise in your sensors and when you further do this differentiation operation you know noise is further increase and then you will get further what to do in such kind of a scenario how to kind of handle that time this concepts are going to be very very useful ok.