Schedule number of steps to next event
void ssSetNumTicksToNextHitForControllableSampleTime(SimStruct *S, int st_index, size_T numTick)
SimStruct representing an S-Function block.
Index of the controllable sample time in the block.
Note
controllable Sample Time is only supported in single rate
blocks. Hence sti
will be 0.
Interval between current and next execution. The block will next
execute after numTick * resolution
. See ssSetControllableSampleTime
for information on setting resolution
.
Use this function in mdlInitializeConditions
and
mdlOutputs
to set the next time the S-function should
execute. The next execution is scheduled for t_next = t + numTick *
resolution
, where t
is the current time and
resolution
is set using ssSetControllableSampleTime
.
C, C++
Set numTick = 1
when you call
ssSetNumTicksToNextHitForControllableSampleTime
in
mdlInitializeConditions
to force the block to execute when
the system is initialized.
static void mdlInitializeConditions(SimStruct *S} { ssSetNumTicksToNextHitForControllableSampleTime(S, 0, 1); }
Schedule the next execution of the block at t + 4 * resolution
,
where t
is the current time.
static void mdlOutputs(SimStruct* S, int_T tid) { ssSetNumTicksToNextHitForControllableSampleTime(S, 0, 4); }
See the S-function sfun_pwm.c
used in sfcndemo_pwm