Tutorial Part 3: Circuit Board

With the schematic completed, go back to the Project Window and open the PCB Editor, either by clicking the PCB Editor button or opening the board file.

PCB Editor Basics

Navigation in the PCB Editor is the same as the Schematic editor: pan by dragging with the middle mouse button or right mouse button, and zoom with the scrollwheel or F1/F2.

The main part of the PCB Editor is a canvas where the board will be designed. The toolbar on the left side has various display options for the board, including units and toggles for outline/filled display modes for tracks, vias, pads, and zones. The toolbar just to the right of the canvas contains tools for designing the PCB.

Some buttons on the right toolbar have a small triangle in the bottom right corner pcbnew palette buttons. The triangle indicates that the button has an expanding palette containing several related tools, for example different kinds of dimensions. To select an alternate tool, click and hold on the button until the palette appears, then click on the alternate tool. Another way to use the palettes is to click on the button and drag to the left until the palette appears, then release the mouse button when the desired tool is highlighted.

At far right is the Appearance Panel and Selection Filter. The Appearance panel is used to change visibility, colors, and opacity of PCB layers, objects, and nets. The active layer is changed by clicking on the name of a layer.

Below the Appearance Panel is the Selection Filter, which enables and disables selection of various types of PCB objects. This is useful to select specific items in a crowded layout.

Board Setup and Stackup

Before designing the board, set the page size and add information to the title block. Click FilePage Settings…​, then choose an appropriate paper size and enter a date, revision, and title.

Layout Page Settings

Next, go to FileBoard Setup…​ to define how the PCB will be manufactured. The most important settings are the stackup, i.e. what copper and dielectric layers the PCB will have (and their thicknesses), and the design rules, e.g. sizes and spacing for tracks and vias.

To set the stackup, open the Board StackupPhysical Stackup page of the Board Setup window. For this guide, leave the number of copper layers at 2, but more complicated projects might require more layers.

Physical Stackup

Next, go to the Design RulesConstraints page. The settings on this page specify the overriding design rules for everything in the board design. For the purposes of this guide, the defaults are fine. However, for a real project these should be set according to the capabilities of the PCB fab house so that the PCB design is manufacturable.

Constraints

Finally, open the Design RulesNet Classes page. A net class is a set of design rules associated with a specific group of nets. This page lists the design rules for each net class in the design and allows assigning nets to each net class.

Net Classes

Track width and spacing can be managed manually by the designer during layout, but net classes are recommended because they provide an automatic way to manage and check design rules.

In this design, all nets will belong to the Default net class, and the default design rules for this net class are acceptable. Other designs may have multiple net classes, each with different design rules. For example a board might have a High Current netclass with wide traces, or a 50 Ohm netclass with specific width and clearance rules for 50 Ohm controlled-impedance traces.

Importing Changes From Schematic

The schematic is complete, but there are not yet any components in the layout. To import design data from the schematic into the layout, click ToolsUpdate PCB from Schematic…​, or press F8. There is also a button update pcb from sch 24 in the top toolbar.

Read through the messages in the Changes To Be Applied window, which will say that the three components in the schematic will be added to the board. Click Update PCB, Close, and click on the canvas to place the three footprints. The location of each footprint relative to the others will be changed later.

Update PCB from Schematic

Footprints Added

In KiCad, updating the PCB with changes in the schematic is a manual process: the designer decides when it is appropriate to update the PCB with modifications in 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.

Drawing A Board Outline

Now the three components have been placed, but the board itself has not been defined. The board is defined by drawing a board outline on the Edge.Cuts layer.

It’s often useful to draw the board outline with a coarse grid, which makes it easy to get round numbers for the board size. Switch to a coarse grid by selecting 1mm in the Grid dropdown menu above the canvas.

1mm grid

To draw on the Edge.Cuts layer, click Edge.Cuts in the Layers tab of the Appearance panel at right. Choose the rectangle tool add rectangle 24in the right toolbar, and use it to draw a rectangle roughly surrounding the three footprints. The other graphic tools (line add line 24, arc add arc 24, circle add circle 24, or polygon add graphical polygon 24) could also be used to define the board outline; the only requirement is that the outline is a single closed shape that doesn’t intersect itself.

Edge Cuts

Placing Footprints

The next step in the layout process is to arrange the footprints on the board. In general, there are a several considerations for positioning footprints:

  • Some footprints may have exact requirements for their locations, such as connectors, indicators, or buttons and switches.

  • Some components may need to be placed according to electrical considerations. Bypass capacitors should be close to the power pins of the associated IC and sensitive analog components should be far from digital interference.

  • Almost all components have a “Courtyard” (or two if both Front and Back are defined). Generally Courtyards should not intersect.

  • Otherwise components should be positioned for ease of routing. Connected components should generally be close together, and arranged to minimize routing complexity. The ratsnest (the thin lines indicating connections between pads) is useful for determining how best position footprints relative to other footprints.

For the purposes of this guide, the only placement goal is to make the routing process as simple as possible.

Start by moving the battery holder BT1 onto the back side of the board. Click it to select it, then press M to move it. Press F to flip it to the opposite side; it now appears mirrored and its pads have changed from red to blue.

BT1 flipped to the back

All PCB layers are viewed from front side of the board. Footprints on the bottom of the board are therefore upside down and appear mirrored.

Each PCB layer has a unique color, which is shown by the swatches in the Layers tab of the Appearance panel. In the default color scheme, items on the F.Cu (Front Copper) layer are red, while items on the B.Cu (Back Copper) are blue.

Now place the other two components. One at a time, select each component, then move and rotate it with M and R. Watch the ratsnest lines between each pad to choose the simplest arrangement of components; a good arrangement will leave the lines untangled. One possible arrangement is shown in the screenshot below.

Footprints positioned optimally

Routing Tracks

With the components in place, it’s time to connect the pads with copper traces.

The first trace will be drawn on the front of the board, so change the active layer to F.Cu in the Layers tab of the Appearance panel.

Click Route Tracks add tracks 24 in the right-hand toolbar or press X. Click on the led pad of D1. The ratsnest line indicates there is an unrouted connection to the led pad of R1, so click on that pad to draw a trace connecting the two pads. Clicking on the second pad completes the trace. The ratsnest line between the led pins is no longer drawn because the connection has been made in copper.

First connection routed

Now draw a trace between the GND pads of BT1 and R1, starting with the BT1 pad on the back of the board. Notice that the active layer automatically changed to B.Cu after clicking on the BT1 pad. Click on the D1 pad to finish the track.

While BT1 has surface mount pads that are only on the bottom of the board, D1 has through hole pads that can connect to tracks on both the front and back. Through hole pads are one way to make a connection between multiple layers. In this case, D1 is a component on the front side of the board, but its through hole pads are used to connect to a trace on the back of the board.

Another way to make a connection across layers is with a via. Start routing at the VCC pad of BT1 on the back of the board. Press V and click halfway between BT1 and R1 to insert a via, which also switches the active layer to F.Cu. Complete the track on the top side of the board by clicking on the VCC pad of R1.

All connections routed

At this point, all connections are routed. This can be confirmed by looking at the status screen in the bottom left of the window, where the number of unrouted nets is given as 0.

Placing Copper Zones

Copper zones are often used for ground and power connections because they provide a lower impedance connection than traces.

Add a GND zone on the bottom of the board by switching to the bottom copper layer and clicking the Add a filled zone button add zone 24 in the right toolbar. Click on the PCB to place the first corner of the zone.

In the Copper Zone Properties dialog that appears, select the GND net and make sure that the B.Cu layer is selected. Click OK, then click to place the other three corners of the zone. Double click when placing the last corner to complete the zone.

Zone outline

The zone outline is displayed on the canvas, but the zone is not yet filled — there is no copper in the zone area, and therefore the zone is not making any electrical connections. Fill the zone with EditFill All Zones (B). Copper has been added to the zone, but it doesn’t connect to the VCC or led pads and traces, and is clipped by the board edge. It overlaps with the GND trace drawn earlier, and it connects to the GND pads through thin traces. These are thermal reliefs, which make the pads easier to solder. Thermal reliefs and other zone settings can be modified in the zone properties dialog.

Filled copper zone

In KiCad, zones are not filled automatically when they are first drawn or modified, or when footprints within them are moved. Zones are refilled by manually filling them and when running DRC. Make sure zone fills are up-to-date before generating fabrication outputs.

Sometimes filled zones can make it hard to see other objects in a crowded board design. Zones can be hidden except for their boundaries using the Show only zone boundaries button show zone disable 24 on the left-hand toolbar. Zones retain their filled status when only their outlines are shown — hiding a zone fill is not the same as unfilling it.

Zones can also be made transparent using the Appearance panel, and inactive layers can also be hidden or dimmed using the Layer Display Options in the Appearance Panel.

Design Rule Checking

Design Rule Checking is the layout equivalent of Electrical Rule Checking for the schematic. DRC looks for design mistakes like mismatches between the schematic and layout, copper regions that have insufficient clearance or are shorted together, and traces that do not connect to anything. Custom rules can also be written in KiCad 6.0. To view the full list of design rules that are checked and to adjust their severity, go to Board SetupDesign RulesViolation Severity. Running DRC and fixing all errors is strongly advised before generating fabrication outputs.

Run a DRC check with InspectDesign Rules Checker, or use the button erc 24 in the top toolbar. Click Run DRC. When the checks are complete, no errors or warnings should be reported. Close the DRC window. DRC can also be run with the button on the top toolbar.

Now intentionally cause a DRC error by moving the resistor footprint to overlap the filled area of the zone. Use D (Drag) to move the resistor footprint slightly while keeping the traces attached to its pads. This creates a clearance violation because the VCC and led pads of the resistor are shorted to the GND zone fill. Ordinarily this would be fixed by refilling the zone, but don’t refill the zone yet.

Resistor footprint moved to violate clearance

Run DRC again, but make sure to uncheck the Refill all zones before performing DRC checkbox. DRC reports 4 violations: for each pad of R1, there is a clearance violation between the pad and the zone and another clearance violation between the pad’s through hole and the zone. Arrows point to each violation in the canvas. Clicking on each violation message zooms in on the respective violation.

DRC errors due to clearance violation between R1 and GND

Close the DRC dialog, press B to refill the zone, and re-run DRC. Alternatively, check the Refill all zones before performing DRC checkbox and re-run DRC. All violations are fixed.

3D Viewer

KiCad offers a 3D viewer that is useful for inspecting the PCB. Open the 3D viewer with View3D Viewer. Pan by dragging with the middle mouse button, and orbit by dragging with the left mouse button. Orbit around the PCB to see the LED and resistor on the top, and the battery holder on the bottom.

A raytracing mode is available, which is slower but offers more accurate rendering. Switch to the raytracing mode with PreferencesRaytracing.

Raytraced view of the PCB

Many of the footprints in KiCad’s library come with 3D models, including all of the footprints used in this guide. Some footprints do not come with 3D models, but users can add their own.

Fabrication Outputs

With the board design finished, the final step is to generate fabrication outputs so the board can be manufactured.

Open the Plot dialog with FilePlot…​. This dialog can plot the design in several formats, but Gerber is usually the right format for ordering from a PCB fabricator.

Specify an output directory so that the plotted files will be collected in a folder. Otherwise, the default settings are fine, but make all the necessary layers are checked: include the copper layers (*.Cu), board outline (Edge.Cuts), soldermask (*.Mask), and silkscreen (*.Silkscreen). The paste layers (*.Paste) are useful for manufacturing solder paste stencils. The Adhesive layers (*.Adhesive) are needed only if any components will be glued to the board during assembly. Other layers may be useful to plot, but are not typically necessary for PCB fabrication.

Plot dialog

Click Plot to generate the Gerber files. Also click Generate Drill Files…​ and then Generate Drill File to create files specifying the location of all holes that will be drilled in the board. Finally, close the Plot dialog. The design is finished.

Generate Drill Files dialog