Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Implementing a discrete PI Controller

Status
Not open for further replies.

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 = (y);
% 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor