Initializes encoder module
mdaqEncoderInit(module, initValue, mode) mdaqEncoderInit(linkID, module, initValue, mode)
This function initializes selected encoder module (ENC1, ENC2) with provided initial value. Module supports different modes which can be used.
Quadrature Count Mode ("quadrature") the ENCxA and ENCxB inputs are used for A and B channels.
In Direction-count Mode ("dir") the ENCxA input will provide the clock for position counter and the ENCxB input will have the direction information. The position counteris incremented on every rising edge of ENCxA input when the direction input is high and decremented when the direction input is low.
In Up-Count Mode ("up") the position counter is incremented on both edges of the ENCxA input.
In Up-Down Mode ("down") the position counter is decremented on both edges of the ENCxA input.
linkID: Valid connection link ID (optional)
module: Quadrature encoder module (1 | 2)
initValue: Initial position value for selected quadrature encoder module
mode: encoder counting mode
// mdaqEncoderInit usage example link_id = mdaqOpen(); // initialize quadrature encoder with 0 mdaqEncoderInit(link_id, 1, 0, "quadrature"); // read quadrature encoder module 1 mprintf('Encoder position: %d\n', mdaqEncoderRead(link_id, 1)); mdaqClose(link_id) | ![]() | ![]() |