Saturday, December 2, 2023
HomeMatlabAlerts vs Parameters in Simulink… and the Parameter Author block » Man...

Alerts vs Parameters in Simulink… and the Parameter Author block » Man on Simulink


Even when most of what I wrote in that publish nonetheless holds at present, I assumed it will be a good suggestion to revisit this matter and describe how the Parameter Author block modifies the sport.

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.
In lots of easy instances, the mathematics finally ends up being the identical. For instance, utilizing a Sum block so as to add two alerts offers the identical outcomes as utilizing a Bias block if its parameter has the identical worth because the equal sign fed to the Sum block. In different phrases, these 3 are the identical:

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?

Since my final publish on this matter, we launched the Parameter Author block. For a couple of releases, the Parameter Author block was restricted for use solely in very particular contexts the place the execution order was explicitly outlined. In R2023a, we relaxed this constraint and the Parameter Author block can be utilized in lots of contexts. Internally, we analyze the information dependency and ensure the blocks execution order displays it.
On this publish, I identified the truth that the Integrator block has an choice to restrict its output, however the limits can solely be specified as dialog parameters:

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.

Exemplifying what I described above, the Sine Wave block makes the belief that the frequency is fixed. Primarily based on this assumption, as an alternative of integrating the time-varying frequency and computing the angle to be handed to sin:

y=sin(ω(t)dt)

The Sine Wave block assumes a continuing worth for ω and implements:

y=sin(ω*t)

Making ω improve linearly with time (ω(t)=ok*t) and differentiating the consequence reveals why the ensuing operate is twice the specified frequency:

ddt(ok*t*t)=2*ok*t

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.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments