Optical Encoder : Working, Types, Interfacing & Its Applications Encoder is a motion-detecting device that provides feedback within a closed-loop control system. The main function of an encoder is to change the rotating motion or linear motion of a device part into an electrical signal after which it delivers to the control system, By using an encoder, the precise location of device components, the rotational speed or its direction and the angle & no. of motor shaft transformations can be recognized. There are different types of encoders available in the market which are classified based on the type of technology, motion, various parameters, etc. Encoders based on motion are classified into linear, rotary, and angle. Encoders based on position are classified into the absolute encoder and incremental encoder. Encoders based on sensing technology are classified into optical, magnetic, and capacitive. Encoders based on the channel are classified into single channel and quadrature. This article discusses an overview of one of the types of encoder namely optical encoder – working and its applications. What is Optical Encoder? An electromechanical device that is used to change the position from rotating or linear to an electrical signal by using a light source, an optical grating & photosensitive detector is known as the optical encoder. These encoders are extensively used in different machine tools, office equipment, and as high-precision position control sensors in industrial robots. Optical Encoder Optical Encoder Design The optical encoder is designed with an LED, photo sensors & a disc known as a code wheel including slits within the radial direction & detects rotating position data as an optical signal. Once a code wheel connected to a rotary shaft like a motor revolves then an optical signal will be generated based on whether light produced from a permanent light emitting element passes throughout a code wheel’s slit or not. The photo sensor notices the optical signal and changes it into an electrical signal & outputs it. Optical Encoder Design Light Emitting Device In optical encoders, inexpensive IR LEDs are used although sometimes, colored LEDs with shorter wavelengths are utilized to contain light diffusion. Additionally, costly laser diodes are utilized where high resolution & high performance are needed. Lens The LED light is diffused light through small directivity so that a convex lens is used to make parallel. Code Wheel The code wheel looks like a disc including slits that allows or blocks the emitted light from the light-emitting diode. The code wheel is made with metal, glass & resin materials. Here, metal material is strong against temperature humidity & vibration. The resin material is not expensive but appropriate for mass production & utilized for consumer-based applications. Glass material is mainly used where maximum resolution & precision are necessary. Additionally, a fixed slit is arranged near the code wheel to clarify the passing or blocking of the light from LED passes throughout the code wheel & goes into the light collecting element. Photo Sensor A photo sensor is normally a phototransistor/ photodiode made with semiconductor material like silicon, germanium & indium gallium phosphide. How Does Optical Encoder Work? An optical encoder simply detects the optical signals which pass throughout the slit and changes them into electrical signals. As compared to the magnetic encoder, this encoder is very simple to improve accuracy & resolution to use in applications wherever a strong magnetic field is produced. The optical encoder allows different controllers for measuring different types of motion. These encoders offer very precise feedback signals used for verifying the actual motor or linear actuator’s position, acceleration & velocity. Optical Encoder Arduino Here we are going to learn how to connect an optical rotary encoder using Arduino Uno. This is a mechanical device with a rotary shaft in a cylindrical housing. On a circular flat disc, there are two sets of slots. On any side of this disc, optical sensors are connected where the transmitter set is on one side and the receiver sent is on another side. Whenever the slotted disc revolves in between the sensor then it cuts the optical sensor, so the signal will be produced at the receiver ends. Here, the receiver is connected to a microcontroller for processing generated signal, in this manner we can identify how much the shaft revolves. The direction of shaft rotation can be determined by simply comparing the polarity of the signal for two o/ps because the two sets of slots on the circular disc are at some offset. The optical encoder interfacing with Arduino is shown below. The required components for this interfacing mainly include an optical encoder, Arduino Uno board, and connecting wires. The connections of this interfacing follow as; Optical Encoder Interfacing with Arduino Board The Red color wire of this encoder is connected to Arduino Uno’s 5V pin. The black color wire of this encoder is connected to Arduino Uno’s GND pin. The White color wire (OUT A) of an optical encoder is connected to Arduino Uno’s interrupter pin like Pin-3. The Green color wire (OUT B) of this encoder is connected to Arduino Uno’s other interrupter pin like Pin-2. Here the output wires from the optical encoder like white and green color wires should be connected only to the interrupt pin of the Arduino Uno board, if not Arduino board will not record each pulse from this encoder. Code volatile long temp, counter = 0; //This variable will increase or decrease depending on the rotation of the encoder void setup() { Serial.begin (9600); pinMode(2, INPUT_PULLUP); // internal pullup input pin 2 pinMode(3, INPUT_PULLUP); // internalเป็น pullup input pin 3 //Setting up interrupt //A rising pulse from encodenren activated ai0(). AttachInterrupt 0 is DigitalPin nr 2 on Arduino. attachInterrupt(0, ai0, RISING); //B rising pulse from encodenren activated ai1(). AttachInterrupt 1 is DigitalPin nr 3 on Arduino. attachInterrupt(1, ai1, RISING); } void loop() { // Send the value of counter if( counter != temp ){ Serial.println (counter); temp = counter; } } void ai0() { // ai0 is activated if DigitalPin nr 2 is going from LOW to HIGH // Check pin 3 to determine the direction if(digitalRead(3)==LOW) { counter++; }else{ counter–; } } void ai1() { // ai0 is activated if DigitalPin nr 3 is going from LOW to HIGH // Check with pin 2 to determine the direction if(digitalRead(2)==LOW) { counter–; }else{ counter++; } } Once the above code is uploaded into the Arduino Uno board, then open the serial monitor & turn the shaft of the optical encoder. If you turn the optical encoder in a clockwise direction then you can notice the value increase and if you turn this encoder in a counter-clockwise direction then the value will be decreased. If the value is showing reverse means giving a negative value for a clockwise motion. So you can reverse the white and green wires. Types of Optical Encoders Optical encoders are available in two types transmissive type and reflective type which are discussed below. Transmissive Type In a transmissive type optical encoder, the photo sensor notices whether the emitted light signal from the light-emitting diodes passes or not throughout the code wheel’s slit. The main benefits of a transmissive type optical encoder include; it improves the accuracy of signal easily and simple development because of the fairly simple optical lane. Reflective Type In a reflective-type optical encoder, the photo sensor notices whether the emitted light signal from the light-emitting diode is reflected or not through the code wheel. The advantages of reflective-type optical encoders mainly include; it is simple to miniaturize & thin. Since these are designed through the stacking technique; then the assembly procedure can be simplified. Optical Encoder Vs Magnetic Encoder The difference between an optical encoder and a magnetic encoder includes the following. Optical Encoder Magnetic Encoder The optical encoder is a type of transducer used to measure rotating motion. The magnetic encoder is a type of rotating encoder that utilize sensors for identifying changes within magnetic fields from a rotary magnetized ring/wheel. This encoder is also known pulse-generating/digital motion transducer. This encoder is also known as the absolute angle-sensing encoder. It needs a very clear line of sight. The line of sight in this encoder is filled with dust or different contaminants. This encoder should maintain with <.25mm air gap. This encoder is accurate through up to 4mm air gaps. It is vulnerable to compression on the rotary disc within humidity & fluctuating heat. It is resistant to humidity & heat. Compromised accuracy in shock or vibration environments. It is vibration & shock resistant. It needs a sealed & large casing to work well in hard environments. It is solid, rugged & low-cost without a large external shell. It includes moving parts. It doesn’t include moving parts. This encoder cannot be adapted to configurations. This encoder can be customized. Its temperature range is medium. Its temperature range is narrow. Its current consumption is high. Its current consumption is medium. Its resolution range is wide. Its resolution range is narrow. It has high magnetic immunity. It has low magnetic immunity. Advantages and Disadvantages The advantages of an optical encoder include the following. The optical encoder easily improves accuracy as well as a resolution by developing the slit shape because it has a mechanism to notice whether light from LED passes or not throughout the slit. This encoder is not affected by the nearby magnetic field. These encoders provide the highest resolutions. These are more resistant to the interference of electrical noise from eddy currents. These encoders have flexible mounting options. The disadvantages of optical encoders include the following. The main drawback of this encoder is that: it is mechanically not strong. These encoders have a thin glass disk that can be damaged by extreme shock or severe vibration. These encoders depend on “line of sight,” so they are mainly vulnerable to dirt, oil & dust. Optical disks in this encoder are normally designed with either plastic or glass so there is more chance to get damaged from extreme temperature, vibrations, and contamination. Applications The applications of optical encoders include the following. These encoders are ideal for applications that need a high level of precision & accuracy. These are used where a strong magnetic field is produced. It is applicable in devices that utilize large-diameter motors. These encoders help in detecting the optical signals which pass throughout the slit and change them into electrical signals. These encoders are very helpful in measuring & controlling rotating motion across a broad range of applications like spectrometers, lab equipment, centrifuges, medical devices, CT scan systems, etc. These encoders are used in high torque-based applications in extremely constrained areas. These are used in programmable inspection devices. These are used in commercial or industrial equipment. These are used in chemical dosing equipment. 1). Why are Optical Encoders Used? Optical encoders easily improve accuracy as well as resolution as compared to the magnetic encoder. So these can be used wherever a strong magnetic field is created. 2). What is the Output of an Optical Encoder? The optical encoder output is an electronic pulse that is used as a “clock” for the data sampling. 3). What is the Resolution of an Optical Encoder? The resolution of an optical encoder is 20k pulses for each wheel revolution that is utilized for odometry calculations. 4). Why are Encoders better than Potentiometers? Encoders can rotate in a similar direction for an indefinite period whereas a potentiometer normally turns a single revolution. 5). Which type of Encoder is Widely used in Robotics? Optical encoders are utilized in robotics to record absolute or incremental measurements. This is an overview of an optical encoder – types, interfacing, working, and applications. Optical encoders use light that is passed through glass & identified through a receiver. These types of encoders are very accurate and very necessary components in various mechanical systems of many industries to provide precise feedback information. Here is a question for you, what is a linear encoder? Share This Post: Facebook Twitter Google+ LinkedIn Pinterest Post navigation ‹ Previous Magnetostrictive Transducer : Schematic Diagram, Types, Advantages & Its ApplicationsNext › Wi-Fi Jammer : Specifications, Circuit, Working, Differences, Interface with Arduino & Its Applications Related Content Kogge Stone Adder : Circuit, Working, Advantages, Disadvantages & Its Applications Brent Kung Adder : Circuit, Working, Advantages, Disadvantages & Its Applications Inverting Summing Amplifier : Circuit, Working, Derivation, Transfer Function & Its Applications Active Band Pass Filter : Circuit, Types, Frequency Response, Q Factor, Advantages & Its Applications