KiCAD Howto – Library and the text editor

I was asked by one of my blog followers about using KiCAD libraries and how to make a library and add parts to it.  So I’ve written this blog entry to help all KiCAD users.

One of the very cool things about KiCAD is all the libraries are just text files, so a good editor is all you’ll need.

On a Linux install of KiCAD the default libraries are tricky for a regular user to edit as they are all owned by root, so they are really read only (unless you want to do all that sudo stuff!).

What I have done on my system is create my own library and saved it on a shared directory on my server so any machine that I login from can see the same library.

Start your text editor and create a new library that has no parts in it, it’s just a “shell” like this:

EESchema-LIBRARY Version 2.3  Date: Wed 07 Nov 2012 01:16:37 PM GMT
#encoding utf-8
#
#End Library

Save this somewhere and call it something like “MyKiCADLib.lib”

Now when you start a new schematic go to “Preferences -> Library”

KiCAD: Select Library from the Preferences Menu

KiCAD: Select Library from the Preferences Menu

In the Library window:

KiCAD: Add a new library

KiCAD: Add a new library

Click on the “Add” button on the right top (near the “Component library files”) and find and select the MyKiCADLib.lib.  The press the “OK” button on the Library preferences window to finish.

Now when you add a component select the “Select by Browser” and you can search for it in your new library… It the moment this library has no parts in it, but it should show up in the left most panel.

KiCAD: New Library is empty...

KiCAD: New Library is empty…

So now it is time to add a part to the new library.  You have two options, you can go ahead and use KiCAD library editor.  This is nice, and I’ve used it a few times when I can’t find a part on the net.  But like most things on-line, someone has probably done the work already!

I’ve found that the part I’m interested in is somewhere in a existing library that may have a few hundred parts in it and I’m only looking for the one part.  So rather than adding yet another library to KiCAD I extract the part from the library and add it to my library.  As the libraries are all text this is easy to do.

For example the DS18B20 is defined like this:

#
# DS1820
#
DEF DS1820 IC 0 40 Y Y 1 F N
F0 "IC" -100 400 60 H V C CNN
F1 "DS1820" 0 300 60 H V C CNN
F2 "~" 0 0 60 H V C CNN
F3 "~" 0 0 60 H V C CNN
ALIAS DS18B20
DRAW
S 150 -100 -150 250 0 1 0 N
X GND 1 100 -400 300 U 50 50 1 1 W
X DQ 2 0 -400 300 U 50 50 1 1 W
X Vdd 3 -100 -400 300 U 50 50 1 1 W
ENDDRAW
ENDDEF

Parts always start with a DEF and end with an ENDDEF. Look out for these if you are taking a part from an existing library.

Paste the text into you new shell library:

EESchema-LIBRARY Version 2.3  Date: Wed 07 Nov 2012 01:16:37 PM GMT
#encoding utf-8
<insert component text here>
#
#End Library

Save your modified library and exit out of the schematic editor and restart it (required to pick up changes to libraries!).

Now when you add a component you should see your library has two parts in it: “DS1820″ and “DS18B20″.  Go ahead and add this to your schematic.

KiCAD: Part added to library

KiCAD: Part added to library

It as easy as that.. Hope you found this a help!