It's Monday, and that means it's time for Adventures in Science! This week, we dive into the mysterious world of rotary encoders.
There are two types of rotary encoders: incremental and absolute. Incremental encoders are useful for determining how many times a shaft has rotated or even counting fractions of a rotation. Absolute encoders, on the other hand, can determine the exact position of a shaft (depending on the resolution and precision of the encoder disc). For the video, I focus mainly on incremental encoders, how they can be used in wheeled robots to measure distance traveled, and how quadrature encoders work to determine the direction a shaft is spinning.
Incremental encoders, in their basic form, detect light, magnetic or physical changes on a disc that rotates with the shaft. We show an optical encoder in the video as a demo (the build for which can be found on Hackster). We then add two photocells to the encoder demo to show how a quadrature encoder works. We can use a simple magnetic encoder to count the number of rotations on a shaft, which we can use to determine how far a robot has traveled by placing one on each motor. Code for making our robot (lovingly named "Fred") move in a straight line for one meter can be found here.
Many of the top competitors in AVC use a combination of rotary encoders and a magnetometer (compass) to create a dead reckoning system that allows their robot to navigate around the course. Additionally, many self-balancing robots rely on encoders along with an inertial measurement unit (IMU) to determine if the robot is leaning one way or the other.
What are some other useful, fun or unusual uses for rotary encoders that you've seen?