2
\$\begingroup\$

I am trying to design a Luenberger observer (or a full state feedback observer) such that with one sensor available I can estimate all the states. A good tutorial is shown here.

My system is 4th order:

num = [-0.00198 2];
den = [1 0.1201 12.22 0.4201 2];
sys = tf(num,den);
[A, B, C, D] = tf2ss(num,den);

First I have a row vector of poles to get my desired response:

poles = [-2.6 + 1i*2.39, -2.6 - 1i*2.39, -100, -120];
K = acker(A,B,poles)
rank(obsv(A,C));  % =4
Mo = rank([C;C*A;C*A^2;C*A^3]) % =4

I then proceed to calculate the plant poles and thus the poles I want for my observer should be around 3x faster.

plant = (A-B*K);
poles_cl = eig(plant)

poles = 3*poles_cl  % THIS IS WRONG
des_poles = (min(real(poles_cl))*3)-(1:4); %This is better

des_poles =

 -361.0000 -362.0000 -363.0000 -364.0000

I then proceed to use Ackermann's formula for pole placement using the new poles:

% design observer by placing poles of A-LC at des_poles 
L=acker(A',C',poles_des)'
eig_obs = eig(A-L*C) 

L =

   1.0e+09 *

    8.6121
    0.1037
    0.0005
    0.0000

eig_obs =

 -361.0000
 -362.0000
 -363.0000
 -364.0000

And finally plot. For the observer (software) to give us all the states as output we need to set C = eye(4):

C = eye(4);
mysys=ss(A-L*C,[B L],C,0); %Not sure if this is correct
tf(mysys)
step(mysys)

Four outputs can be seen:

enter image description here

Following this model for a full state feedback observer:

enter image description here

I am then trying to verify the results on Simulink and am having issue with the block diagram. As can be seen I have two state space models, one for the real plant and one for the observer.

In the below diagram I am comparing state 1, which results in the second graph depicted below.

enter image description here

I am using the base workspace generated by the code above:

enter image description here

Upon running I get an output from the observer which does not track or follow the plant as expected:

Actual and Observer states when comparing state 4 through summing block:

enter image description here

Actual and Observer states when comparing state 1 through summing block:

enter image description here

Any suggestions on why the state I choose to compare via the summing block is effecting the observer estimations would be appreciated.


Observer Parameters:

enter image description here

Plant Parameters:

enter image description here

  1. Why does the state which I am comparing, effect the observer response?
\$\endgroup\$
7
  • \$\begingroup\$ First -- I thought a Luenberger observer is reduced-state. Doesn't that mean a 3-state observer? \$\endgroup\$
    – TimWescott
    Commented Dec 23, 2018 at 20:41
  • \$\begingroup\$ Second -- did you look at the resulting system matrices and vectors, to make sure the values looked reasonable? \$\endgroup\$
    – TimWescott
    Commented Dec 23, 2018 at 20:42
  • \$\begingroup\$ Third -- you may want to put together the augmented system (plant model + observer), check it visually to see if it looks reasonable, and then to simulate it (I assume you use step, but I'm a Scilab guy not a Matlab guy). \$\endgroup\$
    – TimWescott
    Commented Dec 23, 2018 at 20:43
  • 1
    \$\begingroup\$ @TimWescott, yes resulting eigenvalues and matrices for eig(A-B*K) and eig(A-L*C), were checked and all seemed to be reasonable. \$\endgroup\$
    – rrz0
    Commented Dec 24, 2018 at 9:18
  • \$\begingroup\$ @TimWescott, using a Luenberger observer I should be able to estimate all states from a single state. The Luenberger observer is a minimum order observer such that it is designed to reconstruct all state variables. \$\endgroup\$
    – rrz0
    Commented Dec 28, 2018 at 12:00

2 Answers 2

2
+50
\$\begingroup\$

This answer pertains to the question title "How to design an observer to estimate all states from a single sensor".

I'm pretty sure that you have the input vector to the compensator reversed. You either need to reverse the order that signals go into the multiplexer, or you need to reverse the order of the B matrix in the compensator (by changing it to [L B]. For reference here's a picture.

By picking off the \$x_1\$ term from your state vector you are also effectively using \$C=\left[\matrix{1 & 0 & 0 & 0}\right]\$. See the picture. I suspect, but do not know, that the tf2ss function returns C=[0 0 0 1], you should check this.

enter image description here

Note that Simulink will let you draw out the compensator pretty much the way it's done here -- it'll accept matrix gains and carry vector signals, and IIRC integrate vectors. So you can have a complete block diagram of what you want, instead of trying to get all the graphical 'i's and 't's dotted to match the textual specification in the definition block.

Figure 4.2-1 from *Linear Systems*

From Linear Systems, Kailath, Prentice-Hall, 1980.

\$\endgroup\$
14
  • \$\begingroup\$ Thanks for your answer, I changed the order of the B matrix and unexpectedly Simulink is now taking approximately 10 minutes to get to 1% completion. According to this link it should be [B L]. \$\endgroup\$
    – rrz0
    Commented Dec 28, 2018 at 22:02
  • 1
    \$\begingroup\$ According to that link, the plant input is going into the top of the multiplexer, and the observer feedback is going to the bottom. You have that order reversed in your diagram. \$\endgroup\$
    – TimWescott
    Commented Dec 28, 2018 at 22:09
  • 1
    \$\begingroup\$ For a test, try setting your k values to zero and see if your observer follows your plant. That'll at least tell you if the observer is working correctly. \$\endgroup\$
    – TimWescott
    Commented Dec 28, 2018 at 22:11
  • \$\begingroup\$ Yes, setting the K to zero gives good approximations, even though the gain is still off. \$\endgroup\$
    – rrz0
    Commented Dec 28, 2018 at 22:18
  • 1
    \$\begingroup\$ Answer edited. I really do understand that C = eye(4) means that you're telling Simulink that C is the identity matrix. But picking off \$x_1\$ to use for feedback means that you are effectively setting C = [1 0 0 0]. \$\endgroup\$
    – TimWescott
    Commented Dec 29, 2018 at 18:59
1
\$\begingroup\$

This answer pertains to the current title ("Why Does Tracking Different Plant States Result In Totally Different Observer Estimates").

The answer is -- turn off Matlab until you know what you're doing, and then do the math. The answer should be clear. If it's not, do the math some more.

The observer equations (from the picture in my first answer) are $$ \frac{d\hat{x}}{dt} = A \hat{x} + B u + L\left(y - \hat{y}\right), \hat{y} = C \hat{x}$$

Using simple linear algebra, you can eliminate the reference to \$\hat{y}\$ in the first equation:$$ \frac{d\hat{x}}{dt} = \left(A - LC\right) \hat{x} + \left[\matrix{B & L}\right] \left[\matrix{u \\ y}\right], \hat{y} = C \hat{x}$$

The phrase "Tracking different plant states" translates, mathematically, to "changing the value of \$C\$". Looking at the second equation above, it's pretty obvious that if \$A - LC_1 \ne A - LC_2\$, then the two systems are going to act differently. It's really that simple.

\$\endgroup\$
5
  • \$\begingroup\$ Thanks for the above explanation. The math makes more sense now, however even though it may seem simple to you, I am not fully understanding how this can be solved. While I get that A-LC1 is not equal to A-LC2, I still need a way to be able to track all plant states from any single plant state.. I would have thought that from any state (or any value of C) the observer would be able to track the other states accordingly. As I present in the question (and as you show above) this is certainly not the case. \$\endgroup\$
    – rrz0
    Commented Dec 30, 2018 at 9:44
  • \$\begingroup\$ I may be going off in a tangent or not replying directly to your answer but, the plant states should be estimated irrespective of which state I choose to track. \$\endgroup\$
    – rrz0
    Commented Dec 30, 2018 at 9:57
  • \$\begingroup\$ In a word, no. Just to save space, assume a 2nd-order system with \$A=\left[\matrix{-3 & 0 \\ 1 & -3}\right]\$, \$B=\left[\matrix{1 \\ 0}\right]\$ and \$C=\left[\matrix{0 & 1}\right]\$. That's an observable system, because \$x_1\$ is directly affected by the input, and \$x_2\$ is directly affected by \$x_1\$. Now change \$C\$ to \$C=\left[\matrix{1 & 0}\right]\$. Intuitively, the system is no longer observable because \$x_1\$ is unaffected by \$x_2\$. \$\endgroup\$
    – TimWescott
    Commented Dec 30, 2018 at 16:18
  • \$\begingroup\$ Mathematically, the system is no longer observable because the observability check matrix is singular: \$O=\left[\matrix{1 & 0 \\ -3 & 0}\right]\$. \$\endgroup\$
    – TimWescott
    Commented Dec 30, 2018 at 16:20
  • \$\begingroup\$ This set of lecture notes (pulled randomly from the Internet -- it makes sense but I make no guarantees) explains checking for observability. If it's entirely new to you I suggest you get a good book on state space control and study up. If it reminds you of something you've been taught, I suggest you pull out your old book and notes and study up. \$\endgroup\$
    – TimWescott
    Commented Dec 30, 2018 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.