Printed Circuit Board design

It was common to use imperial measurement units for printed circuit boards. Nowadays in the age of sub-miniature surface mount components, metric units are commonly used. This results that the PCB (Printed Circuit Board) makes use of both, usually the grid where the components are places is imperial, the outside dimension and SMD (Surface Mount Devices) are metrical. In PCB design the unit mil is quite common: 1mil = 1/1000 inch = 25.4 um

Kicad

http://kicad-pcb.org/ is a GPL application without licenses limitations.

Thanks to CERN’s key philosophies its popularity increased: https://cernandsocietyfoundation.cern/projects/kicad-development

The pdf English documentation including a tutorial (the handbooks) are in a directory as:/usr/share/doc/kicad-doc-5.1.0/help/en

https://en.wikibooks.org/wiki/Kicad/Kicad

http://www.kicadlib.org/for additional libraries

When a new project is created, the ASCII readable file with the extension *.pro is created containing the project information. In general all files Kicad is using are ASCII files and can be read and edited.

An example: Copy an rename a directory containing a Kicad project. The rename the files to the new project and and find/replace in the important Kicad files the old project name with the new one.

The file:

/usr/share/doc/kicad-20090320.1666/file_formats/file_formats.pdf

contains the data format of the Kicad files, however the *.pro file is not described there since it contains obvious data plus the libraries used in the design (When saved to the *.pro file).

Instead of coping and editing an existing project, a project can be converted into a template. So new project can make use of such templates. KiCad comes with many templates in /usr/share/kicad/template/ to allow a quick creation of shields as for Arduinos and Raspberries.

Under Gentoo, Kicad got split in different packages, to get a full feature install emerge kicad-meta

KiCad Libraries

Even-though Kicad is quite intuitive and allows to start right away to draw schematics and then layout the PCB, at some point there will be an issue with the component libraries. Components might simply not be found in the libraries, Kicad might not find its libraries. Opening an old Kicad project with a new Kicad version might have library issues.

If no troubles appear then this section can be skipped. If troubles appear then this section might give the answer.

Kicad creates cache files containing a copy of the library components used in the design.

Kicad has a big evolution with its libraries. This caused some library incompatibilities..

The libraries are in /usr/share/kicad. Under Linux regular users do not have the permission to mess around in this directory. Create a custom libraries where frequently backups are made.

Recently the libraries can also be found on GitHub but since they move around on GitHub the default Kicad installation might have dangling links and not finding its libraries. As common with git the libraries from GitHub can be cloned as regular files and directories to the local computer and used from there as any other local library.

https://www.digikey.com/ created a GitHub kicad library https://github.com/digikey/digikey-kicad-library containing components from their stock.

Kicad can import eagle component libraries.

Schematic component library

Schematic component libraries end with the extension *.lib and have an associated documentation file *.dcm. They are in /usr/share/kicad/library

To deal with a schematic component library, eeschema has to be opened.

Making libraries available goes in two steps:

  • Add the path to the libraries to the search path.

  • Add the library to the project.

To copy schematic components from one library to an other requires some steps:

  1. Open the library and the desired component in libedit

  2. Export it to a *.lib file

  3. Open the destination library in libedit

  4. Import the component

  5. Save it to ram and then save it to disk.

Schematic libraries containing components that look as blocks can be created using a graphical front-end: http://kicad.rohrbacher.net/quicklib.php

After that the rather ugly components can be modified:

  1. Place the component on the schematics

  2. Open the libedit the library editor

  3. Select the library and then the component

  4. Modify the component as you desire

  5. Save it to the library and schematics

Schematics library components should have documentation. Doc is a sting explaining is simple words what the components is about. Keywords should contain some words to group and search such components. The DocFileName can point to a *. pdf file.

The schematic library components can have also a footprint filter, that helps to find a matching footprint and avoids that wrong footprints can be chosen.

The *.lib files are text files. The components are listed and their definition starts with 3 lines of comments that follows a block opened with a DEF line and closing with a ENDDEF:

#
# 07-HEX-V
#
DEF 07-HEX-V S 0 40 Y Y 1 L 
<here comes the stuff that you better edit in the graphical editor>
ENDDEF

The DEF line contains also the name of the component 07-HEX-V, unused, text_offset, draw_pinnumber, draw_pinname, unit_count, units_locked and option_flag.

The schematics *.sch files are text files as well they obviously contain references to to the schematic components used. Those references look as follows:

$Comp
L CONN_12X2 P14
<stuff where and how to put it on the page> 
$EndComp

In the example above L lists the component followed by its name. P14 is the assembly reference since in this case multiple P (=connectors) can be on the board.

Footprint library

For the footprint libraries there are the old *.mod files and the new *.pretty directories that contain for every footprint a *.kicad_mod file.

Using the Foot Print Editor open the *.mod file and save as *.pretty the old format can be converted into the new format.

They are in /usr/share/kicad/modules

Footprints are called modules and represent the physical outline on the board.

The footprint editor ModEdit can just be started within PCBNew by clicking the "Open module editor" icon. Components can be loaded and stored in libraries or saved a s single component library.

Creating new footprints can best be done by loading an existing one from a library. This way pad and grid settings contain are already useful values. A good start to create a new component is counting the pins and then select a SIL connector. The click on a pad and make export pad settings. Select the custom library as the working directory to saved there.

If a new footprint is created from a current board then the pads have a Pad Net Name, this is necessary if the module gets saved back to the board, but when saved to a library wipe out the data from those fields. Also the text contains an instance number (as P16). This number has to be modified to P***.

The footprints can be documented using a Doc string and Keywords.

mod files

The *.mod files are text files. The file contains a block that starts with $INDEX and ends with $EndINDEX that contains a list of all footprints. The footprint definition than follows afterwards, where every footprint has a block that starts with $MODULE <footprint name> and ends with a $EndModule <footprint name>

$INDEX
HEX-V-Switch
LCD_20x4
<other footprints>
$EndINDEX
$MODULE LCD_20x4
<the footprint definition better to edit in the gui>
$EndMODULE  LCD_20x4

The *.brd files are text files as well and have obviously references to the footprints used. Those references look as follows:

$MODULE pin_array_12x2
<everything seen on the board>
$EndMODULE  pin_array_12x2
Libraries for 3D

The 3D view makes use of wings (see http://www.wings3d.com/) and its KiCad libraries in /usr/share/kicad/modules/packages3d. Theoretically any modeling SW that can produce *.wrl files can be used. Since 3D modeling SW are very complex, import export problems might occur with 3D editors other than wings.

Note

Blender can directly import *.wrl files but can not directly export them. Exporting *.3ds, *.obj and *.stl and then importing to wings works partly. Some formats loose parts other color.

Note

A 3D model can be used for different KiCad component, since it can be zoomed (Example: A Capacitor 3D model, can be zoomed to be a 2.5mm, 5.00mm, 7.5mm, … grid KiCad component).

To create a 3D model install wings and browse in /usr/share/kicad/modules/packages3d to find something that looks similar. Than save it under a different name with the *.wings extension and export it as VRML model with the *.wrl extension.

The grid of wings matches with a KiCad grid of 2.54mm, however within KiCad the components have to be rotated 90° x and 180° y. When creating components it is wise to enter always the coordinates using the Tab key so everything matches the grid. Select also under view > orthograpic view do control better that everything is on the grid.

Select the component using ModEdit and go to Module Properties. In the the 3D settings tab select the 3D file, scale, rotation and offset. Finally check with the ModEdit 3D preview if the component is rotated, scaled correctly and that the pins match the layout.

It is best to observe in CVpcb if the footprint has a 3D view. To add a 3D model to a component that is already used in PCBnew, the component needs to be deleted and the netlist reloaded. However this is not necessary if a 3D model gets modified.

Now the *.wing file has to be edited using wings and exported to *.wrl.

Symbol files

Symbol files (*.sym) contain no pin assignments and other component parameters and are used to efficiently create components. Symbols can be imported and exported to components.

Making your design stable for future KiCad versions

This section is not important when starting to work with KiCad, but it gets very important when the work is done to archive it for later use.

Newer KiCad versions can archive all project files to a *.zip and unpack a project from a *.zip file.

Additionally and for older KiCad Version when a design is finished and a board ordered, a backup of what has been used from the libraries should be done. This is quite easy and can prevent big troubles in the future. All to do is to create a symbol library and a footprint library from what got used.

  1. To create the symbol library, copy, paste and rename (delete the word cache in its filename) the <project name>.cache.lib and its documentation file <project name>.cache.dcm

    Note

    This shows the importance and purpose of those files. Those files also contains modification to the symbols that have not been copied back to the libraries.

  2. Create the footprint library by going in PCBnew and do File > Archive Footprints > Create Footprint Archive.

When in the future the project is reopened all libraries from the preferences can be deleted and replaced by those two libraries.

Additionally creating *.svg, *.pdf documents is recommended. Having Gerber files also saves the artwork, and allows ordering boards from everywhere.

Important

*.svg is a vector format and therefore optimal to publish a schematic page. However kicad *.svg export has (or had) a bug the ; character in polyline fill="none;” causes an error when fop tries to export it to pdf.

Therefore search for fill="none;” and replace in fill=”none”

Drawing the schematics

From the KiCad main window EESchema (Schematic editor) opens the schematic editor and when saved, the *.sch file is created (plus some less important cache files). As with many drawing programs working with a grid is necessary, but often creates frustrating results when the components can not be placed onto the grid. Use as grid of the schematics 50mil, then check by clicking on the components that they use also a 50mil grid.

To verify that the wires connect, click on the components and drag them pressing the G key, so the wire will become a rubber band, when connected. However a weak point is that the wires can not be edited and can become ugly stretched. Select the wires and break them and delete not desired part or if it is really bad delete the complete wire. When moving instead (M key), the wires to the component will detach. With the R key you can rotate the component. The Insert key is also quite useful, it works as a repeat last command key.

Figure 2.1. KiCad schematics

kicad schematics


Cleaning up the schematics

Before proceeding further, some steps are required or strongly recommended:

First click on Schematic Annotation, so every component gets an unique name.

Multi-part components are components as the 7400 containing 4 identical gates (=units) that can be placed everywhere on the schematic page. During annotation those units are packeted into a single physical component. Also other components as relays make use of it this method, allowing to place the relays coil on a different location than the relays contacts. Selecting the component and do edit component > unit lets you switch between relays coil and contacts. IC's might have an extra unit that contains the power supply pins.

The Schematic Electric Rule Check will mark all connection points that are not connected. When placing components they need to be annotated otherwise they are like ghosts and it might be not possible to connect them with wires. The errors and warnings caused by the schematic electric rule check produce small arrows that can be clicked to see their reasons. The errors and warnings do not to be removed to proceed.

Some errors that usually pop up are:

  1. The “non connect flag” (blue cross) can be placed on not used output pins to prevent an error.

  2. ERC << Warning Pin power_in not driven (Net 15), is a power net that has no power source. Place the component PWR_FLAG to this net to remove this ERC error.

Mounting holes appear also in the schematics, since they can be done using the 1pin footprint and then edit its parameters.

Create the net list

To create the net list using the schematic editor Netlist Generation, the *.net file is created.

Note

You have to run Netlist Generation again when you did some modification in the schematic, since the PCB creation programs use the netlist and not the *.sch file.

Link the schematic components to physical footprints

There is a new way and an old way to go.

  1. The new way is right click on the component in the schematic and then via properties select the Footprint

  2. The old way is run Cvpcb and get a list to link the schematic symbols to the foot prints. Having a list gives a good overview.

In the project window click on Cvpcb to link schematic components (*.lib files) to physical packages (foot prints *.mod or *.kicad_mod files). Click on Display the filtered footprint list for the current component, to make the list of available footprints smaller. For the components that have no footprint assigned (or where you like to change the default footprint, click on the desired footprint. To know what got selected click as well on View selected footprint. When done all is added to the Netlist and a *.cmp file is created listing all components.

There are many options to help making useful links:

  1. There is an option to select the footprint on schematic level. Go the edit component > footprint and add the footprint name (as DIP-16__300_ELL for IC package).

    Do not forget to run Netlist Generation after that.

  2. Additionally a schematic component has a footprint filter that can be assigned. Check this with libedit.

  3. Equivalence files (*.equ files) can be created to allow automatically selection of schematic components to footprints. Equivalence files simply contain a list, linking component names to footprint values. They are in /usr/share/kicad/modules

Create the PCB

Start PCBnew from the project window. Then browse netlist and load netlist. A *.brd file is created. Use the command move new modules to get them apart.

Figure 2.2. KiCad PCB

kicad board


The PCB has different layers, not all layers are copper layers. Everything is a layer as the silk screen and soldering mask and what comes next the “Edges PCB” layer that defines the boards dimension to be drawn using graphic lines or a polygon. Since the board dimensions must be precise press the space bar to get the origin 0 for the relative coordinates shown on the status bar. The comment, drawings, ECO1 and ECO2 are layers for documentations as to show mechanical dimensions (e.g. drawing layer).

Note

Copper layer is the soldering side (Page Up) does not mean it is the page that points upward, it means the hot key, if you press onto the Page Up key then the copper layer is selected.

Important

Make sure Courtyard layers are visible F.CrtYd and BCrtYd so components are not placed to near.

When placing the modules on the PCB, un-hide modules rats nest to see rubber bands attached to the module and get a feeling where it connects.

Note

Check that the "Add tracks and vias" tool is not enabled otherwise you can not draw the boards outline.

People write books about how to use the mouse. Mostly it is intuitive, but certain things not, therefore here, the how to use the mouse:

Click and release, then move the line, click and release to extend the line.

Press space to set the origin from where the relative distances to the cursor are measured.

To change track width, just modify the default value, the list of track widths will expand.

For mounting holes add the "1pin" footprint, then edit the pad in order to have the correct size (pad diameter and drill value). To have it consistent with the schematic the CONN_1 could be added to the schematics. This gives a plated hole.

Selecting with the mouse a module and use the keystrokes M for move and R for rotate prevent the numerous mouse clicks using the menu. The + and – key select different copper layers. You need to get familiar with different track edit operations, read the manual for that (deleting segments, Backspace key to undo last click, brake track and move via, brake track and move node … ).

Viewing 3D

When you are done you deserve a 3D view of the result.

If you create a board with more than 2 layers, it might happen that some modules are just for 2 layer, if creating zones, then those holes are not present and causing DRC errors, also it is not possible to wire up inner layer to them. In such cases edit the module. Go to edit pads global, check if the dimensions are ok (pad size 0.056” drill 0.036”), then click on change module and save it to the board.

Figure 2.3. KiCad 3D

kicad drill


Order the board

If your preferred PCB manufacturer supports kicad then you can send directly the kicad files. If not then Gerber data has to be produced.

Nowadays the manufacturing process usually will not use films anymore that have to be manually placed onto the board to be exposed to light, so there is no need to add fiducial marks, alignment marks and dimensions to the design. For some manufacturers those stuff outside of the board might even disturb and cause additional work or maybe you get a larger board with a higher price, where you have to cut those things off. It is enough to submit the data in an electronically form. However make sure to not to exclude the PCB-Edges layer when creating the board, since this layer defines the outline.

Figure 2.4. kiCad drill

ncdrill


To create Gerber data, just plot the board to Gerber format. For each selected layer a separate file is produced (*.pho). Consider also to generate the drill file (*.drl) that contains all diameters of the holes. Otherwise you might end up drilling the holes your self!

With Gerber data it is simply a must to use a Gerber viewer. KiCad includes a Gerber viewer to verify it. However it is still not guaranteed that you get what you expected, since Gerber files depend on a tool set (aperture and drill tables). Last but not least every layer is usually a file and you could end up having the bottom layer as top layer, so for surface mount components the PCB would be useless. So a Gerber viewer that can pack everything together in a single file that is understand by the PCB manufacturer verified by yourself is the way to go.

To be safe, check with your PCB manufacturer, if it supports a viewer project file that puts everything together. As example:

A PCB producer services that will not be scared when ordering little quantities is:

http://www.pcb-pool.com/. The Gerber data can be submitted using GC-prevue down-loadable for free of charge on their site (so is KiCad).

The original place of GC-prevue is: http://www.graphicode.com/

Figure 2.5. GCprevue

gcprevue


The *.gwk file can be uploaded to get the PCB. Only drawback, GC-prevue is not a Linux application. However GC-prevue can be installed under Linux using wine. After installing it do a:

cd ~/.wine/drive_c/GCPREVUE followed by:

wine gcprevue.exe to have it running. Don't forget to copy your Gerber data and drill file somewhere under ~/.wine/drive_c or better make a link from ~/.wine/drive_c to where the kicad data is, so it is in reach of wine. To not confuse the manufacturer, rename and order the layers for a 2 layer board as follows:

  1. First layer drill.nc the drill data,

  2. Second layer top.ger the top or component side copper layer,

  3. Third layer bottom.ger the bottom or soldering side copper layer

  4. Forth layer tresist.ger solder resist top side

  5. Fifth layer bresist.ger solder resist bottom side

The layers can be imported and the GC-prevue is able to detect automatically what it is. Importing the drill gets probably errors. So do not load the drill automatically, load as drill and a window with options pops up. Check KiCads export options if they are different from its defaults and adjust them to the GC-prevue's Load Drill data window. Additionally you need to manually create the drill diameter table in GC-prevue. Therefore create and open the KiCad Drill report file.

Figure 2.6. Drill data

gcprevue drill


To have the layers end up in GC-prevue's window, you need also to set an offset (x-offset 1” y-offset 10”) you can do it either under edit or when loading the layers.

Then you can observe the result an when happy save all to get a a *.gwk file to be e-mailed to the PCB manufacturer. Restore all will read *gwk files at later stage.

Check limits of the PCB manufacturer and set the PCB Design Rule Checks accordingly. This should be the first thing when you do a PCB, but putting it right at the beginning would complicate the stuff unnecessary, since most PCB manufacturers can work with the KiCad default rules.

Printing

To have nice drawings that are even in 1to1 scale do a plot to postscript first. Then using something as kgostview or gsview to convert it to pdf.

Plot silkscreen on component layer to get an assembly drawing. If the drawings are big as A2 print them first in a A2 pdf and then print them again to shrink.

Or print to SVG and open it using inkscape and convert there to PDF or print from there.

KiCad hints

There is no renaming project command in KiCad but it can be done manually thanks to have the KiCad files as Ascii. Rename the pro, brd, sch, lib, cmp, mod files and then open pro, sch, in an Ascii editor and make search old name replace with new name.

KiCad on Gentoo

emerge -pv =sci-electronics/kicad-meta-5.1.12 and add the following to /etc/portage/package.accept_keywords

=sci-electronics/kicad-meta-5.1.12 ~amd64
=sci-electronics/kicad-5.1.12 ~amd64
=sci-electronics/kicad-symbols-5.1.12 ~amd64
=sci-electronics/kicad-footprints-5.1.12 ~amd64
=sci-electronics/kicad-packages3d-5.1.12 ~amd64
=sci-electronics/kicad-templates-5.1.12 ~amd64
=sci-electronics/kicad-i18n-5.1.12 ~amd64

Eagle

Eagle is a PCB (Printed Circuit Board) design program. It is commercial, but can also be run as Freeware. As Freeware it is limited to one schematic page and 2 layer board with maximum dimensions of 80mm*100mm an non commercial usage. For a hobbyist those limitations are mostly acceptable.

You must first run it as root to install the Freeware license. Add icon on desktop, you find the binary and an eagle icon in the /opt/eagle/bin directory. Select on the desktop icon that you want to run it as different user (root). Start it, then change back to regular user.

After finishing the work eagle lets you export the data in various standard formats as Gerber, where the tooling lists (drills and apertures) needs to be specified. This is a potential source of errors. Luckily, there is a more easy and hassle free way by sending the eagle data as it is to a PCB manufacturer that accepts it. PCB manufacturers specialized for small quantities are:

http://www.pcb-pool.com/

https://www.conrad.ch/


Linurs startpage