What is the A B Encoder?
A description of the A B incremental encoder can be found on Wikipedia here:
under the section of Incremental rotary encoder.
You can easily read this kind of encoders
Or the industrial type
All inputs Master count (Encoder_a, Encoder_a_pu, Counter, Counter_pu, Fast_counter and Fast_counter_pu) generate an output value between zero and 65535 (16 bits total). When you exceed the value 65535 starting again from scratch and when it drops below zero it starts from 65535. This mechanism allows many applications to read the value asynchronously. Applications can be undertaken to do and are not required to register any change in the value. Just read the value periodically, at least sometimes every second, to never miss the step.
The application Theremino Counter Reader shows how to correctly read the encoders and counters.
Simple projects can use Theremino CounterReader, to read an encoder from a slot and write the value to another, but major applications should use the “CounterReader”. In this way would have access to the function ReadValue, to be called periodically and Reset function that resets the value at any time (What is done by the button “Zero Set” the Counter Reader).