Rotary Encoder : A rotary encoder is a type of position sensor which is used for determining the angular position of a rotating shaft. It generates an electrical signal, either analog or digital, according to the rotational movement.

There are many different types of rotary encoders which are classified by either Output Signal or Sensing Technology. In Hello 1.0 DC Motor Module, there is a rotary encoder connected to the motor.

Rotary encoder is also known as quadrature encoder or relative rotary encoder and its output is a series of square wave pulses.

How Rotary Encoder Works?

Here’s how the square wave pulses are generated: The encoder has a disk with evenly spaced contact zones that are connected to the common pin C and two other separate contact pins A and B, as illustrated below.

When the disk will start rotating step by step, the pins A and B will start making contact with the common pin and the two square wave output signals will be generated accordingly.

Any of the two outputs can be used for determining the rotated position if we just count the pulses of the signal. However, if we want to determine the rotation direction as well, we need to consider both signals at the same time.

As you can see from the figure, both of the outputs stays HIGH at the initial state. When the encoder shaft starts to rotate in clockwise direction, Output A falls to LOW first and Output B follows it with a lag. In a counter-clockwise direction the operation turns opposite. Time intervals on the waveform depend on the rotation speed but the signal lagging is guaranteed in encoder operation. source/

Filtering Out the Contact Noise of a Mechanical Encoder

Mechanical encoders have built-in switches which generate the quadrature waveform during rotation. Those switches generate noise during the closing and the opening moments of their contacts. In the figure below, you can see the actual behavior of an output signal.

The contact noise is a major problem when dealing with the encoder signals. They cause erroneous direction and rotation detection and make using the encoders problematic. We can get rid of the contact noise by filtering it out in the software or by using some extra filtering circuits.

Filtering the noise out in the MCU software is one option but it has some disadvantages. You need to write a more complex code to handle the noise. Filtering will take processing time and put delays to your work flow. You may need to set timers to ignore the noisy intervals. At the end of the day, it is possible that you can’t get a satisfactory and robust result.

Filtering the noise out by using extra hardware is easier and it stops the noise at its source. What you need is a first order RC filter. You can see how the signal will look like after you use an RC filter.

RC filter slows down the fall time and the rise time and provides hardware de-bouncing. You should consider the maximum frequency of rotation while choosing the resistor and the capacitor pair. Otherwise the expected response of the encoder will also be filtered. source/

Leave a Reply

Your email address will not be published. Required fields are marked *


© All rights reserved