Main Content

Encoder

Measures rotation of motor in ticks

Since R2024a

  • Encoder Block

Libraries:
Embedded Coder Support Package for Infineon AURIX TC3x Microcontrollers / AURIX TC3x

Description

Measures the rotation of the motor in ticks.

The ticks port outputs the encoder ticks count as an int32 value.

The dir port, when enabled, outputs the direction of the encoder.

  • 0 - clockwise direction.

  • 1 - counter-clockwise direction.

The Encoder block is developed based on GPT12 (general purpose timer) module available in the AURIX TC3x devices, where timer T3 & T5 (slow speed calculation) is used.

Ports

Input

expand all

The block converts this input SoC Blockset™ message into encoder position and outputs it in ticks port during simulation.

Dependencies

To view this port, select the Enable simulation port parameter.

The offset_in port enables you to dynamically add the offset in raw position with respective to the motor if required.

Dependencies

To enable this port, select the Enable offset inport parameter.

Data Types: int32

The rate_in ports enables you to change the rate at which the data is sampled at run time in seconds.

Dependencies

To enable this port, select the Enable refresh rate inport parameter.

Data Types: Float32

Output

expand all

The ticks port outputs the encoder position in count as an int32 value.

Data Types: int32

The dir port outputs the current direction of the motor as one of the following:

  • 0 - Clockwise direction

  • 1 - Counter clockwise direction

Dependencies

To enable this port, select the Enable direction port parameter.

Data Types: Boolean

The speed port outputs the mechanical speed (in rad/s) of the motor as an float32 value.

Note

  • If you set the Enable slow speed detection parameter to measure slow speeds, you must set the sample time parameter of the block to be greater than one encoder ticks duration else the speed read is zero.

  • The encoder ticks rolling over on the higher side results in outliers in the speed calculation. You must use the Delay block to correct the speed of the motor.

Dependencies

To enable this port, select the Enable speed port parameter.

Data Types: float32

Parameters

expand all

Outputs

Enable this parameter to output the current direction of the motor.

Enable this parameter to output the mechanical speed (in rad/s) of the motor.

Inputs

Enable this parameter to refresh the rate at which the data is sampled.

Dependencies

To view this parameter, select the Enable speed port parameter.

Enable this parameter to dynamically add the offset in raw position with respective to the motor.

Specify in seconds how often the block should read the pin value.

When you specify this parameter as -1, Simulink® determines the best sample time for the block based on the block context within the model.

Select this parameter to enable peripheral simulation capability.

Note

If you do not have a SoC Blockset license, the Enable simulation port parameter is visible but you cannot enable it.

Version History

Introduced in R2024a