<< mdaqDIOWrite Data acquisition mdaqEncoderRead >>

MicroDAQ toolbox >> MicroDAQ toolbox > Data acquisition > mdaqEncoderInit

mdaqEncoderInit

Initializes encoder module

Calling Sequence

mdaqEncoderInit(module, initValue, mode)
mdaqEncoderInit(linkID, module, initValue, mode)

Description

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.

Input arguments

Examples

// 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)

See Also


Report an issue
<< mdaqDIOWrite Data acquisition mdaqEncoderRead >>