Alerts vs Parameters in Simulink
In Simulink there are two varieties of knowledge:
- Alerts: Represented by sign traces within the Simulink canvas, any such knowledge is anticipated to doubtlessly change at each time step
- Parameters: Handed to Simulink blocks as MATLAB variables, any such knowledge is meant to stay fixed or adjustments sometimes.
This raises the query: Why can I not make any block dialog parameter an enter sign?
My clarification is that some block algorithms are making assumptions that parameters will change sometimes. Altering these at each time step would result in outcomes that might be obscure, or fully incorrect relying in your assumptions.
Within the subsequent two sections, I describe easy methods to tune the worth of dialog parameters for conditions the place that is applicable, and I give one instance the place doing it may result in complicated outcomes.
What if I actually need to change the worth of a block parameter primarily based on the output of one other block?
At the moment, the answer I discovered to restrict the Integrator output utilizing enter alerts was this advanced contraption utilizing the State and Reset ports of the Integrator:
As of MATLAB R2023a, if I’m being requested to do the identical, I’d use two Parameter Author blocks and bind them to the decrease and higher saturation parameters of the Integrator block:
Right here is an instance mannequin utilizing the above subsystem, altering the integrator limits from +/-10 to +/-1 at t=50sec.
Use at your personal threat!
The next is an instance I obtain each occasionally, the place the consumer needs to progressively change the frequency of a Sine Wave block, for example from 3 rad/sec to six rad/sec over 5 seconds. As you may see, the frequency of the ensuing sine wave doesn’t easily improve from 3 rad/sec to six rad/sec. As an alternative, it seems to be twice quicker than anticipated.
The Sine Wave block assumes a continuing worth for ω and implements:
Making ω improve linearly with time () and differentiating the consequence reveals why the ensuing operate is twice the specified frequency:
To get the specified frequency-increasing sine wave, you need to combine the time-varying frequency:
One other tip right here… for those who implement this mannequin, I like to recommend enabling the Wrap State possibility of the Integrator block. This can keep away from its output to develop infinitely because the simulation time will increase, which might result in numerical points for lengthy simulations:
Now it is your flip
Are you a fan of the Parameter Author block? Do you may have challenges with this idea of “Sign vs Parameters” in Simulink? Tell us within the feedback under.