Main Content

Timer

Measure elapsed time from timer in EV3 brick

Add-On Required: This feature requires the Simulink Support Package for LEGO MINDSTORMS EV3 Hardware add-on.

  • Timer block

Libraries:
Simulink Support Package for LEGO MINDSTORMS EV3 Hardware

Description

Use the Timer block measure the elapsed time in milliseconds when the EV3 brick starts running the Simulink® model.

You can see when the EV3 brick starts running a model by observing the LCD on the EV3 brick. For Simulink models that do not use the Display block, the LCD on the EV3 brick displays I am running followed by the model name. For models that use the Display block, the model displays whatever output is sent to it.

During simulations without hardware, this block emits zeros. See Block Produces Zeros or Does Nothing in Simulation.

Examples

expand all

This example shows how to measure and display elapsed time of a running Simulink model on an EV3 brick.

Open the legoev3lib block library as described in Open Block Library for LEGO MINDSTORMS EV3 Hardware.

Copy the Timer and Display blocks to a new model and connect these blocks.

Timer model

Prepare and run the model on the EV3 brick as described in Run Model on EV3 Hardware. Observe the elapsed time on the LCD display of the EV3 brick.

Ports

Output

expand all

The block outputs the time elapsed in milliseconds when the EV3 brick starts running the Simulink model.

Data Types: uint32

Parameters

expand all

Specify the frequency of how often the block the timer values. Shorter sample times, such as 0.01, may produce unreliable measurements.

Smaller sample times require the processor to complete the same number of instructions in less time, which can cause task overruns.

Version History

Introduced in R2012a