Understanding Kicad: let's make a PCB!

Kicad: 6.99

Date: 2022


Disclaimer

​​This guide is not the first, nor is it the most comprehensive for keyboard PCB creation. The reason I'm writing this is to help people who want to start making keyboard PCBs but have no clue where to start. When I started, I had a really hard time finding information, and understanding the process. I have no formal education in electronic design and if you don't either then no worries. I hope that this will guide will shed some light on how this whole process works

Vocabulary

  • MCU - The Micro Controller Unit. This is the brain of our keyboard that will need to be programmed to make everything work. Think of it like a small CPU.

  • Matix - The interconnection of rows and columns that we will wire our switches to.

  • Diode - an electrical component that only allows for the travel of electricity in one direction.

  • N-Key Roll Over - The ability of a keyboard to press each button independently of another without any electrical limitations. This is achieved by using diodes per switch on our PCB.

  • Kicad .pro file - The main file of your kicad project.

  • Kicad .sch file - The schematic file of your kicad project.

  • Kicad .pcb file - The physical PCB file for your kicad project

Getting started

There are a number of different applications out there that will allow you to make a keyboard PCB, but the one I recommend is called Kicad. It is relatively user-friendly, and a majority of the community seems to agree that it is the best software out there for what we want to do. It's also free! There are two versions that you can download. The official release and the nightly version. The official release is more stable but lacks some crucial functionality. For that reason, I recommend that you download the most current nightly. One thing to note is that the nightly versions come out often, and files that have been opened in a newer version of Kicad can not be opened in an older version. If you ever decide to update your nightly version, make sure to make a backup of your files, just in case you need to roll back to an older, and maybe more stable version. Kicad will also do this for you, but you can never be too safe.

Here is a link to the nightly page for windows and mac

Getting Familiar

Now that you have kicad installed, open it up and make a new project. Once you do you will notice that there will be three files. the "pro" "pcb" and "sch" file. you can think of the “pro” file as somewhat of a folder. It is the main file that you should open, and access your project through. It is possible to directly open the "pcb" or "sch" files, but doing so will cause limited functionality, so it's best to always open the PCB or schematic file from within the “pro” file menu.

Before we can start making our PCB, we need to add all of the drawing and placement templates that we might need. These files are .lib and .pretty. The .lib files are library files to help us make a proper schematic. .pretty files are template blueprints that are physically placed on the PCB.

You can download a collection kicad files that I use here
Another popular collection by ai03 here

Drag and drop your footprints into the directory of your kicad working folder. In order to keep things organized I recommend keeping all footprint ".pretty'" files in a master folder called lib.

Now to add the libraries onto our project. Open into the schematic and go to preferences/My symbol libraries. From inside here, we have two options. To manage the global libraries or project-specific ones. By adding libraries globally, the library information will remain on your computer and will be available for all new projects, with the downside of being unavailable for others you might share your project with. That is why I recommend you always add libraries per a project basis. That way when a project is shared with another computer, others will have access to the library content.

From here manually add the .lib files that you will need for your project. If you are using my kicad collection, then the .lib files are in the "Schematic Library" folder.

Once added we will need to add the footprints to the PCB file. We can do this by opening the pcb file and going to preferences/manage footprint libraries. Just like with libraries, footprints can either be global or project-specific, and I recommended you use project-specific, using the same logic. From here add any of the .pretty folders that you might need for your project. Once that is all done you should have everything all ready to start making your PCB.


Making your pcb schmatic

Your PCB schematic is the blueprint diagram for how your PCB will be connected. In the schematic, we don't need to worry about things being too pretty Instead, we want to focus on making sure everything is connected properly and easily readable. Before we get started, I think it will be good to show you a couple of the buttons that will be the most helpful. The first is the search button, which allows you to look for schematic components. If you are making a mx/alps PCB we can search for the mx/alps hybrid switch diagram. The non-led refers to a normal switch while the led refers to a lock light switch. by double-clicking, we will have this footprint available to us.

Our switch will need a diode if we want N-key rollover, so like find one of those, by looking for device/d_small. Now that we have those two things we can connect them. Doing so will require us to know a couple of shortcuts. When something in is selected.

(R) - will rotate

(F) - will flip

(E) - will edit what is currently selected

(W) - will create wires

(A) - will search for symbols. The same as the search button

(P) - will open up the power symbols menu

(Ctrl + H) - will create net labels, like what is used for our columns and rows


You will want to flip the diode to the direction of the triangle facing down. After you can move your cursor over the circle and a green pen will allow you to draw and connect the ends. Connect the diode to the switch like so.

Now that we have some schematic diagrams, we need to match that to a PCB footprint. To do so, double-click the part and select what footprint we want to use with it. You can use the little book icon to view all of your footprints. I'm going to select

MX_Alps_Hybrid:MX-1U-NoLED "for the switch"
Diode_SMD:D_SOD-123 "for the diode"

Note that if you want to use other sized switches other than 1u, you can select that here, that way each switch has the proper footprint over on the PCB.

Note that you can also manually change the reference value of each symbol in this window, which in this photo is labeled as MX1. If you do decide to manually change part names keep two things in mind. Keep the name consistent and numberd. For example you can rename all of the switches Alps1... Alps2... Alps3... but you should not name them Q... W... E.... R..., ect.

Now that we have that settled. I'm going to copy and paste this 8 more times to give us 9 switches. and connect the columns together and diodes together to give us a 3x3 grid. If you do so it should look something like this. Notice that every switch has a unique numbered, to identify that it is different. This should be done automatically for you by kicad, but if it does not, then you can force it to annotate by going to tools/Annotate Schematic


Adding your MCU

By far the easiest way to go is by choosing an MCU that already has its logic laid out on a separate board. Something like a teensy/ pro micro/ or black pill, for this example. For this PCB I'm going to use a teensy 2.0, but the process should be the same for most types of MCU. Onboard MCUs are out of the scope for this beginner guide. To add the teensy I'm going to search for it the same way I found the switch and diode. The schematic info will be as follows


Value :keyboard_parts_TEENSY2.0

Footprint: teensy:Teensy2.0

Connecting everything

Now we have to connect our keyboard matric to the MCU. This can be done using labels, and will help keep our schematic clean. It is important to know the naming convention starts with row 0 and column 0. This can be a little confusing, but the first column will be column 0 and the first row will be row 0. To add naming tags, go to “place/add global label” and name it col0. Now repeat the process, renaming each tag as required. Now add a label to both the wires of the matrix and to the MCU pins.

And just like that, the most basic 9x9 keyboard schematic is done. This is about as simple as it gets, but with this information, you now have the basics. Let's move over to the PCB to place the physical footprints.











Note: When placing row and column labels on the mcu, don"t worry to much now about the perfect pins to use. This will be more clear as we start to build the PCB. Though, it is important to say away from putting rows and columns on pins like RST, AREF, VCC, and GND.

These pins are not generally programable, and it is best to say away from these pins as they have a dedicated purpose already.

RST - Used to put the mcu into flashing mode

AREF - Used for analog reference values

VCC - Used as the power pin, with a steady voltage

GND - Used as a ground pin.

PCB Side

Once the PCB is open it will look blank. In order to place the objects from the schematic. Find this button on the top right of the screen. When pressed it will populate the PCB file with all of the information from the schematic (F8 also works). When you do so, things will kind of get dumped out in a random way. A good way to remember what exact component your looking at is by selecting a part and hitting the ~ key. This will highlight the item in both the schematic and the PCB file. if you ever get lost, you can press the schematic button on the top right to flip back and forth between the schematic and the PCB.

Now let's take the time to understand some of the shortcuts that will make your life easy here

(F) - Flip item. you will notice that it will change the color of the component when done. That is because the color denotes what side of the PCB you're looking at. Red being the top and blue being the bottom, if you are on the standard settings.

(R) - Rotate the item. This will rotate a footprint in increments of 90 degrees while keeping it on the same side.

(~) - highlight a selected item, and all components that it's connected to. Like I said before, this is very helpful when trying to make sense of a cluttered screen.

(X) - makes a wire, color being denoted by whatever side you are currently viewing.

(V) - Flip view, to allow you to switch quickly from viewing either the top side or bottom side of the PCB.

(S) - Set grid 0,0 point.

(Space) - Create a grid origin reference point, helpful for knowing how far something has traveled.

(Shift + P) - This is position relative to, a very helpful thing for getting footprints exactly where you want them.

(Shift + M) - This is an exact move tool. It works a lot like the position relative tool.

(Alt +1) - Switch to grid style one.

(Alt +1) - Switch to grid style two.

(Esc) - this will allow you to stop using whatever tool you are using.

There are many ways to do the exact same thing, and each person will find a different way to reach the same result, but these are the shortcuts I use all the time and beats having to go into a menu every two seconds. that being said, You should be able to find each of these things from inside a menu also if you forget the shortcut.


There are also a few buttons that I think will be very helpful to know.

The measure tool on the bottom right will allow you to measure the distances between two points.

The draw line tool on the bottom right will allow you to draw lines, for example, when we want to make our edge cuts.

The DRC tool on the top will check if there are any conflicts with our design, which will be needed at the end of any project.

The ratsnest button on the left will hide/show all of the gray lines connecting components. When you are placing parts, it is helpful to have all that go away.

Lastly, let's change out the user grid, this will be important for the easy positioning of our switches. To do this go to the top and look for the grid options. Then find the button that says edit user grid. We will want to put both our x and y grids to:

0.79375mm, which is the number I get when doing 19.05/24
you can also do...
2.28125mm, which is the number you get when doing 19.05/8

Eaither will work for our switch demsionsion.

Then once set, make sure to select the user grid. The selected grid will have a checkmark as shown.

With everything, all set it is time to arrange our footprints. With our grid set properly it should be just as easy as dragging things around. If you have many switches it may be hard to find exactly what switch you want. A quick way to find something is to open the schematic file in another window. By clicking on the switch in the schematic it should bring you right to the same switch on the PCB. Also, using (~) to highlight what is selected, will do so on both the schematic and the PCB.

Addition position information: Position relative to

It is sometimes important to position one thing in relation to another. Let's say for a nav cluster or a Numpad that is not directly connected to the PCB. Using position relative to you can move one thing exactly from another. Note that Kicad currently positions a footprint from its leftmost pad, so when selecting the relative point, select the leftmost pad of the relative footprint.

An example of this would be to position a 1u switch exactly 19.05u from another 1u switch. To do this I would click the col 1 row 0 switch to highlight it and press shift + P. I will select a “position relive to” and it will allow me to select another footprint. I am going to click on the col0 row0 switch (leftmost blue pad) to be my relative reference point. Then it should ask me to deviate the distance, and I will put 19.05 in the x coordinate position. once I hit okay it should move my second switch perfectly in line with the switch that I selected. Using this methodology you can always perfectly place any footprint.

Now Im going to go through and place all switches in a 3x3 grid, and it should look something like this.

I am now going to highlight all of my diodes and hit F, to flip them to the blue (back) side. This will move the diodes to the back side of the PCB, and away from our switches when we want to solder them to the board. I am also going to rotate them with R so that the triangle of the diode is facing downwards. Then I'm going to go through and find the diode that corresponds with each switch using the highlight method, and position each diode relative to its corresponding switch with an X shift of 9.52mm (or half the distance of a switch) and a y value of 3, just to move the diode out of the way a bit. The end result should look like this.

The next thing we need to do is make out edge cuts. From this point on I like to change my grid view to something a little more precice. I use 0.2 mm for example, but the exact grid you choose doesn't matter to much. To do this go to the line tool and select edge cuts. Then draw an outline around your footprints. In order to get an exact distance, you can hit the space bar at some starting point, and this will 0 the coordinate system at the bottom bar on the screen. Doing this will allow you to see how far exactly you have drawn. Look at Dx and Dy here.

Now I'm going to arbitrarily draw my edge cuts, though note that you can use the measuring tool or spacebar method if you need to draw exact measurements for a given edge cut. By holding shift and space, you can lock your line to an axsis, which will help keep things straight. After that is done, we will want to round off the edges of the PCB, as some PCB manufacturers have a hard time producing right-angled cuts. Also, PCBs with right angles are sharp to the hands. Let's fix this by using the arc tool (right below the line tool). To use the tool, you will move your cursor evenly in the x and y direction. The first click will be so you can see the center point. The second click will be where you would like to start your arch. Then you will move the curser clockwise until you have moved 90 degrees . Once done make a third click to finish the curve. The tool is a little strange and will take some time to get used to. Just know if you do have some trouble with it, you are not alone. Once you are done you can click and drag the endpoints to line up with the curves you just made. It should end up looking something like this.

Now it's time for the fun part, connecting pads with traces. To do this, hover the mouse over a pad, and click the X button to start drawing a trace. Then move to a pad that is highlighted, and connect the trace. You can go back to the show ratsnest icon and turn it on if that helps you remember where to connect things. We have made our diodes blue to keep them out of the way of out switches, and for that reason we are going to want to connect out diodes (rows) with blue traces on the back of the pcb. This will almost always be a horizontal line. The columns then, will be vertical lines. Normally, vertical lines will be drawn on the front side, preventing rows and columns from crossing on the same side of the pcb.

In this way there are various "best practices" when making a pcb.
1. Short traces are normally better, this is not true for data lines in USB which also want to be generally the same length. Though that is out of the scope of this guide
2. Horozontal lines should generally stay blue, and vertical lines should generally stay red. On a small pcb like this you problly wont find yourself running into any issues if you don't follow this, but on a larger pcb you will run into problems down the line .
3. Use vias sparinly. Using a lot of vias is not exactly a bad thing. Though it is generally seen as sloppy (not drawing your traces better).
4. Think about your traces before hand. If you plan out how your going to connect thing, you will run into less conflicts down the line. This will also save you from using lots of vias.

Once it was time to attach the wires to the MCU, I found that some of the pads on the teensy were chosen sub-optionally. This is normal as we chose our MCU points arbitrarily. We can go back to the schematic and change which pads we want to use by moving the labels on the MCU. I have changed it like so. When you do this make sure to use the "update PCB form schematic” button.

Once all of your traces are connected. It's time to do some cleanup, Go to tools and run "clean up tracks and vias". The clean up tacks and vias tool is great, but don't treat it as en end all. Make sure to give everything a good look over afterwords. After that, we are going to want to run the DRC application. Doing so will show us if we have any errors or warnings. Sometimes an error will occur on an intentional choice. For example on this board, we are getting an error like shown below.

These drill hole errors are showing us that our footprints have drill holes that overlap. This is okay as this is a footprint that is using both alps and MX switches., and the wholes of the two items overlap, which is what we want. Once all of your errors have been solved or understood, we can take a look at our PCB in 3d. You can find this setting under the view option at the top of the screen. (Alt +3)

Now it's time to produce the files that we will need to manufacture the PCB. There are many ways to do this, but I believe the way I'm about to show you is by far the easiest. Open up the Kicad “pro” file and go to the plugin and content manager.

from here we are going to go to manage and add an amazing toolkit from Bouni. Paste in this link.

https://raw.githubusercontent.com/Bouni/bouni-kicad-repository/main/repository.json

Then use the drop tab to change the repository to the one added. From there you will have to install and apply the changes.

Once this is done, when you open up your PCB you should see a new icon. By clicking this button we will have access to a powerful tool that will build our fabrication files for us.

The first thing you're going to want to do is to update the library, with the button on the top right. The after that, we will need to match our footprint part with a real part that JLCPCB has. The only part we need to match is our diodes for this PCB, so I'm going to highlight them and click select part. For the diodes, I'm going to search for part number C2099 and select the part.

Once all of our parts are selected, I am going to hit the "generate fabrication files” on the top left. This will create a folder called JLCPCB in our project folder. Inside will be all of the fabrication files we need to have our PCB manufactured.

Just like that we have created a test PCB, and are ready to send it off to the manufacturer. Though this was a simplistic PCB, The fundamentals will remain the same for any standard PCB you would like to make.

If you want to download my test version, you can do so here.