Reads quadrature encoder
[position, direction] = mdaqEncoderRead(module)
This function reads current value of quadrature encoder (ENC1, ENC2) position register on selected ENC module. Function returns current position and rotation direction. Value of direction indicates rotation direction (0 - no motion, 1 - CW, 2 - CCW).
The quadrature encoder pulse (ENC) module is used for direct interface with a linear or rotary incremental encoder to get position, direction, and speed information from a rotating machine for use in a high-performance motion and position-control systems.
module: Quadrature encoder module (1|2)
position: Current quadrature encoder position value
direction: Current rotation direction (0 - no motion, 1 - CW, 2 - CCW)
% initialize quadrature encoder with 0 mdaqEncoderInit(1, 0); % read quadrature encoder module 1 sprintf('Encoder position: %d\n', mdaqEncoderRead(1))