# Adding a delay in state space form

12 views (last 30 days)
Kashish Pilyal on 31 May 2022
Commented: Kashish Pilyal on 2 Jun 2022
I have a control block diagram
The value of tf_b is written as
tf_b=((0.5*s)+1)/(s^2)*(kp + kd*s);
The transport delay block is equivalent to value of . I made a state space form of the above system. It is written as:
I tried adding a delay as shown in the diagram.
sys=ss(A,B,C,D,'InputDelay',theta,'OutputDelay',0);
The simulink model and the state space give different settling times when given as step input. The settling time for the simulink model is 1.82 appoximately and for the state space is 1.97. Is there something I can do to correct this or add a delay properly?

Paul on 1 Jun 2022
The command
sys=ss(A,B,C,D,'InputDelay',theta,'OutputDelay',0);
puts a delay on the input signal, i.e., at the output of the a1input block to the left of the node (assuming that A,B,C,D as written is the state space model for the Simulink block diagram, but with zero transport delay; I did not verify this myself). In other words, the delay is applied to both forward paths, not just the "upper" path.
Paul on 1 Jun 2022
I don't believe that a system with a delay can be represented in the simple A,B,C,D form.
This doc page should be of interest.
The E term shows up when the system is reperesented in descriptor form.
Though you're not showing your code, I suspect that the descriptor form you're seeing is because you're constructing the model using "transfer function math," like so:
s = tf('s');
Gamma2 = ((exp(-0.02*s)*s^2)+(0.6*s)+0.2)/((0.5*s+1)*(s^2+(0.6*s)+0.2));
Gamma2
Gamma2 = A = x1 x2 x3 x4 x5 x6 x7 x8 x1 1 0 0 0 0 0 0 0 x2 0 1 0 0 0 0 0 0 x3 0 0 1 0 0 0 0 -2 x4 0 0 0 1 0 0 0 0 x5 0 0 0 0 1 0 0 -2 x6 0 0 0 0 0 -2.6 -1.4 -0.8 x7 0 0 0 0 0 1 0 0 x8 0 0 0 0 0 0 0.5 0 B = u1 x1 0 x2 0 x3 0 x4 0 x5 0 x6 2 x7 0 x8 0 C = x1 x2 x3 x4 x5 x6 x7 x8 y1 1 0 0 0.6 0 0 0 0.4 D = u1 y1 0 E = x1 x2 x3 x4 x5 x6 x7 x8 x1 0 1 0 0 0 0 0 0 x2 0 0 1 0 0 0 0 0 x3 0 0 0 0 0 0 0 0 x4 0 0 0 0 1 0 0 0 x5 0 0 0 0 0 0 0 0 x6 0 0 0 0 0 1 0 0 x7 0 0 0 0 0 0 1 0 x8 0 0 0 0 0 0 0 1 (values computed with all internal delays set to zero) Internal delays (seconds): 0.02 Continuous-time state-space model.
Note also that the model has eight states.
I don't have a clear explanation as to why this results in a descriptor form, but I suspect it has to do with how the Control System Toolbox represents that first term in Gamma2 with the delay, and then combines that with all the other terms.
However, transfer function math is generally not recommended; instead use the interconnection fucntions, like so (based on the similar problem discussed here)
Kp = 0.1; Kd = 0.6; theta = 0.02;
pid = Kp + Kd*s;
P = tf(1,[.5 1]);
H = tf([.5 1],[1 0 0]);
clsys = series(parallel(exp(-theta*s),pid/s^2),feedback(P,series(pid,H)));
clsys
clsys = A = x1 x2 x3 x4 x5 x1 -2.6 -1.3 -0.4 1.2 0.2 x2 1 0 0 0 0 x3 0 0.5 0 0 0 x4 0 0 0 0 0 x5 0 0 0 1 0 B = u1 x1 2 x2 0 x3 0 x4 1 x5 0 C = x1 x2 x3 x4 x5 y1 1 0 0 0 0 D = u1 y1 0 (values computed with all internal delays set to zero) Internal delays (seconds): 0.02 Continuous-time state-space model.
Note that clsys doesn't include the E and it also only has 5 states, likely because the CST is smarter when it uses interconnection functions (link).
However, Gamma2 and clsys both represent the same dynamics
bode(Gamma2,clsys)
Kashish Pilyal on 2 Jun 2022
Thank you for the help again. I believe this much will have to suffice for now.

### Categories

Find more on MATLAB in Help Center and File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!