Jump to content
Sign in to follow this  

New polling and pin-interrupt routines for rotary encoders

Recommended Posts

I worked on a new servicing routine for my kit oscilloscope's quadrature rotary encoder, and decided to write it all up and post it on Github.  Included are routines for periodic polling and for pin-interrupt servicing.  Hardware switch debouncing is not needed.  The routines are for general use, but I wrote testing code for the MSP430G2231 installed on the Launchpad.  The scope guys have used the "lookup table" state transition routine that most people use today, but it doesn't work very well on the scope, and I haven't found it to work very well generally.  My routines are designed to avoid all effects of switch bouncing, and seem to work very well and efficiently.

Everything is explained in the PDF file in the repo.  All the testing code is also included, both source code and executable hex files, and I'm afraid it's all in assembler.  But I hope it wouldn't be too difficult to create Energia versions if anyone is interested.  I've provided hex files for both types of encoders - those with the same number of pulses as detents per revolution, and those with half as many pulses as detents.  The code produces one "tick" per detent in both cases.




Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this