Plot step response for control signal (u1 u2 ...) in a MIMO system with feedback

조회 수: 23 (최근 30일)
0) Especify aditional variables and its values (use space as separator)
otherVars = "K1 K2 B1 B2 m1 m2"; otherVars = split(otherVars);
valueVars = "1 1 1 1 1 1"; valueVars = split(valueVars);
if length(otherVars) == length(valueVars)
arrayfun(@eval,strcat(otherVars,'=',valueVars));
else
warning("Number of variables not equal to its values")
return
end
K1 = 1
K2 = 1
B1 = 1
B2 = 1
m1 = 1
m2 = 1
1) Define the state space matrices
% STATE SPACE REPRESENTATION
AA = [0 0 1 0;0 0 0 1;-K1/m1 K1/m1 -B1/m1 B1/m1;K1/m2 -(K1+K2)/m2 -B1/m2 -(B1+B2)/m2];
BB = [0 0;0 0;1/m1 0;0 1/m2];
CC = [1 0 0 0;0 1 0 0];
DD = [0 0;0 0];
1.1) Define the value of for every
T = [4 4]; I = eye(size(DD,1)); s = tf('s');
2) Obtain the plant transfer function
Gp = tf(ss(AA,BB,CC,DD))
Gp = From input 1 to output... s^2 + 2 s + 2 1: ----------------------------- s^4 + 3 s^3 + 6 s^2 + 4 s + 1 -s + 1 2: ----------------------------- s^4 + 3 s^3 + 6 s^2 + 4 s + 1 From input 2 to output... s + 1 1: ----------------------------- s^4 + 3 s^3 + 6 s^2 + 4 s + 1 s^2 + s + 1 2: ----------------------------- s^4 + 3 s^3 + 6 s^2 + 4 s + 1 Continuous-time transfer function.
Gp.TimeUnit = 'seconds';
Gp.InputName = 'u';
Gp.OutputName = 'y';
3) Obtain the open loop transfer function
Go = (1/s)*diag(1./T)
Go = From input 1 to output... 0.25 1: ---- s 2: 0 From input 2 to output... 1: 0 0.25 2: ---- s Continuous-time transfer function.
4) Obtain the full process transfer function
G = feedback(Go,I)
G = From input 1 to output... 0.25 1: -------- s + 0.25 2: 0 From input 2 to output... 1: 0 0.25 2: -------- s + 0.25 Continuous-time transfer function.
5) Obtain the PID controller block transfer function
Gc = Gp\Go; Gc = minreal(Gc)
Gc = From input 1 to output... 0.25 s^2 + 0.25 s + 0.25 u(1): ------------------------ s - 2.378e-15 0.25 s - 0.25 u(2): ------------- s - 1.513e-15 From input 2 to output... -0.25 s - 0.25 u(1): -------------- s - 1.644e-15 0.25 s^2 + 0.5 s + 0.5 u(2): ---------------------- s + 4.121e-15 Continuous-time transfer function.
Gc.TimeUnit = 'seconds';
Gc.InputName = 'e';
Gc.OutputName = 'u';
6) Plot the step response from input r to output y
timeLimit = 40;
Sum1 = sumblk('e=r-y',size(T,2));
Cnt = connect(Gc,Gp,Sum1,'r','y','u');
step(Cnt,timeLimit,'r'), grid on
7) Plot the response from input r to output u (problem here)
Tp = getIOTransfer(Cnt,'r','u');
step(Tp,timeLimit,'r'), grid on
Error using DynamicSystem/step
Cannot simulate the time response of improper (non-causal) models.
I want to obtain the plots for U as this one, is the same problem but the data is obtained through a for loop
This is the original diagram block that I'm trying to simulate without using for loops

채택된 답변

Amey Waghmare
Amey Waghmare 2022년 11월 25일
As per my understanding, you want to plot the response of the system from ‘r’ to ‘u’ but receive the error Cannot simulate the time response of improper (non-causal) models’.
In order to obtain the step response of a system, the system should be ‘causal’ or ‘proper’. A proper system is a one having at least as many poles as zeros or number of poles is greater than number of zeros. To check if a system is proper, you can use the following command;
isproper(sys)
In the code, the Transfer function ‘Tp’ is improper, specifically the transfer functions from r1 to u1 and r2 to u2 are non-causal, with number of poles being 12 and number of zeros being 13 and hence it is not possible to obtain the step response.
  댓글 수: 2
Cesar Adolfo Cruz Vargaya
Cesar Adolfo Cruz Vargaya 2022년 11월 25일
편집: Cesar Adolfo Cruz Vargaya 2022년 11월 26일
Thanks for the answer, as you've stated, it's true that the function Tp is improper. After running step by step I've noticed that my Tp function, which is the controller block, has more poles and zeros than it has to have. In fact, I should've obtained the same T.F. as specified in the fifth step, where Gc is my controller. I tried to use minreal, but that only works when doing manually. It appears that the connect command doesn't take that in account. Additionally, if I recall correctly, if a T.F. is improper then it's graph shouldn't be able to tend to a value. But as shown in the last picture, the response of u1 and u2 is stable and tends to a value.
Pd: I've checked my teacher code, and in the plot code, he changed the ccontroller values,here is the right image with the original values, and as I've stated, both of them (u1 and u2) tend to a value
Paul
Paul 2022년 11월 26일
Hi Cesar,
Tp is not the controller block. That is, Tp is not equal to Gc. Tp is the closed-loop transfer function from r to u; Gc is just the transfer function from e to u. These are not the same thing.
Correct. connect does not execute minreal AFAIK. But I don't see how that's relevant here.
Can you clarify this statement: "if a T.F. is improper then it's graph shouldn't be able to tend to a value."
The design approach used in the Question could be slightly modified so that we can generate the step response from r to us. But those won't look like either set of plots that have been shown.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sam Chak
Sam Chak 2022년 11월 26일
The original plant is a coupled 2nd-order MIMO system. If the desired closed-loop transfer function is a 1st-order system, this suggests there is loss of information, and in your case, the velocity becomes unobservable.
By redesigning your desired , see example below, you should be able to make proper.
Moreover, the settling time of the closed-loop transfer function is almost the same as the time in the previous .
otherVars = "K1 K2 B1 B2 m1 m2"; otherVars = split(otherVars);
valueVars = "1 1 1 1 1 1"; valueVars = split(valueVars);
if length(otherVars) == length(valueVars)
arrayfun(@eval,strcat(otherVars,'=',valueVars));
else
warning("Number of variables not equal to its values")
return
end
K1 = 1
K2 = 1
B1 = 1
B2 = 1
m1 = 1
m2 = 1
AA = [0 0 1 0;0 0 0 1;-K1/m1 K1/m1 -B1/m1 B1/m1;K1/m2 -(K1+K2)/m2 -B1/m2 -(B1+B2)/m2];
BB = [0 0;0 0;1/m1 0;0 1/m2];
CC = [1 0 0 0;0 1 0 0];
DD = [0 0;0 0];
T = [4 4];
I = eye(size(DD, 1));
s = tf('s');
Gp = tf(ss(AA, BB, CC, DD))
Gp = From input 1 to output... s^2 + 2 s + 2 1: ----------------------------- s^4 + 3 s^3 + 6 s^2 + 4 s + 1 -s + 1 2: ----------------------------- s^4 + 3 s^3 + 6 s^2 + 4 s + 1 From input 2 to output... s + 1 1: ----------------------------- s^4 + 3 s^3 + 6 s^2 + 4 s + 1 s^2 + s + 1 2: ----------------------------- s^4 + 3 s^3 + 6 s^2 + 4 s + 1 Continuous-time transfer function.
Gp.TimeUnit = 'seconds';
Gp.InputName = 'u';
Gp.OutputName = 'y';
w = 5/13;
Go = tf(w^2, [1 2*w 0])
Go = 0.1479 -------------- s^2 + 0.7692 s Continuous-time transfer function.
Gc = Gp\Go;
Gc = minreal(Gc)
Gc = From input "y(1)" to output... 0.1479 s^2 + 0.1479 s + 0.1479 u(1): ------------------------------ s^2 + 0.7692 s 0.1479 s - 0.1479 u(2): ----------------- s^2 + 0.7692 s From input "y(2)" to output... -0.1479 s - 0.1479 u(1): ------------------ s^2 + 0.7692 s 0.1479 s^2 + 0.2959 s + 0.2959 u(2): ------------------------------ s^2 + 0.7692 s Continuous-time transfer function.
Gc.TimeUnit = 'seconds';
Gc.InputName = 'e';
Gc.OutputName = 'u';
timeLimit = 40;
Sum1 = sumblk('e = r - y', size(T, 2));
Cnt = connect(Gc, Gp, Sum1, 'r', 'y', 'u');
step(Cnt, timeLimit), grid on
Tp = getIOTransfer(Cnt, 'r', 'u');
Tp = minreal(tf(Tp))
Tp = From input "r(1)" to output... 0.1479 s^14 + 1.377 s^13 + 6.816 s^12 + 22.15 s^11 + 51.71 s^10 + 90.14 s^9 + 119.6 s^8 + 121.7 s^7 + 94.97 s^6 + 56.18 s^5 + 24.7 s^4 + 7.804 s^3 + 1.673 s^2 + 0.2175 s + 0.01295 u(1): --------------------------------------------------------------------------------------------------------------------------------------------------------------- s^14 + 9.077 s^13 + 43.31 s^12 + 134.2 s^11 + 294.1 s^10 + 472.1 s^9 + 562.6 s^8 + 500.1 s^7 + 331.8 s^6 + 163.4 s^5 + 58.89 s^4 + 15.09 s^3 + 2.606 s^2 + 0.2719 s + 0.01295 0.1479 s^13 + 1.081 s^12 + 4.21 s^11 + 10.05 s^10 + 15.3 s^9 + 13.08 s^8 + 1.061 s^7 - 11.99 s^6 - 15.83 s^5 - 10.96 s^4 - 4.689 s^3 - 1.25 s^2 - 0.1916 s - 0.01295 u(2): --------------------------------------------------------------------------------------------------------------------------------------------------------------- s^14 + 9.077 s^13 + 43.31 s^12 + 134.2 s^11 + 294.1 s^10 + 472.1 s^9 + 562.6 s^8 + 500.1 s^7 + 331.8 s^6 + 163.4 s^5 + 58.89 s^4 + 15.09 s^3 + 2.606 s^2 + 0.2719 s + 0.01295 From input "r(2)" to output... -0.1479 s^13 - 1.377 s^12 - 6.668 s^11 - 20.92 s^10 - 46.27 s^9 - 74.65 s^8 - 88.8 s^7 - 77.87 s^6 - 50.04 s^5 - 23.25 s^4 - 7.599 s^3 - 1.66 s^2 - 0.2175 s - 0.01295 u(1): --------------------------------------------------------------------------------------------------------------------------------------------------------------- s^14 + 9.077 s^13 + 43.31 s^12 + 134.2 s^11 + 294.1 s^10 + 472.1 s^9 + 562.6 s^8 + 500.1 s^7 + 331.8 s^6 + 163.4 s^5 + 58.89 s^4 + 15.09 s^3 + 2.606 s^2 + 0.2719 s + 0.01295 0.1479 s^14 + 1.525 s^13 + 8.193 s^12 + 28.82 s^11 + 72.63 s^10 + 136.4 s^9 + 194.2 s^8 + 210.5 s^7 + 172.8 s^6 + 106.2 s^5 + 47.95 s^4 + 15.4 s^3 + 3.332 s^2 + 0.4351 s + 0.0259 u(2): --------------------------------------------------------------------------------------------------------------------------------------------------------------- s^14 + 9.077 s^13 + 43.31 s^12 + 134.2 s^11 + 294.1 s^10 + 472.1 s^9 + 562.6 s^8 + 500.1 s^7 + 331.8 s^6 + 163.4 s^5 + 58.89 s^4 + 15.09 s^3 + 2.606 s^2 + 0.2719 s + 0.01295 Continuous-time transfer function.
step(Tp, timeLimit, 'r'), grid on

카테고리

Help CenterFile Exchange에서 Classical Control Design에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by