PCB Design

The circuitry handbook.

PCB Designer Guide

Learn how to make mech keyboard PCBs.

PCB Designer Guide

PCB Guide Part 1 - Preparations

This guide is intended as a direct replacement for the aging Ruiqi Mao's guide.
Credits go to that guide for serving as a base for this writeup.

If you spot any mistakes, please let me know either through Discord (ai03#2725) or email (ai03.public@gmail.com), and I will fix it to the best of my abilities.

ai03's Keyboard PCB Design Guide

So you want to design keyboard PCBs, or to make sure that you are doing things correctly.
We will build a similar 2x2 macropad in this introduction, but will do so in a more future-proof way compared to the other guides.

Step 1. Grab the requirements

We will be using KiCad for making the PCB.

Download version 5.1.4 from the previous releases folder.

Windows: https://kicad-downloads.s3.cern.ch/index.html?prefix=windows/stable/
Mac: https://kicad-downloads.s3.cern.ch/index.html?prefix=osx/stable/

Why specifically 5.1.4?

There are various stories about KiCad being counter-intuitive and crashing often. However, most of these stories are a relic of ancient KiCad 4.0 variants, and the program runs very stable and smooth with recent updates.

However, just in case, you should always save often and use revision control (see below). 

Now comes the download and install process. Grab a cup of coffee, for the KiCad 5.1.4 installer is a whopping 1GB. 
Install as you would any other program.

Also, this guide will be using Git/GitHub to manage progress.
If you are new to this, grab GitHub desktop here:
https://desktop.github.com/
Install, then sign in or create an account as necessary.
Also, make sure to become familiar with GitHub, as it is very useful for open-source projects.

If you already work with git, use whichever implementation you prefer, and replace all mentions of GitHub in this guide with your preferred methods.

Finally, if you would like community support in case you get stuck, I recommend that you join the Keyboard Atelier Discord server:
https://discord.gg/b7vwhHS
It is a designer haven, with references, datasheets, and various design-specific chat channels.

Step 2. Repository Preparations

First, let's create a git repository for the PCB on GitHub
It is always nice to be able to roll things back in case things get out of hand.
Also, it is a simple and reliable way of sharing your work to the world.

Select File -> New repository,


Then create a repository.

Some of the important options:

This will create a blank repository to begin work in.

Publish the repository,

Using whatever settings you prefer.
Uncheck "Keep this code private" if you want to have the data public and open-source to begin with.

Repository preparations are done.
Now, it's time for initializing the KiCad project.

PCB Designer Guide

PCB Guide Part 2 - Beginning the project

By this point, you should have a repository readied for the project.

Step 3. Creating the KiCad project

The previous page's setup should have created a folder in your home/Documents/GitHub folder with the project name.

 We will be doing all work here.

Launch KiCad, and you will be greeted with the main menu.

From the options, select New Project.

Browse to your repository directory.
Make sure to uncheck "Create a new directory for the project". Otherwise, you will have your project in a useless subdirectory.

KiCad will generate the basic project files.

The default project only has two files:

The basic workflow is to create the schematic first so that the electric side is all set, then to lay it out on a physical PCB based on that.

 

At this point, let's commit our changes.
Give the commit a name, commit, and push the changes.

This guide will occasionally remind you to commit after large milestones; however, it is recommended to do so often. Losing work is not an enjoyable experience.

Step 4. Add local libraries

KiCad is built around libraries - A collection of footprints, and often schematic components bundled with it.
Footprints are the building blocks of PCBs - The sets of copper pads that the components attach to.

KiCad ships by default with support for common electrical components, such as resistors, capacitors, microcontrollers, etc.

It does not ship with exotic things, such as Cherry MX footprints, very specific USB connectors, etc.

Let's take care of that.

KiCad supports two library install types:

We will be using project-specific libraries.

First, we will need to pick which footprint libraries to use.
In this guide, I will be making use of the following repositories:

We will be adding these to our project as Git Submodules - This allows us to pull new changes from them without having to manually download and overwrite the existing files.

Since the GitHub desktop application is fairly awful at managing submodules, we will opt for using the shell instead.

First, navigate to your repository folder, right click in an empty area, and bring up the git shell.

Then, run the following command:
git submodule add URL-OF-REPO

In this case, I will add the two repositories linked earlier.

The GitHub desktop GUI seems to have issues with committing submodules, so let's do it from the command line:

git add *
git commit -m "Add submodules"
git push

The commands adds the new submodules to the commit, creates a commit with the given name, and pushes it to GitHub.

After the push finishes, you can see that the library repositories are linked in your GitHub repository.

Now that the files are there, let's add them to the project.

First, open up your schematic file,