Encoder

Measure motor rotation in degrees

Library

Simulink® Support Package for LEGO® MINDSTORMS® EV3 Hardware

Description

Measure the wheel rotation of an EV3 Motor in degrees. Driving the wheel forward increments the measurement. Driving the wheel in reverse decrements the measurement.

You can use this block with the Motor block.

If your model contains Motor and Encoder blocks for the same motor, set the EV3 brick output port parameter in both blocks to the same port.

The block output emits values as int32.

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

Parameters

EV3 brick output port

Select the EV3 brick output port connected to the motor. The options are A, B, C, or D.

Reset mode

Choose whether to reset the measurement value:

  • No reset — Do not reset the measurement value. Measure the total degrees of rotation.

  • Reset at each sample time — For each sample period, output the measurement value and then reset it to 0.

  • Reset by external signal — Create a block input that can reset the measurement value to 0. When you send a value other than 0 to the block input, reset the measurement value to 0. For each sample period, output the measurement value since the last reset.

Sample time

Specify how often the block reads sensor values.

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