Axon

A ground-up, fully programmable custom mechanical keyboard.

Through-hole components
QMK compatible
Designed in spring 2021

Following the creation of my first custom mechanical keyboard in 2019, I retreated somewhat from the mechanical keyboard hobby because I didn’t want to spend more money on keyboards. They are, after all, quite expensive given that equivalent functionality can be achieved at much lower cost. However, as I started to explore electronics and DIY projects further, I found myself seeking a personal project which would motivate my learning.

Enter Axon, a “40%” (so named because it is roughly 40% of the size of a typical keyboard) custom mechanical keyboard, where the underlying electronics are designed and built by me instead of purchasing a pre-assembled PCB. I name this keyboard after the axon of a neuron, representing my branching foray into multidisciplinary design and learning new things in the process.

I had always held an attraction for keyboards which only use through-hole electrical components, such as Plaid by 5z6p Instruments and Gingham by Yiancar Designs (pictured below). I find their aesthetic is appealing in the same way that an audiophile might be attracted to the looks of vacuum tubes over more modern amplifiers. I decided that a keyboard in the through-hole style would be a good project for me. Not only is there plenty of reference material to learn from, but the basic electronics and operation of a keyboard are accessible for a beginner such as myself.

 
Plaid by 5z6p Instruments

Plaid by 5z6p Instruments

Gingham (left) by Yiancar Designs

Gingham (left) by Yiancar Designs

 

The goals of this project were as follows:

  1. Create a totally unique DIY custom mechanical keyboard which I could hold up as my own creation.

  2. Learn about electrical design and component selection, including the production of my first PCB.

  3. Further my understanding of microcontrollers and firmware.

 

Layout

The start of any keyboard project is the layout. Because I love the idea of compactness, and to keep this project manageable, I decided upon a “40%” layout. In my opinion, this layout approaches the limit of “minimum viable keyboard”, discarding most keys dedicated to special characters and even the number row in favour of using modifier keys to access such functionality. With such a small keyboard, the hands need never leave home row.

The base layout of Axon.

The base layout of Axon.

Here are some of the layout design decisions I made:

  • Since I almost never intentionally use Caps Lock, its spot has been repurposed for Tab.

  • I only ever press space with my left thumb. By splitting the spacebar, I can put my right thumb to work as a special modifier key which I call “Super” to quickly access an additional layer. The left thumb key is longer in length, based upon an examination of the typical contact point of my thumb in relation to the other keys.

  • The traditional place of Control is not ergonomic for me. Instead, I prefer to place it directly beside the spacebar, where the similar Command key in Mac systems is found. No key takes its place, much in the style of the Happy Hacking Keyboard. Personally, I like the aesthetics of missing corners.

 
The “Super” layer, accessed using the right thumb.

The “Super” layer, accessed using the right thumb.

As for the “Super” layer, which is accessed using the right thumb:

  • The top row becomes a number row.

  • The left hand becomes responsible for other symbols that are traditionally located on the right side of the keyboard.

  • The Home and End keys are easily accessible.

  • The control key becomes the Windows key.

  • The right hand can access arrow keys without leaving home row.

  • The L key remains available because I like to be able to press Win+L to lock the computer.

  • Some other keys are unmapped, but can easily be programmed as need arises.

Finally, the function key allows access to a third function layer where F-keys can be found, along with volume controls.

This key assignment is simply based on my needs. Since the keyboard is fully programmable, key function can be tailored to the tastes of each individual.

 

Electrical Design

Since my keyboard is based on prior open hardware keyboard designs which use through-hole components, I could use those designs as reference material. However, I wanted to go beyond blind copying and actually understand the purpose and function of each component. This section will be a combination of writing about what I’ve learned and explaining decisions made during the design of Axon.

 
Electrical schematic.

Electrical schematic.

 

Schematic

Keyswitches are arranged in a matrix of rows and columns. The microcontroller (MCU) pulls columns high one at a time, and checks for resulting high values in each row. Each key is equipped with a diode in order to prevent ghosting (false keypresses). This was the most straightforward part of the schematic to design.

I was mostly using Gingham by Yiancar Designs as a reference design, which uses a mini-USB connector (an update recently introduced USB-C as the connector of choice). I wanted to use USB-C, so I needed to figure out how to implement the more complicated USB-C connector. It turns out that for simple applications such as a keyboard, it’s relatively simple. By using 5.1k pull-down resistors on the CC pins, the keyboard is recognized as a USB 2.0 device. I could then proceed to ignore all pins other than D+, D-, GND, and VCC. Furthermore, D- is pulled high through a 1.5k resistor to indicate low-speed data rates, and protective resistors in series with the data pins limit current. Unlike prior designs, I did not connect the USB connector shield to data ground, because I learned that to do so on the device end is inappropriate. Instead, the shield should be connected to chassis ground, if it exists. Since this keyboard doesn’t have a chassis (more on that later), I left the shield unconnected. The only remaining question I had was regarding the purpose of the zener diodes on the data pins. Based on some naïve googling, I initially thought that they were there for ESD protection. However, I have since come to learn that the USB data lines operate at 3.3V, not 5V logic levels. Since the MCU is operating at 5V, the zener diodes serve to clamp the data line voltages to stay within USB specifications.

Like similar keyboard designs, I chose to use the ATmega328P as my MCU. It is popular, available in a through-hole package, and compatible with open-source keyboard firmware. However, I didn’t really understand these nuances at the time, and simply chose it because it worked for previous keyboards. From a hardware perspective, I simply needed to provide the MCU with power, ground, a reset button with a pull-up resistor, and a crystal which provides the operating frequency of 16 MHz. The crystal requires two capacitors to ensure resonance at the fundamental frequency. Apart from the reset button and crystal, I needed to learn about decoupling capacitors. I learned that the VCC power supply from the USB connector is slow to respond to the high frequency, bursty demands of the MCU. By placing decoupling capacitors at the power pins of the MCU, the MCU is provided with a power source that responds much more quickly to sudden loads, and is less likely to misbehave as a result.

 
PCB layout in KiCad.

PCB layout in KiCad.

 

Footprints and PCB Layout

Converting an electrical schematic into a functional PCB design was unexplored territory for me before Axon. The fantastic, keyboard-specific tutorials of hadi and ruiqimao demystified much of the process.

Choosing the package and footprint for each component was a challenge which I again approached by defaulting to the selections made by other designers. Though I was “flying blind” at the time, the process taught me much about different packages, footprints, and how to find the one I’m looking for, simply from googling terms and seeing where they led. Another trick I used was to perform a parametric search on digikey for the parts I was interested in, and sort the results by the in-stock quantity to get a feel for which parts are most common. By examining the datasheets of those parts, I gained an understanding of how the parts would look and feel. As for the keyswitches, I googled around to eventually find a KiCad library of MX-compatible switch footprints that I liked.

The process of laying out components in KiCad was essentially brand new to me. Even things as simple as edge cuts and fill zones were unknown. Drawing inspiration from the process presented by the aforementioned hadi, I found it very helpful to use AutoCAD to create a basic layout. Making precise drawings in KiCad is not advised, since it really isn’t made for that purpose. It’s much easier to get everything squared away in AutoCAD and then import .dxf drawings into the appropriate layer in KiCad.

Laying out components was largely a process of trial and error. Guided by basic principles such as reducing trace length where possible, I went through a cyclic process of trying different layouts, running traces, realizing something wasn’t working, deleting all my traces, and starting all over again. Beyond practical considerations, I had my own aesthetic criteria to meet. I wanted to have the USB connector in the middle of the board, and I wanted the 40 diodes to be symmetrically placed on the outsides. I also created silkscreen art above the diodes to symbolize the myelin sheath surrounding axons.

 
An Axon PCB in the flesh.

An Axon PCB in the flesh.

After checking my PCBs many times, I ordered PCBs from JLCPCB with the knowledge that they are a popular choice for PCB prototypes. It was nerve wracking to place the order since I knew that there was a chance that something would be wrong with my design. My desire to realize the project overcame my reservations in the end.

 
 

Firmware

Firmware was, and still is, somewhat mysterious. To get things working on my hardware, I found this guide by nullstagia and others extremely helpful. I also spend time reading relevant portions of the MCU datasheet and other online articles to learn about what I was doing with each step.

From what I understand, the ATmega328P does not natively support USB. Instead, USB functionality is emulated in firmware. I first prepared my environment on my raspberry pi. As the guide describes, I used AVRDUDE on my raspberry pi to set the appropriate fuses (which control hardware settings) and flash the USBaspLoader bootloader. USBaspLoader creates a virtual USBasp programmer and allows me to then flash additional firmware through the USB port of the keyboard.

At this point, I transferred the MCU to my PCB which had all components soldered except for the keyswitches. I could then follow QMK guides to create, build, and flash firmware for my keyboard. I wanted to figure out how to configure my own QMK firmware without the help of Keyboard Firmware Builder, but I couldn’t find a guide to do so. I suppose that will be a good project for another day; to understand the structure and operation of QMK at a deeper level.

 
 

All soldering done.

 

Mechanical Design and Purchased Parts

Since the focus of this project is the electrical aspects, the mechanical design is left simple for now. I simply use a stacked PCB design where a second, non-functional PCB is positioned under the functional one using standoffs. A laser-cut acrylic cover protects the exposed electrical components.

The keyswitches I used are Durock T1 tactile switches lubricated with Krytox 205g0, which I chose out of a desire to try quality tactile switches. After writing much of this article on my Axon, I can say that tactile switches certainly offer a very pleasing typing experience. I’m not sure that I prefer them over linear switches, but the variety is nice.

I have some new keycaps on order which will accommodate my keybindings without misleading labelling (or using shift keys for spacebars, for that matter). For now, I will make do with my trusty set of GMK Bento.

 

Final Thoughts

The Good

So, did I achieve my goals? I think the answer is a resounding yes. It was an incredible feeling to see the keyboard work for the first time, and it appears to be working flawlessly. I love the way it has turned out, both functionally and aesthetically.

This was an amazing introduction into the world of basic electrical engineering. I have learned so much through this process, and I feel that this is a project which I can display with pride.

The Suboptimal

There are, however, some mistakes which I need to own up to. When creating the PCB design, I did not properly account for the size of keyboard stabilizers. As a result, one of the screw holes is not usable since it is blocked by the stabilizer wire. It’s possible that this key (the right spacebar, or “Super” key) could be used without a stabilizer, but the keyboard seems to work fine without this screw. Another consequence of failing to consider the physical footprint of the stabilizer is that some of the silkscreen art is obscured. Luckily, it is not noticeable except under close inspection.

Furthermore, one of my decoupling capacitors is not optimally placed. Instead of being as close to the MCU power pin as possible, it is further away and separated from the MCU by other components. This does not appear to have produced any issues so far (fingers crossed!), but the robustness of the MCU could be improved with simple layout changes.

The Future

There are a few key improvements that I may implement soon. I have been thinking about buying a 3D printer, which I could use to design and produce a proper case. This keyboard also lacks a keyswitch plate, leading to a loss of stiffness. It would be interesting to design, for example, a custom metal plate for production through a laser cutting or water jetting process.

I am also working on a design for a standalone numpad in the same style. It is basically the same process as Axon, and the only difficulty so far is fitting components into a smaller PCB area.

I think the logical next step is to find a project which exposes me to surface mounted components, which can dramatically increase the compactness of electrical hobby projects. Let me know if you have any interesting ideas!

 
 
20210427-DSC07956_smaller.jpg
 

Links and Attribution

Axon is an open hardware project, available on my github.

I posted about this project on reddit.

Axon was included in an issue of Keyboard Builders Digest.

Thanks to my electrical/computer engineer friends, who endured my numerous questions.