Main Content

Timer

Measures elapsed time from timer in EV3 brick

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

Library

Simulink® Support Package for LEGO® MINDSTORMS® EV3 Hardware

  • Timer block

Description

The Timer block measures the elapsed time, in milliseconds, from when the LEGO MINDSTORMS EV3 brick starts running the model.

You can see when the EV3 brick starts running a model by observing the LCD on the EV3 brick. For 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 outputs zeros. See Block Produces Zeros or Does Nothing in Simulation.

Use the Timer

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

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

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

Parameters

Sample time

Specify how often the block reads timer values. This value defaults to 0.1. Shorter sample times, such as 0.01, may produce unreliable measurements.

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

Version History

Introduced in R2018a