Simulink state space observer output issue

31 views (last 30 days)
Hello everyone. For my simulink state space observer system, I set up two models based on the same system. One model that doesn't use the 'state space block', and another one that uses the 'state space block'. The 'state space block' was configured (with the A, B, C, D matrices) to be the equivalent to my graphical interconnected blocks observer system model.
The output of the graphical interconnected block observer model is mostly satisfactory - except, I notice that the plotted output always spikes or rockets up to large value at the 'end time'. So if I choose a simulation end-time of 0.5 seconds, then the spike occurs at 0.5 seconds. And if I choose the simulation end time to end at 10 seconds, then the spike will occur at 10 seconds, while the general output response is satisfactory for times well below 10 seconds. Same if I were to choose an end time of 20 seconds. The spike would occur at 20 seconds.
However, for the compact 'state space block' model of the observer system. Equivalent system. The output never gets that spiking (which is good).
Woud anyone have any ideas about the reason for spiking seen only at the end-time? And anything we can try - so that the spike at the end time doesn't occur for the blocks-connected observer model? Thanks all!
  4 Comments
Paul
Paul on 2 Aug 2023
Is there any difference between the two Simulink diagrams shown above?
What is implemented in the A,B,C,D matrices in the State Space block in the lower right of the block diagrams?
Kenny
Kenny on 3 Aug 2023
Hi @Paul ! I just spent ages - typing a reply to you in the editor. Only to find that my time was totally wasted - because at the very end of my long reply, I was simply trying to upload screenshots. And when I dragged an image to the uploader window, a pop-up window arose and prompted - 'leave page, or stay on page'. Now I realise that this editor has drag-drop for files, but no 'drag-drop' for images. I assumed I needed to just click on 'leave page' and let the software do whatever it was trying to do. And surprisingly - and disappointingly - it went to another page - so the reply that I typed was just completely lost. No trace of it when I used the 'back' (arrow) in the web-browser.
That's ok. The state space block in the lower right was meant to model the combination of a simulated actual second order system, plus the observer (estimator) system, and also the observer error system. Those three systems combined.
With Sam's help, I now realise that my design of the observer gain matrix L was using the wrong approach. Instead of designing 'L' based on [A - LC] system matrix, I incorrectly based the design on {[A-BK] - LC}, where the A-BK is effectively a state feedback system matrix. Sam showed that the error system matrix to use for design of L is indeed just A - LC, where 'A' does not involve the state feedback.
Also, I found in my calculations for 'L', that I used incorrect coefficients - calculation error. I have corrected the calculations - and now getting satisfactory results now.
I will upload the amended simulink project file here, and add the screenshots again. This time, I will select all of my text and copy to buffer memory -- just in case!
Thanks for your question Paul!

Sign in to comment.

Accepted Answer

Sam Chak
Sam Chak on 2 Aug 2023
See my analysis below:
A = [0 1; 0 -32]; % state matrix
B = [0; 8]; % input matrix
C = [1 0]; % output matrix
D = 0; % direct matrix
K = [256 4]; % controller gain matrix
L = [64; -4096]; % observer gain matrix
a1 = A - B*K;
a2 = B*K;
a3 = zeros(2);
a4 = A - L*C;
Aa = [a1 a2; a3 a4] % state matrix of feedback system with a controller-observer.
Aa = 4×4
0 1 0 0 -2048 -64 2048 32 0 0 -64 1 0 0 4096 -32
% Eigenvalues of the closed-loop system with observed-state feedback
eig(Aa)
ans =
1.0e+02 * -0.3200 + 0.3200i -0.3200 - 0.3200i -1.1397 + 0.0000i 0.1797 + 0.0000i
As you can see, one eigenvalue has the positive real part. This explains why the trajectory is unstable.
  5 Comments
Sam Chak
Sam Chak on 2 Aug 2023
Thanks for your clarification, @Kenny
If a4 = a1 - L*C, all eigenvalues have negative real parts. However, this theoretical stable result contradicts with the divergent behavior as seen in Simulink.
A = [0 1; 0 -32]; % state matrix
B = [0; 8]; % input matrix
C = [1 0]; % output matrix
D = 0; % direct matrix
K = [256 4]; % controller gain matrix
L = [64; -4096]; % observer gain matrix
a1 = A - B*K;
a2 = B*K;
a3 = zeros(2);
a4 = a1 - L*C; % <--- according to Kenny
Aa = [a1 a2; a3 a4]; % state matrix of feedback system with a controller-observer.
eig(Aa)
ans =
1.0e+02 * -0.3200 + 0.3200i -0.3200 - 0.3200i -0.1875 + 0.0000i -1.0925 + 0.0000i
Correct me if I'm wrong. I tried substituting , but it got eliminated at the end, leading to the orignal result presented above. I believe there must be something that explains the divergent (unstable) behavior.
When Eq. (3) is subtracted from Eq. (1),
Kenny
Kenny on 2 Aug 2023
Edited: Kenny on 2 Aug 2023
Thanks for adding those details above. Earlier, I did write u = r - Kx. I had overlooked the situation - where the state-feedback to the two sub-systems is based on the estimated state vector 'x_hat', instead of state vector 'x'.
Thanks to you Sam, as I overlooked that condition. So u will correctly be r - K.x_hat
So the difference x_dot - x_hatdot will indeed be [A - LC].(x - x_hat), as you correctly had it from the beginning.
I'll redesign the observer gain matrix elements in L based on the correct observer error system matrix
[A - LC], and will get some simulink simulations to add here.
Also - fully agree with you about the divergent behaviour - difficult to explain based on the behaviour occuring in the vicinity of the end-time for simulations. Absolutely and genuinely appreciated (and appreciating) your help. I would have continued to assume (without knowing for some indefinite amount of time) that the observer error system matrix is incorrect {[A-BK] - LC}, when it really is [A - LC]. Thanks Sam.

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!