Thursday, March 14, 2013

Friendship With State Space

Last post we saw how to represent any system in a block diagram and barely touched upon mathematical representation of it called state space. Today I will try to make you believe how simple it is to convert any system into state space representation and give a few “Engineering Secrets” to you.

Best way is to go through an example and then generalize it. Let’s recall Newton (He has tortured us many times before! :-/). So (simplified) Newton’s second law is can be represented by 

Where “m” is the mass of the body, “a” is its acceleration and “F” is the force applied on it. We all have used this equation a million times before. We use this equation to answer the question “What force “F” is required to maintain/attain acceleration “a” of a mass “m”??) Now let’s try to convert this to the form I mentioned in the last post, which is

To do this we need values for “A”, “B” and “C”. Looking at this we can easily answer the question that we need an input “u” to maintain/ attain a state ([X]) ̇ where X is a vector of all the states of the system. So relating this to the answer mentioned above: We have Force (F) as an Input (u) and acceleration as an output (y)!! We can also represent the above equation as 


Engineering Secret 1!: “Generally the number of states in a state space representation is equal to the highest derivative in the differential equation of the system”

Hence in above equation (d^2 x)/(dt^2 ) suggests the highest derivative is second order. Hence the number of states (length of X vector) is 2!!

Engineering Secret 2!: List all the states X1…Xn. To guess the states, let the first state X1 be the original variable itself, in this case “x”. Let the second state, X2, be the derivative of first state, the third be the derivative of second state and so on!
So now we get 

Now computing LHS of the state space equation which is given by the matrix below is super easy!


We have all the ingredients! 
So,

Engineering Secret 3! How do you know the dimensions of A and B???
Well.. we know LHS is 2*1 and is 2*1 hence if A is m*n then 2*1 = (m*n)X(2*1). So n should be equal to 2 (for a valid matrix multiplication) and m should be 2 for valid dimensionality.  Thus A is 2*2. Similarly if LHS is 2*1 and u is 1*1 then 2*1 = (m*p)X(1*1). Hence p = 1 and m =2. So B is 2*1 matrix.

Dimensions of C depend on dimensions of “y”. That means if you  are going to measure both the states the Y is 2X1 and hence C will be 2X2. If you are measuring only X1 (displacement) then C will be 1X2.


Engineering Secret 4!: To rearrange this into state space format  write the skeleton first (according to the dimensions you derived from the above trick!) and then fill in the values for A and B using matrix multiplication rules

And then filling in the values we get


Hence to Summarize:
  1. Determine highest order in the system equation (given to you by physics!). Your number of  states is equal to the highest order of derivative. 
  2. Let first state be the variable itself, second be its derivative, third be second’s derivative and so on.. Calculate values for all states. 
  3. Calculate LHS by taking first derivative of each state. And write all equations. 
  4. Derive the dimensions of A, B  and C matrices
  5. Write the SS skeleton and then fill in the numbers according to the equation coefficients you got from step3!



 So.. how does that feel? I will try to go over a more real life example in next post so that you may get more familiar to this. 



No comments:

Post a Comment