Incremental Rotary Encoder Introduction

The XCSB Incremental Rotary Encoder library is designed to be used with mechanical contact devices. The optical versions are much simpler to handle and the library can handle these as well. If the library had been specifically written for optical encoders, then it would not have been able to handle the mechanical contact version.

The mechanical contact version uses two switches. These are noisy inputs (unlike the optical inputs which are clean) and require debouncing. Because of the rate at which the encoder can be turned by a human operator, the device must be polled very quickly. This is to ensure that pulses are not lost or missinterpreted as reverse pulses.

The incremental rotary encoder library maintains a count in the variable rotary_encoder_count. When the encoder is turned in one direction, the count is incremented, when the encoder is turned in the opposit direction the count id decremented.

The encoder has two outputs which are connected to two inputs of the PIC. These two outputs are known as channel A and channel B.