MATLAB: Simulink Limit Integral Saturation Limit Dynamic Input

blockintegrationlimit integralsimulationsimulink

Hello.
I would like to find out if there is a way to use a variable input computed within a given Simulink session as a limit integral saturation limit in the Simulink integrator block. The limit integral block parameters allows entering a variable name or a constant. The block entry can import a vector present on the workstpace, though it's not capable of reading a variable that is dynamically being computed at the same simulation execution frame as the limit integrator.
I have tried to incorporate a unit delay or memory block in the integrator input to delay the integrator and allow the computed limit integral saturation variable to be computed prior being read by the integrator block. Unfortunately the integrator fails to execute unless the saturation variable has been already computed and available in the workspace.
I'd appreciate it if someone can assist me with this issue.
Thanks! Nima

Best Answer

As you have found out, the Limited Integrator block from the Simulink Library only takes the saturation limits as a parameter, and not as an input signal. I would recommend that you read this blog post to understand why you cannot change the saturation limit parameter based on the output of another block.
However, it should be reasonable straightforward to create your own custom block using S-functions to do what you need. There is an existing S-function block demo that you can modify to achieve what you need. Please type "msfcndemo_limintm" at the MATLAB prompt to open up the demo. Now, double click on the blue box in the model to see the MATLAB code corresponding to the S-function. You simply need to increase the number of inputs to 3, and use the inputs instead of the parameters for limits in the Derivative method.
Related Question