Analog numpad with Hall effect sensors
Posted: 21 Jul 2015, 11:53
Hi everyone! First post here, so I guess a quick introduction is in order. I'm Matt, a relative newcomer the the mechanical keyboard craze, having bought my first one (a Pure Pro) a little more than a year ago. Since then I have been considering other purchases and planning to build a custom 65% board but despite the shortcomings of the Pure Pro (nonstandard layout, OEM profile thin ABS keycaps) it seems so well-rounded to me that I feel no urge to own another keyboard.
On to the subject: a few weeks ago, after playing a bit of GTA V and noticing that the lack of analog control with a keyboard can be limiting, I started searching for info on analog keyboards — I was not even sure such a thing existed but I came across an experiment you might already know: Ben Heck's addition of an analog WASD cluster to a mechanical keyboard thanks to Hall effect sensors (details here).
What he did was mod MX switches with magnets and sensors, wire the sensors to a microcontroller which sends the signal to a digital pot and then to the logic board of a 360 gamepad, which is connected to a USB hub inside the keyboard case. As a result, the modded switches are seen as gamepad axes in Windows.
Concept: I don't want to deal with such a convoluted setup, so I'm aiming at a simpler approach: a discrete keypad that I can keep on my desk with four analog keys, other keys acting as joystick buttons, and a dedicated switch to turn it into a numpad or a macro pad when I'm not gaming (and possibly cycle through several layers). Something I would use as a Belkin Nostromo when playing, but with a smaller footprint, and which will remain useful in a working environment.
Layout: I'd like to keep things simple and avoid the need to source special keycaps, so I've settled with the traditional numpad arrangement, except that it is mirrored since it is meant to be used with the left hand and I find larger keys to be easier to use with the pinky when the left hand is in resting position (fingers on 4856). Also it should be possible to replace 2u keys with 1u keys.
Controller: A Teensy 2.0 has enough inputs to accomodate either a 5x4 switch matrix or 20 switches wired directly, four analog inputs for the sensors, one pin for a status LED, and have a few pins left for an optional extension if using a matrix. I considered trying the newer Teensy LC, but it is not 5 V tolerant (the Hall sensors operate between 0 and 5 V), does not have significantly more pins, and I am not sure there is any advantage in using an ARM mcu for this project.
Firmware: This is going to be the hardest part for me. Using a Teensy allows me to use one of the popular keyboard firmwares (Soarer's, Hasu's or Metalliqaz') but I have no clue about how to add the hall sensor logic to their code. On the other hand, the teensyduino environment makes coding this feature much easier, but the whole matrix implementation will have to be done from scratch, the thought of which I find befuddling. This will be my biggest hurdle.
Assembly: I'd love to try a CNC alu case but the first unit will use cheaper acrylic layers instead. This crude foamcore mockup shows what it should look like : a low profile case with narrow edges, a thicker front edge, and most likely small-radius corners (not seen here). I may use something different for the first prototype and make sure that I have a working concept before ordering laser-cut acrylic layers (for which the .svg files are already drawn).
The first unit will be hand-wired. I have already laid out a PCB that can accomodate up to 20 switches (5x4 matrix) in a mirrored numpad layout with PCB-mounted stabs :
This was done before I realized that the matrix programming was a brick wall for my poor coding skills and that direct wiring switches to the Teensy would probably be easier for me. It will be simple to lay out a different board if needed, but to avoid unneeded costs and superfluous delays I'll hand-wire the first unit.
That's it for the overview of the project, let's start making stuff! Before I can build the first unit, I need to experiment with components and code, so I'll use a testbed with six switches connected directly to the Teensy, six more wired as a 3x2 matrix (with diodes), and a few other things (an RGB status LED, Hall sensors and so on).
On to the subject: a few weeks ago, after playing a bit of GTA V and noticing that the lack of analog control with a keyboard can be limiting, I started searching for info on analog keyboards — I was not even sure such a thing existed but I came across an experiment you might already know: Ben Heck's addition of an analog WASD cluster to a mechanical keyboard thanks to Hall effect sensors (details here).
What he did was mod MX switches with magnets and sensors, wire the sensors to a microcontroller which sends the signal to a digital pot and then to the logic board of a 360 gamepad, which is connected to a USB hub inside the keyboard case. As a result, the modded switches are seen as gamepad axes in Windows.
Concept: I don't want to deal with such a convoluted setup, so I'm aiming at a simpler approach: a discrete keypad that I can keep on my desk with four analog keys, other keys acting as joystick buttons, and a dedicated switch to turn it into a numpad or a macro pad when I'm not gaming (and possibly cycle through several layers). Something I would use as a Belkin Nostromo when playing, but with a smaller footprint, and which will remain useful in a working environment.
Layout: I'd like to keep things simple and avoid the need to source special keycaps, so I've settled with the traditional numpad arrangement, except that it is mirrored since it is meant to be used with the left hand and I find larger keys to be easier to use with the pinky when the left hand is in resting position (fingers on 4856). Also it should be possible to replace 2u keys with 1u keys.
Controller: A Teensy 2.0 has enough inputs to accomodate either a 5x4 switch matrix or 20 switches wired directly, four analog inputs for the sensors, one pin for a status LED, and have a few pins left for an optional extension if using a matrix. I considered trying the newer Teensy LC, but it is not 5 V tolerant (the Hall sensors operate between 0 and 5 V), does not have significantly more pins, and I am not sure there is any advantage in using an ARM mcu for this project.
Firmware: This is going to be the hardest part for me. Using a Teensy allows me to use one of the popular keyboard firmwares (Soarer's, Hasu's or Metalliqaz') but I have no clue about how to add the hall sensor logic to their code. On the other hand, the teensyduino environment makes coding this feature much easier, but the whole matrix implementation will have to be done from scratch, the thought of which I find befuddling. This will be my biggest hurdle.
Assembly: I'd love to try a CNC alu case but the first unit will use cheaper acrylic layers instead. This crude foamcore mockup shows what it should look like : a low profile case with narrow edges, a thicker front edge, and most likely small-radius corners (not seen here). I may use something different for the first prototype and make sure that I have a working concept before ordering laser-cut acrylic layers (for which the .svg files are already drawn).
The first unit will be hand-wired. I have already laid out a PCB that can accomodate up to 20 switches (5x4 matrix) in a mirrored numpad layout with PCB-mounted stabs :
This was done before I realized that the matrix programming was a brick wall for my poor coding skills and that direct wiring switches to the Teensy would probably be easier for me. It will be simple to lay out a different board if needed, but to avoid unneeded costs and superfluous delays I'll hand-wire the first unit.
That's it for the overview of the project, let's start making stuff! Before I can build the first unit, I need to experiment with components and code, so I'll use a testbed with six switches connected directly to the Teensy, six more wired as a 3x2 matrix (with diodes), and a few other things (an RGB status LED, Hall sensors and so on).