Blockset described on this wiki is deprecated **since 2012**.

For Model Based Design (MBD), use the free **MPLAB Device Blocks for Simulink**, tool from Microchip.

Updated Rapid Control Prototyping (RCP) custom projects are published at: **https://lubin.kerhuel.eu**.

# DsPIC Block/Calculus Time Step

Provide the exact execution time of the time step.

Each microcontroller time step can be decomposed in time into two parts. During the busy part, all the Input/Output tasks and the calculation tasks are completed. During the idle part, the microcontroller is waiting for the time of the next time step to start. Time step is usually controlled using the timer1. Steps execution starts when timer1 reachs the precomputed PR1 value and is then reseted. The "Calculus Time Step" block extract the Timer1 value at the end of the busy part. Comparing this value to PR1 provides the margin for the step computation time. The PR1 value corresponding to the model time-step can be found in the Master block dialog box. Note that this block works only when time step is based on the timer 1 (in master block configuration, ie, does not work when using ADC sample time as reference for time).

## Contents

# Dialog Box Parameters

## Sample Time

-1 is inherited

## Max Step Time Out (Timer1 PR1)

When this case is checked, a second output provide the PR1 value. You can read directly this value in the master block configuration dialog.

Dividing first input by PR1 gives the percentage of charge of the microcontroller (using non integer division !).

Typically, 'the calculus time step' block output is connected directly to the 'Tx Output Multiplexed For Matlab Lavview' block. Values can then be plotted with the matlab graphical user interface. With multirate simulink models, force the sample time to the model time step (ie, the minimum time step possible for a block of the model). Thus, you will obtain the execution time for the different rate of the model and you will be able to measure the time margin for each one.

## Related topics on the forum

Confused about Calculus Time Step

<comments \>