Jump to content

[Energia Library] Rotary Encoder with Coarse / Fine Adustment

Recommended Posts

This is an Energia sketch designed to be used with a rotary encoder with push button.  The difference is that input can be made coarser or finer by pushing the button.


The need came about because I wanted to be able to adjust a frequency generator between 1 and 40 MHz with fine adjustment on the order of 1 Hz with a simple interface on the board.  A potentiometer would not work due to low resolution and jitter.  Buttons or a simple encoder might work but it would take a lot of button pushing or knob turning to get from 10 Hz to 10 MHz.  I thought about a solution where the rate of turning the knob would determine the incremental increase or decrease but that seemed fiddly.  I could use multiple buttons but I liked the idea of a knob and in the end I only had one rotary encoder on hand.


So my solution was to use the encoder push button to provide for coarse to fine adjustment.   For example, the encoder can be set to increase or decrease the value by 100 with a twist.  By pushing the button it can be made to improve fine control by say 1 value per click.  This allows the user to rapidly change values or achieve fine  control as desired.
The sketch is here.

A couple on additional points:

  • Capacitors were used for hardware debouncing.  You may wish to modify the sketch or use a different encoder scheme with software debouncing.
  • Interrupts were used for both encoder pins and the switch.  You may need to change the pins to a port with interrupt capability with different LaunchPads. 
  • The sketch allows the minimum and maximum values to be set, as well as the change rate for coarseness.

It seems to work pretty well although it is a cheap encoder and with a minimal effort I can now rapidly change the frequency on my AD9850 and see the results on the FR6989 LCD.



I still need to put together a BoosterPack....  Tested with Energia V17 on the following LaunchPads:  MSP-EXP430FR6989, EK-TM4123GXL and MSP-EXP432P401R.


UPDATE:  There is a 43oh post that shows the BoosterPack I created here:  http://forum.43oh.com/topic/9402-ad9850-frequency-generator-boosterpack/

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...