This little board is designed to convert the CW and CCW encoder rotation into an active low "press button" events. The main use for this adapter are DIY joystick/cockpit systems with no dedicated rotary encoder inputs. With this board the encoder can be connected to ordinary active low button inputs.
The outputs of the encoder are filtered, debounced and work on PinChange interrupts basis, thus delivering a reliable operation, even with cheaper types of encoders.
The number of steps is buffered and "clicked out" in a constant period pulses to avoid missing steps due to button debounce routines. A quick turn of a 30 step rotary encoder will be definitely too fast for typical button input with 20-50ms debounce time. The default press on and release time of a one button press event is set to about 30ms in firmware.
Two types of encoders are implemented: half step and full step. Setting is done via a jumper. How to determine the encoder type: one step should generate one button press event. If it takes two steps to make one click, or one step generates two clicks, simply change the encoder type setting to the opposite one.
use any ISP AVR programmer, like USBasp or AVR MKII.
First, set the fuses to
- Low = 0xE2
- High = 0xDD
- Ext = 0xFF
then upload the Enc2Btn.hex file found in firmware/hex directory.
- ALPS EC11 series
- BOURNS PEC11L-4xxxF series
- various no name 11mm rotary encoders
- Connect the power lines: GND and VCC (3-5V DC).
- Connect the INC and DEC outputs to any active low button inputs in your joystick/controller board.
- If encoder has a built in button, attach the BTN out to another button input.
Depending on the encoder type and it's internal construction it may happen the INC and DEC outputs will work backwards, CW rotation will generate pulses on DEC and vice versa. No big deal, as you can swap the button inputs freely.
Boards can be ordered directly from OSH Park:
Passive components are in 0603 size. The ATTINY25SU chip is in SOIC8 Wide package.
The encoder subroutines are heavily inspired by the work of Ben Buxton http://www.buxtronix.net/2011/10/rotary-encoders-done-properly.html
(c) 08/09.2016 by Piotr Zapart www.hexeguitar.com
License: Creative Commons - Attribution - ShareAlike 3.0 http://creativecommons.org/licenses/by-sa/3.0/