Friday, May 08, 2015

Interfacing a Chord Keypad to Papilio Duo FPGA Board

Five keys plus thumb operated shift/control key
This is a simple chord style keypad that I made up a few years ago.  It is loosely based on the Microwriter - an early UK designed portable keypad / notewriter.

The five main keys are located under the fingertips and thumb of the right hand, plus an additional shift key that can be held down with the thumb.  This combination allows up to 64 key combinations  - which is enough for simple ascii, alphas and numerals.

However, this time the application is not for text entry, but to allow very rapid access to menu items, tools and colour options for a CAD program - without having to break concentration and use the keyboard.

In the early 1990's, Charles Moore - the founder of the Forth programming language, devised a similar simple keypad, to allow him fast, direct and immediate control of his OKAD suite of VLSI CAD design tools. It means that all the frequently used options, for example the toolset in CAD, are immediately below your fingertips and accessible without remembering a series of keyboard strokes or moving the mouse off the working drawing area, to the menu bar, to select a new tool.

If this multi-keypad were combined with the position and scrolling functions currently provide by a mouse, then it would mean that a considerable amount of program interaction could be done from the "mousekey"  without having to take one's hand of the mouse to type at the keyboard.

Wiring Up

The keypad will interface directly into the Atari joystick port of a Classic Computing Shield that I purchased from Gadget Factory - as part of the Papilio Duo development kit. I am slowly developing a stand alone CAD workstation, based around a 32 bit soft processor running on the Papilio Duo FPGA.

The wiring is very simple - just 6 microswitches connected to inputs pins which short to ground when pressed.  The Computing Shield provides 47K pull-up resistors - such that the port lines will all appear high until a keyswitch is pressed. The wiring schematic is provided in the Computing Shield hardware guide

For the moment, the keypad inputs will have to be polled, but a little more logic - such as 6 diodes, would allow a further line to indicate an interrupt from the keypad - if any switch is pressed, the diode AND  (inverted logic OR) would bring the interrupt line low.

Decoding the key inputs in code is fairly simple - we assign binary weights to each of the key inputs, and then the unique combination of switch presses is the binary sum of these weights.

For example - assign a weight of:
1 to switch 1,
2 to switch 2,
4 to switch 3,
8 to switch 4,
16 to switch 5,
32 to switch 6.

If switches 1 and 2 are pressed together, the decoding returns a value of (2+1) = 3.

Some consideration was given to switch debounce - multiple sampling of the key-inputs until a stable, repeatable sum is achieved.

The keypad is first scanned to see if any key is pressed.  If there is, we wait for 30mS and scan again. We then wait a further 30mS and scan a second time.  If the first and second scans are equal - we know we can return with a valid keycode.

Why a Custom Keypad?

The keypad provides a simple and fast means of navigating and selecting a wide range of options from a menu.

It may be used for causing a quick change in operation - such as an original games controller.

It can also be used for text input - but this requires a bit of practice and learning the character set.


Blogger Templates said...

You touch my favourate topic, like it
Free Blogger Templates

Unknown said...

This is a pretty clever solution . I remember back in the PS2 days, the single multiplexing made it impossible to hit more than 2 keys on the same channel of the keyboard as once (not sure about now, but at least the main qwerty subset of non-tacticle buttoned keyboards were split into 3 'channels' where each button had a conductive element on it, and when you applied pressure it would complete a circuit (think: closing a gate) indicating the key is pressed).

Anyways, I digress. You're totally right about making this a 'one stop shop' unifying the mouse functionality (I suggest either a trackpad 'nipple' like on the old IBM laptops), or a ball-mouse still very popular in the CAD community.

In general though, whether one is laying out physical components in AutoCAD or PCB layouts in Altera, most people know the shortcuts inside-out -- that is: everyone who uses those tools have muscle memorized all the common keyboard shortcuts. The 'bottleneck' in general isn't the speed or inconvenience to get to select/execute an operation, so much as the thinking component. (If you look at the original chord device -- the stenographer's keypad-- it was designed because the bottleneck was the keystroke).

That said-- I'm all for new interfaces, though. I'd be interested to know what key-bindings -> function mappings you have, and I'd be interested to see where this project goes. I've seen some demos with VR headset HUDs for CAD's/CAMs and new interfaces.

Keep it up.