This mechanical rotary encoder is the ideal way to add a rotary knob interface to your microcontroller project. The encoder comes with a nut and washer (not pictured) for the threaded bushing. This encoder works well with any of our knobs for 1/4 inch shafts. Our favorite knob for use with this encoder is PH-3025B.
To understand how this encoder functions, consider the following. This device contains two normally-open single-pole single-throw switches, which we'll label as switch A and switch B. This device has three pins, which we'll label as pin A, pin B, and pin C. One side of switch A is connected to Pin A; the other side of switch A is connected to pin C. One side of switch B is connected to pin B; the other side of switch B is connected to pin C. When the knob is at rest, nestled in one of the detents, both switches are off. As the knob is turned clockwise from this resting position, the following sequence of events occurs:
- switch A turns on,
- switch B turns on,
- switch A turns off,
- switch B turns off
This sequence occurs repeatedly as the knob is rotated, once for each detent.
A similar sequence of events occurs for counterclockwise rotation:
- switch B turns on,
- switch A turns on,
- switch B turns off,
- switch A turns off,
A microcontroller can watch for these transitions, and increment or decrement a counter to keep track of the absolute position of the knob.
This is a great way to navigate through lists in a menu structure. This is the strategy used by programmer (and Vetco customer) David Andrews in his Arduino LCD Menu package.
The rotary encoder can also be used in place of a potentiometer to select a position along a continuum of values. Unlike a potentiometer, this rotary encoder can turn forever in either direction, with no mechanical stop to limit its motion.
For the Arduino, we recommend the Encoder library written by Paul Stoffregen, which can be downloaded here. This library does a great job of handling interrupts and debouncing the pulses. A massive amount of functionality is wrapped into a single class called Encoder.
Specifications
| Encoder Type |
mechanical |
| Output Type |
Quadrature (incremental) |
| Pulses per Revolution |
24 |
| Detents per Revolution |
24 |
| Shaft Diameter |
6 mm |
| Shaft Length (dimension L in technical drawing) |
15 mm |
| Bushing Threads |
M9X0.75 |
Click here for the datasheet.
Pictures (click to enlarge):
Here is a great interactive description of the signal produced by the rotary encoder. Credit for the text and images below goes to Paul Stoffregen. This content was copied from http://www.pjrc.com/teensy/td_libs_Encoder.html.
Understanding Quadrature Encoded Signals
Encoders can sense movement in either direction, by detecting holes or marks as they move past 2 positions. When the blue disc in the diagram below spins clockwise, the changes are first detected by pin 1, and then by pin 2. When it spins counterclockwise, pin 2 is first to detect changes. This scheme is called "quadrature encoding" because the waveforms detected by the 2 pins are 90 degrees out of phase.
The Encoder library monitors the 2 pins and updates a count of the relative change in position. The library updates its count at each change, which is often called 4X counting, since 4 counts are available for each physical mark or hole in the encoder hardware.
|