circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

Issue 152 March 2003
Using Rotary Encoders as Input Devices


I INTERRUPT THIS ARTICLE…

Some readers are sure to bemoan the fact that they don’t have two or four free interrupt lines on their favorite microcontroller to service one or two of these encoders. I use the AVR microcontroller family and have only one or two external interrupt lines available, one or more of which may be needed for some other time-critical purposes.

PIC and Motorola fans are luckier because many of these devices have an interrupt-on-change function that causes an interrupt if a change occurs on a particular 8-bit port. This function makes interfacing to one or more 2-bit encoders simple, because a change in any of the encoders will result in an interrupt. The ISR then checks the current state of each encoder, compares it to the last state, as I described earlier, and adjusts the appropriate variable.

To solve this dilemma, I scouted around for a chip that would monitor multiple encoders (in addition to a few other switches) and attach to the main microcontroller using just a few I/O lines. I toyed with the idea of creating the function myself with a small AVR or PIC chip, but instead I found a solution in an inexpensive device developed by Philips Semiconductors.