Using Rotary Encoders with Arduino
Rotary encoders are versatile devices that can be used both as controls and as instruments to measure the rotation of a DC motor. Today I will show you how to do both of those things using rotary encoders and an Arduino.
Complete article with code – https://dbot.ws/rotenc
More articles and tutorials at https://dronebotworkshop.com
Subscribe to the DroneBot Workshop newsletter https://dbot.ws/dbnews
We will look at two types of rotary encoders today. The first one is a very common control that looks a bit like a potentiometer but, as you will see, is much more accurate and versatile.
The second rotary encoder we’ll examine is attached to the back of the DC Gearmotor I’m using to build my DB1 robot.
Both encoders work on similar principles.
I’ll show you how rotary encoders can determine both the position and direction of rotation by using and comparing two output pulses. Then we will create and run a few Arduino sketches to put them to use.
In the first sketch we will see how to read the value from a rotary encoder control. Next, we will add a servo motor and precisely control its position with a rotary encoder.
After that, we will bring out the servo motor encoder. We will look at the output pulses on an oscilloscope, then we will connect it to an Arduino to build a tachometer of sorts, reading the RPM of the motor.
Here is the Table of Contents for today’s video.
Rotary Encoder Operation – 2:15
Basic Rotary Encoder Control Sketch – 6:13
Controlling a Servo Motor – 12:09
Rotary Encoder on a DC Gear Motor – 18:40
Reading RPM from a Motor – 21:08
As usual, you will find all of the code in a detailed article on the DroneBot Workshop website at https://dbot.ws/rotenc. While you’re there don’t forget to sign up for the newsletter at https://dbot.ws/dbnews . I’ll be making an announcement to my newsletter readers very soon about a new way to suggest content, so you don’t want to miss out.
And if you haven’t subscribed to the YouTube channel then now is the time! Just hit the Subscribe button and you’re in the club!
Hope you enjoy the video, thanks for watching!
source