Jump to content

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.




Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...