Main Content

Encoder

Measure rotation of motor in ticks

  • Library:
  • Simulink Support Package for Arduino Hardware / Arduino Motor Carrier

  • Encoder Arduino Motor Carrier block icon

Description

TheEncoderblock reads the position and rotational speed of the motor from an encoder that is connected to an MKR Motor Carrier. The position is measured in ticks, and the speed is measured in ticks per second. Every increment in the tick count indicates a clockwise rotation, and every decrement in the tick count indicates a counterclockwise rotation.

If you simulate a model that contains theEncoderblock without connecting the hardware, the block outputs zeroes. For more information, seeBlock Produces Zeros or Does Nothing in Simulation.

Ports

Output

expand all

ThePositionport outputs the relative change in the position of the rotating motor, measured in ticks. For more information, seeCalculate Position and Rotational Speed of the Motor.

Data Types:int32

TheSpeedport outputs the rotational speed of the motor, measured in ticks per second. For more information, seeCalculate Position and Rotational Speed of the Motor.

Dependencies

TheSpeedport is available only when you select theShow Speed output portparameter.

Data Types:int32

Parameters

expand all

Select the channel number of the encoder that is connected to the MKR Motor Carrier.

When you select theShow Speed output portparameter, theSpeedport becomes available. The port outputs the rotational speed of the motor, measured in ticks per second.

When you select theReset count at initialization参数块重置滴答计数为0 each time the Simulink®model runs on the hardware.

Specify how often the block reads the tick count from the encoder, in seconds. When you specify this parameter as-1, Simulink determines the best sample time for the block based on the block context within the model.

More About

expand all

Version History

Introduced in R2019a