How to Combine Modeling Styles with Schedulable Components in Simulink

From the series: Run-Time Software Modeling

Schedulable components allow you to take two very different modeling styles, rate-based modeling and export function modeling, combine these, and schedule them in the same model, helping you save time by catching problems early when you combine different components.

This modeling style gives you two big benefits. This gives you full control over scheduling model components, rather than letting Simulink schedule the components. And there is no need to deal with data dependency issues between components, because there are only data transfers.

Let me show you an example motivating the need for schedulable components. In this model, we have two different modeling styles. At the top level, we have Simulated Pedal Input, going into a Throttle Sensors and Monitor model block. The sensors data is going to the Throttle Position Controller and Actuator model block. This system is then being simulated by a model of the Throttle Body acting as the plant. Inside the Throttle Position Controller and Actuator model block, there are two Export Function components – one for the Controller and another for the Actuator

Inside, the Throttle Sensors and Monitor model block, there are rate-based subsystems for the sensors and monitor. Three of them are running at 5 milliseconds – the Throttle Position Sensor Primary and Secondary, as well as the Monitor. One of them is running at 10 milliseconds – The Acceleration Pedal Position sensor.

What I want is to schedule the Controller to run before the sensors. I must rearchitect the model to interleave the scheduling of these different modeling styles. To do this, I can configure the Throttle Sensors and Monitor model block to schedule the model’s rate-based components via a periodic event port. Now inside the Throttle Sensors and Monitor model block, all the subsystems are triggered by two events, which come from outside the model block. They are labeled D1 and D2.

With both Export Functions and Schedulable Components, no inherent scheduler is assumed, allowing you to more flexibly integrate to a custom environment.

So, we can use the Schedule Editor to schedule both types of components at the top level. In this case, we are interleaving calls to both the export functions and schedulable components. The ControllerRun5ms and ActuatorRun5ms events control the function calls in the Throttle Position Controller and Actuator model block. The D1 and D2 control the Schedulable Component.

But we want to have the controller be executed first in the Execution Order, so in this case, we simply drag and drop it to the place in which we want it to run.

When you get different IP with different modeling styles from different places, this explicit scheduling and interleaving of compositions is very useful.

Product Focus