Hi,
The encoder outputs channels which has a 90° phase shift between them.

The QEI-module can be set to 2X or 4X mode (X4 is the most common) but the easiest to understand is the 1X mode....

Simply, if the B channel is high on the rising edge of the A channel then you count up, if the B channel is low on the rising edge of the A channel then you count down. In 2X mode you "trig" on the rising edge of both channels (giving you a resolution of 2X the line count of the encoder) and it 4X mode you trig on the rising AND falling edge of BOTH channels (giving you a resolution of 4X the line count of the encoder).

If you look up incremental or quadrature encoder on Wikipedia you'll find more details.

/Henrik.