## KiCAD - Overview
### Basic Concepts and Workflow
KiCAD mainly consists of two things:
- Schematics containing **Symbols**.
- PCBs containing **Footprints**.
A KiCAD Project is a Folder.
That folder will contain:
- Project File
- Schematic
- Board Layout
- Other
- Symbol Libraries
- Footprint Libraries
- Simulation Data
- Purchasing Information
#### Schematic Capture
Schematics are drawn first. PCBs are laid out second.
Custom symbols may need to be created for the Schematic.
It is during Schematic capture that footprints need to be assigned to the components.
When the schematic is complete, it must pass an ERC - Electrical Rules Check.
#### Board Layout
The layout process requires each footprint to be placed precisely and carefully.
After component placement, copper traces are drawn to fulfill the connections detailed in the schematic.
Custom footprints may need to be created for the Board Layout as well.
Once the board layout is complete, it must pass a DRC - Design Rules Check.
After that, fabrication files are generated so the board can be manufactured by a PCB fabricator.
#### Reciprocity
Schematics can be updated after layout has begun. Changes to the schematic are easily pushed into the board design.
The reverse is true as well: changes in the board layout can rewrite the schematic.
### Tutorial Part 1 - Project
#### Main Menu
Contains Several Tools:
1. Schematic Editor
2. Symbol Editor
3. PCB Editor
4. Footprint Editor
5. Gerber Viewer
6. Image Converter
7. Calculator Tools
8. Drawing Sheet Editor
9. Plugin and Content Manager
The Main Project File - `.kicad_pro`
The Schematic File - `.kicad_sch`
The Board File - `.kicad_pcb`
Take the time to get familiar with your options and configs in Preferences.
### Tutorial Part 2 - Schematic
Do Page Setup and Sheet Setup first
Controls:
- `M2` or `M3` - Pan/Drag
- `Scroll` or `F2/F1` - Zoom In/Out
- `SHIFT+SCROLL` - Pan Up/Down
- `CTRL+SCROLL` - Pan Left/Right
- `A` for Add Symbol
- `M1 Drag` or `M` - Move
- `SHIFT+M1` - Add to selection
- `CTRL+M1` - Add/toggle selection. The usual stuff
- `G` - Drag, similar to move
- `R` - Rotate
- `DEL` - Delete
- `W` - Wire
- `P` - Add a Power Symbol
- `L` - Add a Net Label
- `E` - Properties
- `X, Y` - Flip Horizontal, Vertical
- `Insert` - Repeat last operation
Tips:
- For connected symbols, M will release the connection, G will maintain it.
- Mouse Drag performs G - Drag by default, enabled in settings.
- You CAN pass wires through multiple components in series and link them all at once, just as in LTSpice.
- Power symbols are important for clarity and there are many available in the power symbols library.
Schematics require the following for every symbol:
- Annotation
- Values
- Footprint Assignments
#### Footprint Selection
**Every symbol needs to have an assigned footprint. How else would you layout the PCB?**
You can right-click any of the individual footprints and select `View selected footprint` to open a popup viewer.
There are several ways to filter the *gazillion* footprints:
- Filter by footprint types specified in the selected Symbol
- The symbol itself can contain data that constrains what footprints should be associated with it
- Filter by pin count
- The symbol has a number of pins, the footprints also have some number of pins
- Filter by library (toggle)
- When you click a Footprint Library on the left side, it activates this filter.
- To deactivate it and see all libraries, just click it again to disable
- Search
**It's usually best to use the Symbol Filter OR the Library Filter but not both**
#### Electrical Rules Check
Run it before proceeding to Layout, and after any schematic changes along the way.
It will find many potential errors.
If you click the symbol it's referencing, it will place a red arrow and move your camera to the component.
You can exclude violations by right-clicking each error message.
It's worth addressing all violations even if they aren't design errors, if only to get a clean ERC report.
It's good practice to avoid missing the real problems.
In this case `Input Power pin not driven by any Output Power pins` is a common ERC error.
Power symbols like `VCC` and `GND` expect to be driven by some other power output pin, like a Voltage Regulator.
It's obvious to a human that these pins are driven by the battery, but not to KiCAD.
`PWR_FLAG` is a "Special symbol for telling ERC where power comes from"
When the ERC passes without any violations, the schematic can be considered complete.
#### Bill of Materials
Tools -> Generate Bill of Materials
This is optional - it will produce a .csv for you.
### Tutorial Part 3 - Circuit Board
Basic UI Info:
- Some buttons have a triangle in the bottom right, indicating there's a expanding tool palette inside.
- Right side has an Appearance Panel where you can adjust visibility, opacity, and colors of PCB layers, objects, and nets.
- This is also where you can click and select the Active Layer.
- Under the Appearance Panel in the bottom right is the Selection Filter, which enables and disables various object types. Useful for picking out specific stuff in a crowded layout.
#### Board Setup and Stackup
It's very important to configure the board's settings before proceeding.
`File -> Page Settings`
`File -> Board Setup -> Board Stackup -> Physical Stackup`
Board Setup is also the second button in the top bar.
**There are a ton of settings here with a lot of nuance, but you have to take the time to define them properly.**
The most important settings are the stackup & design rules:
`Board Setup -> Board Stackup -> Physical Stackup`
This is where we select what copper and dielectric layers the PCB will have, and their thicknesses.
`Board Setup -> Design Rules`
This is where we set sizes and spacing for tracks and vias.
**For real projects the Design Rules/Constraints should always be set according to the listed capabilities of the PCB Fab House so that the PCB design is actually manufacturable.**
It's easy to find the manufacturing capabilities on JLCPCB's website:
https://jlcpcb.com/capabilities/pcb-capabilities
##### Net Classes
You can create Net Classes, and define a set of custom design rules associated with a specific group of nets.
This menu is both where you design the rules & assign the nets.
Of course, track width and spacing can be managed manually during layout in the editor.
Net Classes are best practice because they provide an automatic way to manage and check design rules.
##### Importing Changes from Schematic
When you first switch to the Layout, the components from the Schematic won't be there.
To import data from the Schematic into the Layout, click the button on the top bar, or press `F8`.
**Updating Schematic -> PCB is a manual process and the designer needs to decide when it is appropriate to update the PCB with modifications from the schematic.**
**Each time the schematic is edited, the designer must use the `Update PCB from Schematic` tool to keep the Schematic and Layout in sync.**
##### Board Outline
The board's outline and dimensions need to be defined by drawing a single closed shape on the `Edge.Cuts` layer.
It's good to switch to a coarse grid, e.g. 1mm for the outline.
##### Placing Footprints
Ratsnest - the thin lines indicating unresolves connections between pads
**Controls:**
`M` - Move
`F` - Flip
`R` - Rotate
**Some considerations for arranging the footprints:**
- Some footprints have exact requirements for their locations.
- e.g. connectors, indicators, buttons, switches.
- Some components have electrical considerations.
- Bypass capacitors should be close to power pins for their IC.
- Sensitive analog components should be far away from digital interference.
- Almost all components have a "Courtyard".
- Generally speaking, courtyards should not intersect.
- Generally, seek to minimize routing length and complexity
##### Routing Tracks
`X` - Route Tracks
`V` - Place Via
`D` - Drag, extending Trace
**After routing tracks, if you need to move a component, use `D` to Drag while extending the trace dynamically.**
Good color theme helps here.
##### Copper Fill Zones
The shortcut for a Copper Zone is `CTRL+SHIFT+Z`.
There is an associated dialog window.
When outlining the Copper Zone's perimeter, left click to add points, and double click to end the polygon.
**These outlines are incomplete and still need to be filled with copper.**
Fill the zones with `Edit -> Fill All Zones` or `B` and `CTRL+B` to fill and unfill respectively.
The zone properties is where all the zone settings & thermal reliefs are defined.
##### Warning - Zone Fill Errors
Zones are not filled automatically when first drawn nor when modified nor when footprints are moved.
Zones are refilled manually both when you fill them, and when you run the DRC.
**Make sure zone fills are up-to-date before generating fabrication outputs**
##### Design Rule Check
Layout Editor -> Design Rule Check (DRC)
Schematic Editor -> Electrical Rule Check (ERC)
The full list of design rules and their severity level is under
`File -> Board Setup -> Design Rules -> Violation Severity`
Like with the ERC, running DRC and fixing all errors is strongly advised before generating Fabrication Outputs.
Run a DRC with `Inspect -> Design Rules Checker` or click the button in the top bar.
There is a button to Refill all Zones before performing DRC, which is convenient. On by default.
##### 3D Viewer
There's a 3D Render tool for the PCB under `View -> 3D Viewer` or by pressing `ALT+3`
Raytracing is available as well.
The 3D Models for each component are associated with the footprints, in the footprint library.
Since not all footprints come with 3D models, users can add their own if they wish.
##### Fabrication Outputs
The board layout is finished, so the final step is generating fabrication outputs to send to a manufacturer.
From the Layout Editor, go to `File -> Plot`.
###### Plot Options:
- **Plot Format:** It's almost always going to be Gerber.
- **Include Layers:** Ensure all the necessary layers are checked, such as coppers, edge.cuts, mask, silkscreen, paste, etc.
- mask - soldermask
- paste - useful for manufacturing solder paste stencils for surface mount boards
- **Plot on All Layers:** Self-explanatory, not very necessary in most cases.
- **Output Directory:** Relative to the project folder (e.g. `fab/`)
- **General Options:** Default settings are fine
- **Gerber Options:** Default settings are fine
To produce the actual fabrication outputs, there's another dialog to handle under `Generate Drill Files`
**Plot** - Generates the Gerber Files
**Generate Drill Files** - Generates the files that specify the location of all the holes in the board.
**Both are necessary to fabricate the board**.
##### Final Output
Check the output folder and review the gerber and drill files produced.
- There should be a Gerber file for each layer included.
- There should be a Gerber Job File.
- There should be a few Drill Files.
![[Pasted image 20241206085436.png]]
##### Gerber Viewer
KiCAD has a Gerber Viewer that allows you to review these files.
Opening all of the Gerber Files in the viewer will produce a new layer stackup where you can toggle visibility for each layer and verify things look correct.
### Custom Symbols and Footprints
#### Library and Library Table Basics
Symbols and Footprints are both organized into Libraries.
**A Library can hold Symbols or Footprints, but not both.**
Alongside the Global Libraries, there are also Project-Specific Libraries.
From the Schematic Editor: `Preferences -> Manage Symbol Libraries`
From the Layout Editor: `Preferences -> Manage Footprint Libraries`
Both Libraries can be accessed from `Preferences` from the Main Menu/Project Manager.
##### Path Substitutions
**Symbol Library:**
- `${KICAD8_SYMBOL_DIR}` - Standard symbol library directory
- `${KIPRJMOD}` - Current project directory
**Footprint Library:**
- `${KICAD8_3DMODEL_DIR}` - Standard 3D model library directory
- `${KICAD8_FOOTPRINT_DIR}` - Standard footprint library directory
- `${KIPRJMOD}` - Current project directory
##### Creating New Global or Project Libraries
**Symbol Editor** is another tool in the Main Menu. Creating a new symbol and creating a new symbol library to contain it both occur here.
After creating this new Project-Specific Library, you can go to `Preferences -> Manage Symbol Libraries`, switch to the tab `Project Specific Libraries` and it will appear there.
#### Creating New Symbols
Select the Library you want to add a symbol to.
Hit `CTRL+N`, right click the library, or hit the new symbol button on top bar.
You'll have to specify the Name of the symbol, and it is wise to set the Default Reference Designator.
##### Symbol Pins
`P` - Add Pin
Pins require a few properties:
- Pin Name - `A`
- Pin Number - `2`
- Electrical Type - `Passive`
- Orientation - `Right`
- X Position - `-200 mills`
- Y Position - `0`
Tips:
- Keep in mind each individual Pin has its own properties,
- and then the Symbol overall has its own properties.
- For simpler symbols, it may be convenient to turn off Pin Names in the Symbol's Properties.
- Remember to fill out the Keywords section for the Symbol, so that it's easier to find via search later on. In this case, `spst switch toggle`.
##### Symbol Editor - Critical Information
Small grids are useful for graphical features, but symbol pins must always be placed on a 50 mil (1.27 mm) grid. Pins which are not aligned to a 50 mil grid will not be able to connect to wires in the schematic.
It is strongly recommended to always use mils (or inches) in the Schematic Editor and Symbol Editor, particularly for symbol pins. Mixing imperial and metric units will result in symbol pins that cannot be properly connected because they do not align with wires or other pins. The KiCad libraries use a 50 mil grid for their pins; using a different unit system will prevent your symbols and schematics from connecting with KiCad’s builtin symbols. Note that unlike in the PCB editor, units in the schematic have no physical meaning.
#### Creating New Footprints
To create a custom footprint we have to dimension several tedious things:
- Create a footprint library for the project
- Determine physical pin size
- Determine hole size (some margin larger than pin)
- Determine annular ring size for solder pads
- Determine placement geometry for each unique pin
- Design Cosmetic Footprint Graphics
##### Custom Grids to simplify Pad Placement
For ease of placement, adjust the grid to match the desired pad spacing.
Open the grid settings by right clicking the grid button in the left toolbar and select `Edit Grids`.
You can add a new grid with the + button, and set its size to the dimension between the pins, in this case `4.7mm`
##### Footprint Generators
Instead of clicking `New Footprint` you can select `Create Footprint` and a Footprint Generator/Wizard will open
##### Footprint Tips
**Note:** the properties assigned to the previous pad and hole size will be considered as default for the Footprint and will be copied from the previous pad.
**Note:** You can right click on a pad after making an adjustment and then click `Push Properties to Other Pads`
**Note:** The pad size fields accept mathematical expressions, such as `1.62+2x0.3`, etc.
These mathematical expressions can include unit conversions as well.
##### Footprint Graphics
A good footprint will have three graphics:
- The exact part outline on the fabrication layer - `F.Fab`
- A slightly larger outline on the silkscreen layer - `F.Silkscreen`
- An even larger boundary on the courtyard - `F.Courtyard`
###### Fabrication Outline
![[fab-outline.png]]
###### Silkscreen Outline
![[silk-outline.png]]
###### Courtyard
![[courtyard-outline.png]]
###### Finished Footprint
![[Pasted image 20241206204956.png]]
##### KiCAD Library Conventions
There is a **KiCAD Library Conventions** document which provides a set of guidelines for symbols and footprints. They are a good starting point.
Symbols in the official library are requires to follow the **KLC**.
[KiCAD Library Convention (KLC)](https://klc.kicad.org/)
The [KLC requirements for footprint filters](https://klc.kicad.org/symbol/s5/s5.2/) contain some useful tips for effective footprint filters.
##### Add Footprint to Symbol
The next step is to link the Footprint to the Symbol.
KiCAD will know to set the Footprint as the default option when that Symbol is used moving forward.
**Process:**
- Open the Symbol Editor
- Open the switch symbol
- Edit the Symbol's properties
- Go into the `Footprint` field:
- Click the library book
- Find the Project-Specific Footprint Library
- Select the Switch Footprint
- Save the Symbol
##### Add Symbol to Schematic
- Open the Schematic Editor
- Open the Project-Specific Library created for this design
- Select and add the custom component in
- Wire the component into the schematic
- Re-run ERC
**Always Re-run ERC when you are done making changes to the Schematic Editor**.
##### Add Footprint to Layout
Switch to PCB view, and run `Tools -> Update PCB from Schematic` or `F8` or the top bar button.
Since the PCB Layout needs to be revised and several components need to be repositioned, remember to press `B` to recalculate the fill zones. Otherwise the board will be useless.
Be sure to re-run DRC after making adjustments to the Layout.
Double check and ensure the switch has the footprint listed under it's `Footprint` Property.
*At this point, we would also re-export the gerber/fabrication files, but the tutorial is now complete.*
##### Footprints and 3D Models
- 3D models for components are stored in separate files from the Footprints themselves.
- The filenames for the 3D models are saved in the Footprint.
- Any number of 3D models can be added to each Footprint.
- There is a `3D Models` tab under `Footprint Properties`.
- KiCAD can automatically select the STEP version and export a 3D model of the board for MCAD integration.
**Not all footprints in KiCad’s library are provided with 3D models, but all footprints list a 3D model filename even if the 3D model does not exist. This is so 3D models can be added at a later date without needing to edit the footprint.**