Rotary Encoder Kit Tutorial
Description:
This rotary encoder kit can be used for sensing motor's position and velocity. It is a very simple kit consisted of an optical beam sensor (opto switch, phototransistor) and a piece of slotted disc. It can be connected to any microcontroller via the 3-pin header. The optical beam sensor detects missing slots of the slotted disc, and generates a pulse train.
It requires +5VDC to power up, and gives a 0V and 5V output. It provides a 5V output when the beam is blocked, and a 0V output when the beam is unblocked. Your microcontroller can simply read the 0-5-0V pulse train to determine how far your motor has traveled, and how fast.
The kit includes a green LED that light up when the beam is uninterrupted.
Specification:
- Operating Voltage: 4.5-5 VDC
- Output Signal: Digital output
- Direct connection to microcontroller (internal pull-up to 5V)
- Able to read up to 100KHz
- Slotted Disc Diameter: 26mm
- PCB Dimension: 22mm x 20mm
Materials Preparation
For this tutorial, the items needed to run this project are:
- Arduino Uno
- USB Cable Type A to B
- Male to male jumper wire
- Female to male jumper wire
- Plastic Gear Motor
Hardware Installation
Diagram above shows the simple connection between Rotary Encoder Kit and Arduino Uno:
- 5V > 5V
- GND > GND
- OUT > D2
Connection between Plastic Gear Motor and Arduino Uno:
- Terminal 1 > 5V
- Terminal 2 > GND
After completing the connection, connect Arduino Uno to power supply with a USB cable.
Insert Source Code
- Download the test code and open it by using Arduino software or IDE.
- Make sure that you have choose the right board and the corresponding port (In this tutorial, Arduino Uno is used).
- Then, upload the test code into your Arduino Uno.
Downloads
Results
The slotted disc is mounted to Plastic Gear Motor and placed within the space of the rotary encoder circuit board. The optical beam sensor detects missing slots of the slotted disc and generates a pulse train. By adjusting code in Arduino, Rotary Encoder will be able to detect actual rpm for the Plastic Gear Motor and display on Serial Monitor.