Fork me on GitHub

Project Notes

#413 Incremental Rotary Encoder Tester

Demonstrating a rotary encoder forward/reverse LED indicator using simple digital logic.

Build

Here’s a quick demo..

clip

Notes

Incremental Rotary encoders typically provide quadrature output on two pins:

Quadrature_Diagram CW

LEAP#118 RotaryEncoderMethods demonstrates various ways of using a rotary encoder with an Arduino, but I’m inspired to throw away the microcontroller for a more basic demonstration after reading Experiment 101: Rotary Encoders from ARRL Hands-on Radio (Vol 2).

This project demonstrates a forward/reverse LED indicator using simple digital logic and a mini rotary encoder (from seller on aliexpress).

Design

Key thing to note from the quadrature diagram:

on the edge of one output from the rotary encoder, the level of the other output will indicate whether rotation is forward or reverse

This insight is used by Experiment 101: Rotary Encoders, where one signal is considered a clock source and the other the data to be latched with a CD4013 D-type flip-flop. The output controls a “forward” LED, and the complementary output drives the “reverse” LED.

I don’t have any CD4013 on hand, so modified the idea to work with 74LS173. The 74LS173 is a 4 bit D latch and doesn’t have complementary outputs, so in this design it uses two of the D latches - one configured to drive the “forward” indicator, the other for the “reverse”. The 74LS173 can source/sink enough current to drive and LED at under 5mA in either direction.

The 74LS173 clocks on the rising edge

CL -G0 -G1 CLK (A) D (B) Q Inferred Rotation
0 0 0 rising 0 0 CW
0 0 0 rising 1 1 CCW

There are may other ways of achieving this. For example one other alternative I scoped out was using a 74LS73 JK Flip-flop and an inverter.

Construction

I tested this out on a breadboard first. The 100nF capacitors coupled with the 10kΩ pullup resistors on the A/B rotary encoder connections are for hardware de-bouncing.

Breadboard

Schematic

IncrementalTester_bb_build

But then decided to capture the circuit on protoboard using this layout:

IncrementalTester_layout

The final protoboard build:

Build

Testing

I added pin headers to the protoboard to assist capturing signals with a scope. Here are some traces where:

  • CH1 (yellow) - CLK (A)
  • CH2 (blue) - D(B)

Here’s a clockwise (CW) rotation capture. Note the effectiveness of the hardware de-bouncing - quite clean transitions.

scope_cw

Here’s a counter-clockwise (CCW) rotation capture:

scope_ccw

Credits and References

About LEAP#413 SensorCMOS/TTL

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

Project Source on GitHub Return to the LEAP Catalog
About LEAP

LEAP is my personal collection of electronics projects - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting.

Projects are often inspired by things found wild on the net, or ideas from the many great electronics podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know or send a pull-request.

NOTE: For a while I included various scale modelling projects here too, but I've now split them off into a new repository: check out LittleModelArt if you are looking for these projects.

Project Gallery view the projects as an image gallery Notebook reference materials and other notes Follow the Blog follow projects and notes as they are published in your favourite feed reader