Printed Circuit Board design

Originally 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. The pdf English documentation including a tutorial (the handbooks) are in:

/usr/share/doc/kicad/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 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).

Making your design stable for future Kicad versions

This section is not important when you start working with kicad, but it is extremely important when you are done and plan to archive your work for later use. This is why this section comes right at the beginning.

When a design is finished and a board ordered, you should basically backup what you have used from the libraries and this is quite easy. If you don't do it you might end up in big troubles in the future. All you have to do is to create a symbol library and a footprint library.

  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. To create the footprint library go in PCBnew and do File > Archive Footprints > Create Footprint Archive.

If you reopen the project, you should delete all libraries from the preferences and add those two libraries.

Additionally creating svg, pdf documents is recommended. Having Gerber files also saves the artwork, and allows you to order boards from everywhere, but for editing, Gerber is not the way to go.

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. Hover a weak point is that the wires can not be edited and become ugly stretched, so often they have to be deleted and redone when dragging components. When you move 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.

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 between schematic components and physical footprint

Kicad has no static links between schematic components and the physical footprint. You can assign a 256pin BGA package to a capacitor schematic component if you want. More problematic is when you assign a 14 pin DIL case to a 16 pin DIL, the two missing pins do not create warnings, except when you enable in the Netlist Dialog > Display Warnings.

An other issue is that pin names instead of numbers are used. A transistor might call its pins E,B,C whereas the footprint 1,2,3. Kicad will report an error in this case. The way to resolve this is editing the component libraries.

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). The following document shows the footprints available in the standard libraries (However the correct footprint names can not be seen): /usr/share/doc/kicad-20090320.1666/footprints_doc/footprints.pdf

    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

In the project window click on Cvpcb to link schematic components (*.lib files) to physical packages (foot prints *.mod files). Kicad uses the term modules for physical packages (or foot prints) indicating that it can be more than just a package. 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 you select click as well on View selected footprint. When done all is added to the Netlist and a *.cmp file is created listing all components.

Note

Not linking schematic components to physical footprint makes the libraries smaller an flexible, however there is also a draw back, the pin number in the schematics must match the same number as in the modules, this is not guaranteed automatically, so watch out!

Example: The + pin of a polarized capacitor is in the schematic pin 1 and in the footprint? If not, the capacitor on the PCB can explode!

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.

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 Libraries

If the components, footprints and 3D libraries are found and everything desired is there, then there is not much user interaction with the libraries. If not it gets a bit complicated. To keep the previous chapters simple, the library stuff has been put here:

The libraries are in /usr/share/kicad. Under Linux regular users do not have the permission to mess around in this directory. If you like to make a custom library structure (modules and library as kicad has) make it where you do frequently backups.

Do not worry about where the libraries are, since Kicad creates cache files containing a copy of the library components used in the design.

There is an site to collect component libraries: http://www.kicadlib.org/. Once a library is downloaded, put it some where and than import it using the schema editor and preferences > library.

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. And the DocFileName should point to a e.g pdf file inside /usr/local/kicad/share/library/doc, /usr/share/kicad/library/doc or /usr/local/share/kicad/library/doc directories.

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 sch files are textfiles 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.

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. They are in /usr/share/kicad/library

Footprint library

They are in /usr/share/kicad/modules

Footprints are called modules and represent the physical outline on the board and have the *.mod extension to mark that they can also be modules containing more than one physical component.

A common praxis for creating, maintaining and documenting a foot print library is creating a dummy board (only brd file) containing all foot prints. This board can then be converted to a library using the File > Archive Footprints > Create Footprint Archive.

An other way is using 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, then loaded into the dummy board explained in the previous paragraph.

To create a new footprint load an existing one from the library or from the current board is better than creating one from zero. Since pad and grid settings contain are already useful values. Select your custom library as the working directory so it can be saved there. A good start for a new component is counting the pins and then select a SIL connector. The click on a pad and make export pad settings.

If you have a custom library, go to Preferences > Library and add your library (*.mod file) and let the project know about it by saving it to the *.pro file.

If you load the module from the board, then the pads might 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 foot prints can be documented using a Doc string and Keywords.

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, you might run into import export problems with your favorite 3D editor. Before you create a module look at http://www.kicadlib.org/.

Note

It is better to take a module from there and just do the modules that you do not find, but make them nicely and add share them with other users.

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 emerge 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 3D and exported to *.wrl.

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.

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. Those “historical” formats have the danger that you do not get what you see (What You See Is Almost What You Get) WYSIAWYG format, since you have to specify the tooling lists (drills and apertures), better to have WYSIWYG (What You See Is What You Get). 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 Servernest startpage