Rotary Encoders for Odometry

Ahmed
6 min readFeb 26, 2023

--

Odometry is estimating motion and position from sensors. Rotary encoders are sensors that attach to a motor to measure rotation and can be used for odometry. With data on the rotation, we can potentially estimate distance, velocity, and location. Rotary encoders are used for wheel odometry, where the encoders connect to the motors of the wheels, enabling localization for wheeled robots and autonomous vehicles. They are also used for robots that have rotating motion, such as robotic arms, to track orientation and position.

Photo by Lenny Kuhne on Unsplash

In this article, we’ll explore encoders, the different types, and the mechanics behind them.

Note: this article is not exhaustive; there’s a lot of variation, nuance, and customizations for encoder technology.

Types of Rotary Encoders

In the section, we’ll explore four types of encoders: mechanical / contact encoder, optical encoders, magnetic encoders, and electromagnetic induction encoders. At a high level, these encoders will produce a signal that will be affected by the rotation of the motor.

Mechanical / Contact Encoder: in this design, we’ll have an electric circuit with a variable resistor that changes resistance based on the rotation. The encoder is keeping track and returning the voltage of the electric circuit where the voltage is affected by the resistance (as defined by Kirchhoff’s Circuit Laws). Since the resistance is affected by the angle of rotation, we can relate the voltage value we get from the encoder with the amount of rotation.

Optical Encoder: in this design, we’ll have an electric circuit that is connected to a photo sensor, which will affect the amount of voltage in the circuit. There will be a disk that will separate the circuit with the photo sensor from a light emitting diode (LED). The disk will be comprised of slits and will rotate with the motor. As the disk rotates, light will pass through the slits which will be detected by the photo sensor and affect the voltage of the circuit, thus capturing the rotation. Optical encoders can also leverage multiple circuits, photo sensors, and LEDs to capture data with more accuracy and resolution.

Magnetic Encoder: in this design, we’ll have magnets that generate a magnetic field distribution and a magnetic sensor to measure the magnetic field distribution. As the motor rotates, the magnets change their position / orientation, which affects the magnetic field distribution. The magnetic sensor will detect this change, and we can use this to determine the rotation of the motor.

Electromagnetic Induction Encoder: in this design, we’ll leverage electromagnetic induction and coils to determine rotation. Electromagnetic induction refers to when we get current from a conductor due to changes in the conductor’s magnetic field. A conductor is a substance or material that enables electricity to flow through it (such as an electrical wire). Coils are when conductors are looped to create a more concentrated magnetic field. In this type of encoder, we’ll leverage coils that will spin with the motor, which will cause changes in the magnetic field. Then through the process of electromagnetic induction, we’ll see changes in current which will indicate rotational motion.

Absolute vs Incremental Encoders

Now that we understand the different designs for encoders, we’ll now discuss absolute encoders from incremental encoders. An absolute encoder is one that tells the exact or absolute position / orientation of the motor at every measurement. Whereas with an incremental encoder, we will know the relative change in position / orientation between measurements. If we wanted to know the absolute position / orientation with an incremental encoder, we’d need to have an index or special portion of the encoder that informs us that we are at some reference position / orientation or backtrack from our starting point if the starting position / orientation is known.

Typically, incremental encoders are easier to make and will have less complexity as they only need to keep track of rotation from one time step to the next. However with absolute encoders, the encoder will have more components. Let’s see an example of this with optical encoders. For an incremental optical encoder, we can design the disk to have one circle of equally space slits. In this setup, we would keep track of how many slits were passed and that would provide information on the amount of rotation that took place (as each slit would represent some amount of rotation). For an absolute optical encoder, we would instead design the disk to have multiple layers / circles of slits, with each layer having different spacing patterns. Then we could have circuits with photo sensors to detect which slits are passed per each layer. The design of the slits per layer would be such that the set of voltage values from the circuits per layer would uniquely map to a certain position / orientation of the motor. Notice that for the incremental optical encoder, we could use only one layer of slits whereas for an absolute optical encoder, we’d need multiple layers with varied spacing patterns.

Which Encoder When?

Clearly there are several options available to us when deciding on an encoder. Let’s discuss the general advantages and disadvantages of the different types of encoders (note: this section is not universal — there maybe exceptions).

Mechanical encoders are often the cheapest option for encoders. They are generally simpler to make as they primarily rely on a variable resistor. However, the resolution of data (i.e., how precise or fine the sensor measurements are) can be less than other encoder designs. Moreover, mechanical encoders are subject to mechanical failure from environmental conditions (i.e., water damage, oxidation, rust) and wear and tear. Thus, mechanical encoders will typically have a shorter shelf life.

Optical encoders typically offer better resolution of data and accuracy. Furthermore, they can be customized through the slits spacing and the number of layers used on the disk. The disk can have more slits to get higher data resolution and use multiple layers of slits to get absolute measurements. However, the more slits and layers an optical encoder has, the bigger it needs to be (to fit it all in) — thus a downside to optical encoders can be their size. Moreover, similar to mechanical encoders, they do suffer from mechanical failure from environment conditions (i.e., water, debris, and dust can block or cover the LED). Thus, optical encoders aren’t recommended for very contaminated environments.

Magnetic encoders on the other hand are robust in a contaminated environment (can work with water, debris, and dust). Thus, magnetic encoders are typically used in processes with lots of contaminants (such as around industrial sewing machines which can produce a lot of lint or environments near water). Furthermore, magnetic encoders have a smaller profile than optical encoders. Thus, magnetic encoders can be found in applications that require small, highly reliable encoders.

Historically, magnetic encoders had lower data resolution and accuracy than optical encoders, however the gap between magnetic and optical encoders is closing. Thus, we are seeing magnetic encoders encroach into applications that previously were done by optical encoders. It should be noted that optical encoders would be preferable over magnetic encoders around applications that have or generate a strong magnetic field (such as large-diameter motors), as optical encoders are not affected by magnetic fields but magnetic encoders are.

Electromagnetic Induction encoders promise to provide highly accurate data, but they are more of a newer encoder technology. The trade-offs are less clear due to their recency, but given their reliance on electromagnetic induction and magnetic fields, applications with strong magnetic fields may affect their performance.

Lastly, we’ll compare absolute vs incremental encoders. In general, incremental encoders are cheaper and provide the amount of rotation between measurements. Whereas absolute encoders offer better resolution and accuracy, can better localize as it doesn’t need to reference an index or backtrack from its start position, and are more resilient when recovering from failure (i.e., can relocalize quicker as it knows the absolute position / orientation each time). The trade-off with absolute encoders is that they require more complexity to build and are generally more expensive (albeit the gap is closing), especially depending on the type of encoder. For an optical encoder, it would involve having layers of slits with particular spacing patterns that corresponds to an unique orientation whereas for a magnetic encoder, it’s much simpler to achieve absolute measurements as it primarily requires a rotation angle sensor.

Conclusion

In this article, we explore the four types of encoders: mechanical / contact encoder, optical encoders, magnetic encoders, and electromagnetic induction encoders. We also explored the distinction between absolute and incremental encoders. After understanding the encoder space, we discussed the general trade-offs between the various encoder options.

--

--