| Contents | Index |
void model_step(void) void model_step(int_T tid) void model_stepN(void)
Task identifier. The Embedded Coder software generates this argument only for multirate, single-tasking models.
The model_step default function prototype varies depending on the number of rates in the model and the solver mode, as shown below:
| Rates/Solver Mode | Function Prototype |
|---|---|
| Single-rate/SingleTasking | void model_step(void); |
| Multirate/SingleTasking | void model_step(int_T tid); |
| Multirate/MultiTasking (rate grouping) | void model_stepN (void); (N is a task identifier) |
If you generate reusable, reentrant code for an ERT-based model using the Generate reusable code option, the generated code passes the model's root-level inputs and outputs, block states, parameters, and external outputs to model_step using a function prototype that generally resembles the following:
void model_step(inport_args, outport_args, BlockIO_arg, DWork_arg, RT_model_arg);
The manner in which the inport and outport arguments are passed is determined by the setting of the Pass root-level I/O as parameter, which appears on the Interface pane of the Configuration Parameters dialog box only if Generate reusable code is selected.
For greater control over the model_step function prototype, you can use the Configure Model Functions button on the Interface pane to launch a Model Interface dialog box (see Configuring Function Prototypes in the Embedded Coder documentation). Based on the Function specification value you specify for your model_step function (supported values include Default model initialize and step functions and Model specific C prototypes), you can preview and modify the function prototype. Once you validate and apply your changes, you can generate code based on your function prototype modifications. For more information about controlling the model_step function prototype, see the sections and Function Prototype Control in the Embedded Coder documentation.
The Embedded Coder software generates the model_step function for a Simulink model when the Single output/update function configuration option is selected (the default) in the Configuration Parameters dialog box. model_step contains the output and update code for all blocks in the model.
model_step is designed to be called at interrupt level from rt_OneStep, which is assumed to be invoked as a timer ISR. rt_OneStep calls model_step to execute processing for one clock period of the model. See rt_OneStep and Scheduling Considerations in the Embedded Coder documentation for a description of how calls to model_step are generated and scheduled.
Note If the Single output/update function configuration option is not selected, the Embedded Coder software generates the following model entry point functions in place of model_step: |
The model_step function computes the current value of all blocks. If logging is enabled, model_step updates logging variables. If the model's stop time is finite, model_step signals the end of execution when the current time equals the stop time.
In cases where a tid is passed in, the caller (rt_OneStep) assigns each task a tid, and model_step uses the tid argument to determine which blocks have a sample hit (and, therefore, should execute).
Under any of the following conditions, model_step does not check the current time against the stop time:
The model's stop time is set to inf.
Logging is disabled.
The Terminate function required option is not selected.
Therefore, if any of these conditions are true, the program runs indefinitely.
model_initialize | model_SetEventsForThisBaseStep | model_terminate

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |