I've been seeking help regarding this issue for some time now, I'll
try to explain it as best as I could:

I am simulating a system of ODEs using MATLAB, then as some variables
may be controlled it is required to incorporate a PI controller into
the main system.
Thus a new state variable is added to represent the integral part of
the error related to the difference between the set point &
measurement of the controlled variable, and a new ODE to respresent
the derivative of this error.

so say (ipart) is a new state variable e= reference - So; % error dipart = K/Ti*e; % the additional ODE where K, Ti are the gain & integral time constant of the controller

outputtemp=K*e + ipart; % the value of the controlled variable prior to limitation

if outputtemp <0 outputlim=0; end

if outputtemp > max outputlim =max; end

if 0<=outputtemp<=max outputlim=output; end

then the controlled variable (outputlim) is inserted in its right position within the ODEs.

Now this should represent an ideal PI controller, what if the PI controller experiences time delay & noise, also how could the code be modified to compensate for integral windup.

Please incase the original representation of the ideal PI controller is missing something kindly clarify the missing point as well.

I've no control experience & I've been looking for this information for some time now, so incase someone has an idea of some useful URLs please point them out to me.

I've been trying Google & other search engines & I've found endless information but usually it is too complicated for me to follow & no simple code is provided to help.

I just need simple explaination with a MATLAB code of the PI controller if possible.

Thank you in advance for your assistance.

I am simulating a system of ODEs using MATLAB, then as some variables

so say (ipart) is a new state variable e= reference - So; % error dipart = K/Ti*e; % the additional ODE where K, Ti are the gain & integral time constant of the controller

outputtemp=K*e + ipart; % the value of the controlled variable prior to limitation

if outputtemp <0 outputlim=0; end

if outputtemp > max outputlim =max; end

if 0<=outputtemp<=max outputlim=output; end

then the controlled variable (outputlim) is inserted in its right position within the ODEs.

Now this should represent an ideal PI controller, what if the PI controller experiences time delay & noise, also how could the code be modified to compensate for integral windup.

Please incase the original representation of the ideal PI controller is missing something kindly clarify the missing point as well.

I've no control experience & I've been looking for this information for some time now, so incase someone has an idea of some useful URLs please point them out to me.

I've been trying Google & other search engines & I've found endless information but usually it is too complicated for me to follow & no simple code is provided to help.

I just need simple explaination with a MATLAB code of the PI controller if possible.

Thank you in advance for your assistance.