Calculations:: Case I: Manipulated Variable: Heat and Disturbance Variable: Flow Rate
Calculations:: Case I: Manipulated Variable: Heat and Disturbance Variable: Flow Rate
̂ is the Heat deviation variable, 𝐹̂ (𝑠) is the Flow Rate deviation variable, 𝑇̂(𝑠) is the
Here 𝐻(𝑠)
Temperature deviation variable
Case I: Manipulated Variable: Heat and Disturbance Variable: Flow Rate
Gain from positive step: 4.437847
Gain from negative step: 3.974368
Average Estimated Gain: 4.2061075
Case II: Manipulated Variable: Flow Rate and Disturbance Variable: Heat
Gain from positive step: -6.955941
Gain from negative step: -3.359578
Average Estimated Gain: -5.1577595
Manipulated Variable: Heat and Disturbance Variable: Flow Rate, Negative Step
Manipulated Variable: Flow Rate and Disturbance Variable: Heat, Positive Step
Manipulated Variable: Flow Rate and Disturbance Variable: Heat, Negative Step
Controller Tuning:
P Controller:
PI Controller:
1
𝑦(𝑠) 𝐺𝑃 (𝑠)𝐺𝐶 (𝑠) 𝐾𝑃 𝐾𝐶 (1 + 𝜏 𝑠) 𝐾𝑃 𝐾𝐶 (1 + 𝜏𝐼 𝑠)
𝐼
= = ∗ =
𝑟(𝑠) 1 + 𝐺𝑃 (𝑠)𝐺𝐶 (𝑠) 𝜏𝑠 + 1 1 + 𝐾 (1 + 1 𝐾𝑃 𝜏𝜏𝐼 𝑠 + 𝜏𝐼 (1 + 𝐾𝑃 𝐾𝐶 )𝑠 + 𝐾𝑃 𝐾𝐶
𝐶 𝜏𝐼 𝑠) ∗ 𝜏𝑠 + 1
1+𝜏𝐼 𝑠
̂=
b. 𝑇(𝑠) 𝜏𝑃 𝜏𝐼 2 (1+𝐾 𝐾𝐶 )
𝐾𝑃 𝐾𝐶
𝑠 +𝜏𝐼 𝐾 𝑃 𝑠+1
𝑃 𝐾𝐶
Here, 𝜏𝐼 = 208.9719, 𝜏𝑃 = 235.616998, 𝐾𝑃 = 4.206107, 𝐾𝐶 = 1.0675
figure(1);
plot(TIME, INPUT, TIME, OUTPUT),grid;
xlabel('Time'); ylabel('Input and Output(mA)'); title('Raw Step Input Data');
legend('Input', 'Measured Output');
figure(2);
plot(TIME, dev_in, TIME, dev_out),grid;
xlabel('Time'); ylabel('Deviation Input and Output (mA)');
title('Perturbation Data');
legend('Input', 'Measured Output');
delU = INPUT(end)-Us;
Ysf = mean(OUTPUT(end-50:end));
delY = Ysf-Ys;
K0 = (Ysf-Ys)/(INPUT(end)-INPUT(1));
yc = 0.633*(Ysf-Ys);
if(Ysf-Ys>0)
n_c = find(dev_out-yc>=0,1);
else
n_c = find(dev_out-yc<=0,1);
end
n_step = find(dev_in,1);
tau0 = TIME(n_c)-TIME(n_step);
step_out = dev_out(n_step:end);
step_time = TIME(n_step:end)-TIME(n_step);
X0 = [K0, tau0];
Xopt = fminunc('fun',X0);
Kopt = Xopt(1);
tauopt = Xopt(2);
N_op = length(step_time);
step_output_graphical = zeros(N_op, 1);
for i=1:N_op
step_output_graphical(i) = K0*delU*(1-exp(-step_time(i)/tau0));
end
STEP_OUTPUT_GR = step_output_graphical + Ys;
step_output_opt = zeros(N_op, 1);
for i=1:N_op
step_output_opt(i) = Kopt*delU*(1-exp(-step_time(i)/tauopt));
end
STEP_OUTPUT_OPT = step_output_opt + Ys;
STEP_OUTPUT_MEASURED = step_out + Ys;
figure(3);
plot(step_time, STEP_OUTPUT_MEASURED, '-');
hold on
plot(step_time, STEP_OUTPUT_GR, '--');
plot(step_time, STEP_OUTPUT_OPT, '-.');
xlabel('Time');
ylabel('Measured and Predicted Outputs');
title('Comparison of Model Step Responses');
legend('Measured', 'Graphical', 'Optimum');
hold off
Function File:
function fofx=fun(X)
global delU step_out step_time
Kg = X(1);
taug = X(2);
N_op = length(step_time);
dev_output_hat = zeros(N_op,1);
error = zeros(N_op,1);
fofx = 0;
for i=1:N_op
dev_output_hat(i) = Kg*delU*(1-exp(-step_time(i))/taug);
error(i) = step_out(i) - dev_output_hat(i);
fofx = fofx + error(i)^2;
end
end