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:

DsPIC Block/Calculus Time Step

From - Simulink device driver Blockset for dsPIC / PIC24 / PIC32 Microcontrollers --[[User:LubinKerhuel|LubinKerhuel]] 12:40, 3 September 2009 (UTC)
< DsPIC Block
Revision as of 19:30, 3 May 2015 by LubinKerhuel (talk | contribs) (LubinKerhuel moved page Block/Calculus Time Step to DsPIC Block/Calculus Time Step: Block is a special page, creates many issues)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Block Calculus Time

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).

Dialog Box Parameters

Calculus Time-Step Dialog

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 \>