brypat
Electrical
- Mar 18, 2006
- 1
Hi,I'm relatively new to Matlab and am trying to implement a discrete PI controller to a simulation of an ammonia plant. The problem is that I don't know how to do it using Matlab code, as i'm used to simulink, and was wondering if anyone could help. Below is the code i've started with:
%PI Controller
dt = 10; % Time Sample [secs]
kp = 10; % Proporsional Gain
ki = 4; % Integral Gain
eIntegral =
;
% New Setpoint after 1000 seconds
if i == 1000
yset = u1;
end
% Setpoint error
if mod(i,dt) == 0
e = yset - y(30);
eIntegral = eIntegral + e*dt
P(u) = kp*e + ki*eIntegral;
end
I want it to implement after a stepchange at 1000 secs. This doesn't work, does anyone know why??
Thanks,
Bryan
%PI Controller
dt = 10; % Time Sample [secs]
kp = 10; % Proporsional Gain
ki = 4; % Integral Gain
eIntegral =
% New Setpoint after 1000 seconds
if i == 1000
yset = u1;
end
% Setpoint error
if mod(i,dt) == 0
e = yset - y(30);
eIntegral = eIntegral + e*dt
P(u) = kp*e + ki*eIntegral;
end
I want it to implement after a stepchange at 1000 secs. This doesn't work, does anyone know why??
Thanks,
Bryan