Main Content

ssSetNumTicksToNextHitForControllableSampleTime

Schedule number of steps to next event

Syntax

void ssSetNumTicksToNextHitForControllableSampleTime(SimStruct *S, int st_index, size_T numTick)

Arguments

S

SimStruct representing an S-Function block.

st_index

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.

numTick

Interval between current and next execution. The block will next execute after numTick * resolution. See ssSetControllableSampleTime for information on setting resolution.

Description

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.

Languages

C, C++

Examples

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

Introduced in R2017b