Code only - step disturbance at 40 seconds

2 次查看(过去 30 天)
Hi All,
Can anyone help me with pure code for a step disturbace at 40 seconds? I dont want to use symulink for this project and i am interested in the fundamentals.
I need to test the tuning by applying a step disturbance at 40 seconds to see how the controller responds in each case.
Help very much appreiciated!!
Question:
what is the code to implement a step disturbance in the system at 40 seconds that would test the disturbance rejection of the controller and allow the system to return to 1?
Disturbance is defined as G_Disturbance in the below code.
matlab version R2018b
load time.dat
load response.dat
plot (time,response,'g');
title ('Actual response')
xlabel ('Time')
ylabel ('Amplitude')
hold on
s=tf('s')
K = 2;
tau = 3;
sysmod = exp(-s)*(K/(tau*s+1))
plot (time,response,'g');
hold on
step (sysmod,'k')
title ('System Model Step Response')
hold off
Applying the Hagglund-Astrom Tuning
theta = 0.1; % Defines the dead time in the process
kp = (0.14/K)+((0.28*tau)/(theta*K)) % Defines the Proportional element CORRECT
ki = ((0.33*theta) + ((6.8*theta*tau)/(10*theta+tau))) % Defines the Integral element CORRECT
G_disturbance = (exp(-40*s)*(1)) % Function for the disturbance
%haggast1 = feedback ((kp + (ki/s)) * sysmod,1); % Applying the Hagglund-Astrom tuning
haggast1 = feedback ((K*(1+(ki/kp)/s)) * sysmod,1);
step (haggast1,'g')
hold on
step (sysmod,'k')
title ('Haggland-Astrom Tuning')
%step (G_disturbance + haggast1,'r',60) % Applying Disturbance
legend ('haggast1','sysmod','disturbance')
hold off
Applying the Cohen and coon PI Tuning
theta1 = 0.1;
kp1 = (1/K)*(tau/theta1)*(0.9+(theta1/(12*tau))) % Defines the Proportional element CORRECT
ki1 = (theta1*(30+(3*(theta1/tau))) / (9+(20*(theta1/tau)))) % Defines the Integral element CORRECT
%CC = feedback ((kp1 + ki1/s) * sysmod,1); % Applying the Cohen Coon tuning
CC = feedback ((K*(1+(ki1/kp1)/s)) * sysmod,1);
step (CC,'g',100)
hold on
step (sysmod,'k')
title ('Cohen Coon Tuning')
legend ('CC','sysmod')
hold off
Ziegler-Nichols Reaction curve PID settings
RN = 13;
L = 0.1;
Kp_P = 1/(RN*L);
Kp_PI = 0.9/(RN*L);
Kp_PID = 1.2/(RN*L);
Ki_PI = 3*L;
Ki_PID = 2*L;
Kd_PID = 0.5*L;
ZN_P = feedback ((Kp_P)*sysmod,1);
ZN_PI = feedback ((Kp_PI + Ki_PI/s) * sysmod,1);
ZN_PID = feedback ((Kp_PID + Ki_PID/s + s*Kd_PID) * sysmod,1);
step (ZN_PID,'b')
hold on
step (ZN_PI,'y')
step (ZN_P,'g')
title ('Ziegler Nichols')
legend ('PID','PI','P')
hold off
  2 个评论
Toby Russell
Toby Russell 2020-8-25
Good Morning,
Thank you for your reply.
OK, sorry for the lacking info.
the data files are attached, not possible to load .dat here so they are in excel format.
below is a copy of latest code, I am running a live script for this.
Question:
  1. is it possible to code a step disturbance to occur at 40 seconds that would test the conntrollers disturbance rejection and allow the controler to return the output to 1?
  2. how would this be achieved in code?
MATLAB version - R2018b
I will edit the code in my origninal question to show the lastest verion of where I am. Iam using G_Disturbance to define the disturbance.
best regards
Toby

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by