With the loop scheduler design pattern, you can
schedule one Simulink® subsystem to execute multiple times in a single time step. The model
sf_loop_scheduler illustrates this design pattern.
The Looping Scheduler chart contains the following logic:
The key behaviors of the loop scheduler are:
In a given time step, the Stateflow® chart broadcasts a function-call output event to trigger the
execution of the function-call subsystem
A1 multiple times in
the Simulink model. Here is the sequence of activities during each time
The Simulink model activates the Stateflow chart Edge to Function at a rising edge of the 1-millisecond pulse generator.
The Edge to Function chart broadcasts the function-call output event
call to activate the Stateflow chart Looping Scheduler.
The Looping Scheduler chart broadcasts a function-call output event
for loop to trigger the function-call
A1 multiple times (see Flow Chart Implements For Loop).
The Looping Scheduler chart uses Stateflow flow charting capabilities to implement a
loop for broadcasting an event multiple times in a single time step. The chart
contains a Stateflow flow chart that uses a local data variable
control the loop. At each iteration, the chart updates output
y and issues the
send action to
broadcast a function-call output event that executes subsystem
A1 uses the value of
y to recompute its output and send the value back to the
Looping Scheduler chart.
To run the
sf_loop_scheduler model, follow these steps:
Open the model by clicking sf_loop_scheduler
sf_loop_scheduler at the
MATLAB® command prompt.
Open the Scope block.
The scope displays the value of
y at each time
In this example, the Looping Scheduler chart executes the
loop 10 times in each time step. During each iteration:
The chart increments
y by 1 (the constant value of
The chart broadcasts a function-call output event that executes subsystem
y by a gain
Control returns to the chart.