Quadrature Encoder Get

Reads the Quadrature encoder counter value.

Description

When using this block, the channel A and channel B signals of the quadrate encoder should be connected to the channel 1 and channel 2 pins respectively of the timer module that was selected in the block parameters.

The underlying software driver processes the channel A and channel B signals to create a 32-bit signed counter as can be seen in the illustration below. TI1 is the quadrature encoder's channel A, TI2 is channel B, and Counter is the value returned by this block.

The counter value that is outputted by this block is of datatype int32, so its range is from –2,147,483,648 to 2,147,483,647. The counter will underflow/overflow if it gets out of range. To prevent the counter from going out of range you can manually reset the counter back to 0 through the block's boolean input. This input can be enabled through the checkbox 'Show counter reset input'. If a rising edge is detected on the block input, the counter will be reset to 0.

Output

Counter value
The used datatype is of int32.

Input

Counter reset trigger
The used datatype is of boolean.

Parameters
Quadrature Encode Module
Selects the Timer to use as the quadrature encoder module.

Configuration
Select if the inputs are floating or internally connected to a pull-up or pull-down resistor.

Show counter reset input
Configures if the input port for the counter reset should be shown.

Sample time
Sample time of the block. The Sample time (in seconds) defines the rate at which the block is visited by the real-time scheduler of the target. The value of the Sample time has to be an integer multiple of the base sample time of the model.