MATLAB: Limit the chaning rate of a signal

delaysimulink

Hello,
I´m working on a Simulation in Simulink for my masters degree in engineering. In this Simulation there is a valve which controlls the flow of water on one side of a plate heat exchanger based on the outlet tempreture of water on the other side of the exchanger. At the moment this valve is controlled by a thermostat, now it shall be controlled by a electrical engine so that the plant can be controlled electronicly and monitored.
My Problem is now that this engine has a maximum chaning speed e.g when the controller jumps from 0 to its maximum value the engine should need 30 seconds to adjust its position so that the valve is opened completly. I tryed many different solutions but none of them works like they are supposed to be.
function y = fcn(u, du,t)
persistent dy_alt y_alt dy
if isempty(dy_alt)
dy_alt=0;
y_alt=u;
dy=0;
end
while du~=0 || y_alt~=u
if du>0
dy=0.7;
dy_alt=dy;
elseif du<0
dy=-0.7;
dy_alt=dy;
elseif du==0
dy=dy_alt;
end
y=y_alt+dy*t;
if y==u
break
end
end
y=u;
y_alt=y;
end
This is one example of a solution for the problem but it doesent works. The Simulation runs without an error but only until a certain time is reached then it doesnt proceed further.
Has somebody an idea to solve this Problem? Maybe the Solution is easy but i dont see it :/

Best Answer

  • Use the Simulink Rate Limiter block.