Hong
Hong

Reputation: 546

What is the best practice to enable mixed sample time in Simulink model

An outside Library (from PreScan) requests 200 Hz while my control plant model needs to run at 100 Hz. Therefore, my question is that how can I coordinate these two activities? My concern is that if I use 200Hz in Simulink, it may compromise my control plant’s fidelity.

Is it possible to set simulink time step as 1/100 while keep the outside library to run at 200Hz?

Upvotes: 0

Views: 3134

Answers (2)

Evgeni Verbitski
Evgeni Verbitski

Reputation: 31

You can use both explicit and implicit rate control in Simulink.

  1. Sample Time To set the fundamental sample time go to: Configuration Parameter>Solver>Fixed-step size. You can also use the Simulink API:

get_param(bdroot, 'FixedStep')

set_param(bdroot, 'FixedStep', '0.005') % 200Hz

  1. Colors To activate the Sample Time colors go to: Display>Sample Time>All. The Sample Time Legend will help you understanding how the implicit rate control works.

  2. Sample time Option You can control the tasking and sample time options via: Configuration Parameter>Solver>Tasking and sample time options.

At the beginning you can activate the automatic handling of rate transition for data transfer. Then you shall analyse what colors your model elements are and place the Rate-Transition blocks on the data signal lines between the model elements with different sample rates.

Now the rate control is implicit. If you use the function calls to explicitly call your subsystems at a required rate by involving a predefined scheduler, than the rate control is explicit.

You can open build in Simulink examples to see how it works:

sf_ladder_logic_scheduler

sf_loop_scheduler

Upvotes: 1

Phil Goddard
Phil Goddard

Reputation: 10762

Simulink works perfectly happily with multi-rate models. The thing (it appears) that you don't understand is the difference between the overall model sample rate - i.e. the settings of your solver - and the sample rate of individual blocks within your model.

It's very typical to have some blocks in your model sampled at say 100Hz, while other parts of your model sampled at 200Hz. In this case you would choose a discrete solver and give it a sample time of 200Hz. The 200Hz blocks would get executed at every solver time step, while the 100Hz blocks would get executed every second solver time step.

You should look at the Sample Times in Systems section of the documentation.

Upvotes: 1

Related Questions