Rotary encoder working principle


  • How Rotary Encoder Works and How To Use It with Arduino
  • Encoder Working Principle
  • How Rotary Encoder Works and Interface It with Arduino
  • Rotary encoder basics and applications, Part 1: Optical encoders
  • How Rotary Encoder Works
  • Types of Encoders: Rotary, Linear, Position, and Optical Encoder Types
  • How Rotary Encoder Works and How To Use It with Arduino

    Micro SD Card Module How Rotary Encoder Works and Interface It with Arduino A rotary encoder is a type of position sensor that converts the angular position rotation of a knob into an output signal that is used to determine what direction the knob is being rotated. Due to their robustness and fine digital control; they are used in many applications including robotics, CNC machines and printers.

    There are two types of rotary encoder — absolute and incremental. The absolute encoder gives us the exact position of the knob in degrees while the incremental encoder reports how many increments the shaft has moved. The rotary encoder used in this tutorial is of an incremental type.

    Rotary Encoders Vs Potentiometers Rotary Encoders are the modern digital equivalent of the potentiometer and are more versatile than a potentiometer.

    Potentiometers are best in situations where you need to know the exact position of the knob. However, rotary encoders are best in situations where you need to know the change in position instead of the exact position. How Rotary Encoders Work Inside the encoder is a slotted disk connected to the common ground pin C, and two contact pins A and B, as illustrated below. When you turn the knob, A and B come in contact with the common ground pin C, in a particular order according to the direction in which you are turning the knob.

    When they come in contact with common ground they produce signals. This is called quadrature encoding. When you turn the knob clockwise, the A pin connects first, followed by the B pin. When you turn the knob counterclockwise, the B pin connects first, followed by the A pin. By tracking when each pin connects to and disconnects from the ground, we can use these signal changes to determine in which direction the knob is being rotated.

    You can do this by simply observing the state of B when A changes state. When the A changes state: if B! VCC is the positive supply voltage, usually 3. SW is the active low push button switch output. When the knob is pushed, the voltage goes LOW.

    This output can be used to determine the direction of rotation. CLK Output A is the primary output pulse for determining the amount of rotation. Wiring — Connecting Rotary Encoder to Arduino Now that we know everything about the rotary encoder it is time to put it to use! Connections are fairly simple.

    Finally, connect the SW pin to a digital pin 4. The following illustration shows the wiring. The following sketch detects when the encoder is being rotated, determines which direction it is being rotated and whether or not the button is being pushed. Try the sketch out; and then we will dissect it in some detail. If the rotation being reported is the opposite of what you expect, try swapping the CLK and DT lines. The counter variable represents the count that will be modified each time that the knob is rotated one detent click.

    A string called currentDir will be used when printing the current direction of rotation on the serial monitor. The lastButtonPress variable is used to debounce a switch. We also setup the serial monitor. If they are different then it means that the knob has turned and a pulse has occurred. We also check if the value of currentStateCLK is 1 in order to react to only one state change to avoid double count.

    To do this we simply read the DT pin on the encoder module and compare it to the current state of the CLK pin. If they are different, it means that the knob is rotated counterclockwise. If the two values are the same, it means that the knob is rotated clockwise. To determine when such changes occur, we can continuously poll them like we did in our previous sketch.

    However, this is not the best solution for below reasons. We have to busily perform checking to see whether a value has changed.

    There will be a waste of cycles if signal level does not change. There will be latency from the time the event happens to the time when we check. If we need to react immediately, we will be delayed by this latency. It is possible to completely miss a signal change if the duration of the change is short. A solution widely adopted is the use of an interrupt.

    This frees the Arduino to get some other work done while not missing the event. So now the wiring looks like this: Some boards like the Arduino Mega have more external interrupts. If you have one of them, you can keep the connection for SW pin and extend below sketch to include code for the button. Meanwhile, this program watches digital pin 2 corresponds to interrupt 0 and digital pin 3 corresponds to interrupt 1 for a change in value.

    When this happens the function updateEncoder often called the interrupt service routine or just ISR is called. The code within this function is executed and then the program returns back to whatever it was doing before. Below two lines are responsible for all this. The function attachInterrupt tells the Arduino which pin to monitor, which ISR to execute if the interrupt is triggered and what type of trigger to look for. This project can be very useful in many situations, for example, when you want to operate a robot arm, as it would let you precisely position the arm and its grip.

    In case you are not familiar with servo motor, consider reading at least skimming below tutorial. Then servo motors might be the solid launching point for you Of course you can use the Arduino 5V output but keep in mind that the servo can induce electrical noise onto the 5V line that the Arduino uses, which may not what you want.

    Therefore it is recommended that you use an external power supply. Each time the knob is rotated one detent click , the position of the servo arm will be changed by one degree. At the start we include the built-in Arduino Servo library and create a servo object to represent our servo motor.

    Encoder Working Principle

    A rotary encoder also called a shaft encoder is a position sensor that is used to detect the angular position and speed of electrical signals. They process the signals based on the rotational movements i. Angular position: As the shaft rotates around the center axis, an angular position exists for each location along the path of travel. Rotary Encoder Classification of Rotary Encoder There are many types of rotary encoders that can be classified based on output signal or sensing technology.

    The most common type: Absolute: In this current position will be known as soon as the power is applied. Incremental: This encoder immediately reports change in the position without reporting track of the absolute position. How Rotary Encoder Works? The inside of encoder consists of a evenly spaced disk.

    And a series of electrically charged pads are placed around the outer portion of disc. On top of these pads there are 3 contact pins — A, B and C as given below: Diagram to understand how rotary encoder works Pin A and B are set of fixed position contacts called as the clock and data line which are 90 degrees out of phase. When the disk starts rotating, pin A clock and pin B data lines make contact with pin C the electrically charged pad.

    This further creates square wave output signals as shown in the above figure. These output waves can also be used to find the angular position by counting the number of pulses of the signal. The positioning of pin A and pin B is in such a way that it makes the shaft turn clockwise or anti-clockwise and based on the direction of the shaft the travel direction is determined.

    Check out the diagram for a simplified explanation of the working and classification of the rotary encoder: Sr Indus provides 2 types of rotary encoder: 1. Hengstler Incremental Rotary Encoder: We provide Hengstler incremental rotary encoder for robust heavy-duty products.

    This encoder interrupts a beam of light from a light-emitting diode which determines the number of lines in resolution. The information is then available as a signal at the encoder output.

    The incremental rotary encoder can provide 10, pulses per revolution. For more information and technical specification of various types of incremental rotary encoder check out this page. Hengstler Absolute Rotary Encoder: The Hengstler absolute rotary encoder are innovative engineering and easy to operate. This sophisticated piece of engineering is in a position to provide accurate data for motor feedback and automation.

    They come equipped up with the BiSS sensor interface which makes them ideal for all equipment in the coming future. For more information and technical specification of various types of absolute rotary encoder check out this page.

    Contact us now to find out the best price on the Hengstler products.

    The absolute encoder gives us the exact position of the knob in degrees while the incremental encoder reports how many increments the shaft has moved. The rotary encoder used in this tutorial is of an incremental type. Rotary Encoders Vs Potentiometers Rotary Encoders are the modern digital equivalent of the potentiometer and are more versatile than a potentiometer.

    Potentiometers are best in situations where you need to know the exact position of the knob. However, rotary encoders are best in situations where you need to know the change in position instead of the exact position. How Rotary Encoders Work Inside the encoder is a slotted disk connected to the common ground pin C, and two contact pins A and B, as illustrated below. When you turn the knob, A and B come in contact with the common ground pin C, in a particular order according to the direction in which you are turning the knob.

    When they come in contact with common ground they produce signals.

    How Rotary Encoder Works and Interface It with Arduino

    This is called quadrature encoding. When you turn the knob clockwise, the A pin connects first, followed by the B pin. When you turn the knob counterclockwise, the B pin connects first, followed by the A pin.

    By tracking when each pin connects to and disconnects from the ground, we can use these signal changes to determine in which direction the knob is being rotated. You can do this by simply observing the state of B when A changes state.

    Rotary encoder basics and applications, Part 1: Optical encoders

    When the A changes state: if B! VCC is the positive supply voltage, usually 3. SW is the active low push button switch output. When the knob is pushed, the voltage goes LOW. This output can be used to determine the direction of rotation. CLK Output A is the primary output pulse for determining the amount of rotation. Wiring — Connecting Rotary Encoder to Arduino Now that we know everything about the rotary encoder it is time to put it to use! Connections are fairly simple.

    Finally, connect the SW pin to a digital pin 4. The following illustration shows the wiring. The following sketch detects when the encoder is being rotated, determines which direction it is being rotated and whether or not the button is being pushed.

    Try the sketch out; and then we will dissect it in some detail. If the rotation being reported is the opposite of what you expect, try swapping the CLK and DT lines. The counter variable represents the count that will be modified each time that the knob is rotated one detent click. A string called currentDir will be used when printing the current direction of rotation on the serial monitor.

    The lastButtonPress variable is used to debounce a switch. We also setup the serial monitor. A simple example of how an encoder might be used is in a cut-to-length application.

    How Rotary Encoder Works

    Imagine a cutting operation or machine that is designed to regularly produce material of a certain fixed length.

    The raw material, such as fabric, is continuously fed into the machine from a spool. An encoder is used in applications such as this to tell the control circuit for the machine when to make the cut. This article will review the different types of encoders, provide a basic understanding of how they function, and present information on selection considerations and important specifications. Types of Encoders There are several different ways in which encoders can be characterized for motion control applications.

    The most common approach is to characterize these devices by the type of movement being monitored, whether that be linear straight-line or rotational. The three most common types of encoders are linear encoders, rotary encoders, and angle encoders.

    Linear Encoders Linear encoders deal with the movement of objects along a path or line, such as in the cut-to-length application mentioned earlier. This type of encoder makes use of a transducer to measure the movement or distance between two points, sometimes employing a cable longer distances or a small rod shorter distances. In these cases, a cable is run between the encoder transducer and the moving object.

    Rotary Encoders Rotary encoders are used to provide feedback about the movement of a rotating object or device, such as the shaft of a motor. Rotary encoders may contain shafts or can be of a design that is known as thru-bore encoders, meaning that they are capable of being directly mounted on top of a rotating shaft such as that of a motor. Thru-bore encoders are available with a wide variety of sizes and feature clamp or set screw mounting options making them suitable for attachment in machine design applications.

    Flanges are used to position the encoder and to keep it from rotating with the moving shaft. Angle Encoders Angle encoders are similar to rotary encoders in that they monitor and provide feedback on rotational movement, but they are different in that angle encoders tend to offer higher accuracy.

    Absolute and Incremental Encoders Both linear and rotary encoders are available as either absolute or incremental encoders, which describes the desired signal output for the encoder.

    With an absolute encoder, the output signal generated by the device results in a unique set of digital bits that correspond to a specific position of the object being measured. Even if power is lost, the absolute encoder by its design can determine the position of the object since there is a specific digital signal associated with every position.

    Types of Encoders: Rotary, Linear, Position, and Optical Encoder Types

    Rotary absolute encoders are available in both single-turn and multi-turn designs. Single-turn encoders are capable of providing information within any one shaft rotation. Multi-turn encoders are capable of providing information about the position over many rotations of shaft position, even large numbers of rotations.

    Absolute encoders are used in applications where knowing the exact position of an object is important. They are also used in situations where the machine or process is inactive for a large percentage of time or moves at a very slow rate. Incremental encoders use a simpler method of counting movement and rely on establishing the position of the object by counting the number of pulses and then using that count to compute the position.

    Because they rely on pulse counting, there is no unique digital signature that can be used to determine an absolute position. Hence in the event of a power loss, incremental encoders must be referenced to a home position or reference point so that the counter can be reset and then used to compute relative movement. One way to think about the difference is that incremental encoders measure the relative movement against some point of reference, whereas absolute encoders measure the position directly using a unique signal code that directly reflects the position.

    Encoder Sensing Technologies There are several different sensing technologies that may be used within an encoder to detect motion or position. The most common sensing technologies that are used in encoder designs include: Optical Capacitive Optical Encoders Optical encoders are the most accurate of all the sensing methods.

    A rotary optical encoder consists of a light source such as an LED and a rotating disk that is patterned with a series of opaque lines and alternating translucent slots.


    thoughts on “Rotary encoder working principle

    Leave a Reply

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