My Kicad Libraries

Kicad Libraries

I have created a set of Kicad schematic and footprint libraries. The library archive is available here.

These instructions are for Mac users.

After downloading, copy the archive to your user application support directory at /Users/YourAccountName/Library/Application Support/ and unarchive it (double-clicking in the Finder suffices). It will create a folder in the application support directory called kicad. This is the standard directory for Kicad libraries. Some users might wish to put the libraries into the global library directory, /Library/Application Support/kicad.

Inside that directory are the schematic symbol libraries (in library), the footprint libraries (in modules) and any 3D models I might have (in modules/package3d). The scripting directory has some plug-ins, notably the Python scripts which are used to generate footprints.

The plugins directory has some XSL scripts, most notably the bom2csv.xsl script which is used to generate bills of material from EESchema.

The template directory has a couple of default project templates.

The help directory has the PDF-format manuals for all of the Kicad programs.


Setting up EESchema to recognize schematic libraries

You need to tell EESchema where to find the schematic symbol libraries. From EESchema’s main menu, choose Preferences => Component Libraries. A dialog pops up:

kicad-schematic-library-list

Initially it might be populated by Kicad default libraries.  (You may have gotten dire warnings from EESchema when you first launched it.) Go through and select and delete each of those default libraries.

Next, make sure that the libraries you unarchived earlier are on one of the paths listed under “Current search path list.” If not, add the path to the search list by hitting the “Add” button next to “User defined search path” and mousing around to that directory (in my case, it’s /Users/andy/Library/Application Support/kicad/library).

Then, hit the “Add” button next to the list of Component library files and selecting each library.  Now all of the libraries should be available to use for schematic entry.

Please note: As you add components to the schematic, they will also be added to a file created automagically in your project directory called projectname-cache.lib. DO NOT delete this file! If you do, all of the symbols you added to the design will be lost. (Unlike pcbnew, the current eeschema file format does not embed the symbols in the sheet schematic file, and instead uses this cache. The Kicad developers indicate that they will revise the schematic file format to eliminate this weirdness and embed the symbol in the schematic file.)

Once the library list is set up, you should be able to browse the libraries from within EESchema and place the symbols onto your sheets.


Setting up the Footprint Libraries for use with pcbnew

You tell pcbnew where to find footprints by setting an environment variable and then using that environment variable in a list called a “Library Table.” This sounds complicated but it’s very simple.

First, we’ll set the environment variables. These are mainly useful for those who use Kicad on different machines which might have different library locations, for example working on a Mac and then on a Windows machine. From the Kicad project manager main menu, choose Preferences => Configure Paths. The following dialog pops up:

kicad-env-var-path-config

For our purposes, ignore the KIGITHUB line; that is useful if one wishes to access the community footprint libraries that are served by Github.

The KISYSMOD and KISYS3DMOD paths must be set to the directories where you find the footprints and the 3D models, respectively. You can see that here I’ve set them to the correct locations. If they are not correct, or do not exist, then double-click on an incorrect path and enter the correct one. Click OK to save.

Next, you need to create or modify a library table. This is the file that maps the footprint library locations to a pointer that is used in pcbnew to find the footprints. Again, this is all so that you can store the libraries anywhere in the file system on any computer, and as long as the entries in the file table are correct, pcbnew can find the footprints.

By default, the footprint library table is called fp-lib-table and it lives in the directory /Users/yourname/Library/Preferences/kicad. It is a text file and can be opened and changed by any editor. My current library table file, which references all of my PCB libraries, is here.

Modifying the library table is easy. From the pcbnew main menu, choose Preferences => Footprint Libraries Manager. (You may also prefer the Wizard.) This opens a dialog like this:

kicad-library-tables-manager

Here you the location and the contents of my library table. As of Kicad stable 4.0.0, the footprint library is actually a directory with the suffix “.pretty,” and inside that directory are the individual footprints within that library.

For each library, you give it a “nickname,” which is a short name for the library. I recommend making the nickname the same as the library directory sans the .pretty suffix. (Don’t confuse yourself.) If the nickname is the same on all of your different machines, pcbnew will never have a problem finding the library.

Next, note the library path includes the ${KISYSMOD}/ prefix. This text string invokes the environment variables for the library location, and it’s the hook which lets you put the library anywhere in the filesystem and pcbnew will be able to find it. The environment variables are shown at the bottom, and you can change them as you need.

For the most part, “Plugin Type” will be Kicad, which is the “.pretty” format. “Legacy” libraries are in an ancient format Kicad used to use and is now deprecated. Those libraries can be read but not modified. (If they are modified, they are automatically upgraded to the new format.) You can also directly use, but not modify, EAGLE- and gEDA-format footprint libraries. (Note that you cannot use EAGLE or gEDA symbol libraries in your schematics.)

Ignore the “options” for now. And if you prefer, you can enter a short description of the libraries, in case the name itself is insufficient.

Once the library table is set up, it can be used when importing a netlist generated by EESchema, as long as the symbols in the schematic have proper “footprint” entries (all of mine do). If you create your own symbols, it is not strictly necessary to embed a footprint link in them; you can use the CvPCB program within EESchema through the Tools => Assign Component Footprint” menu option. But I don’t recommend this design flow. Create symbols with reasonable names that somehow indicate footprint, and then marry the footprint to the symbol by making sure that the symbol’s “Footprint” field has a valid entry.


Generating a Bill of Materials

You will note that each of the symbols library has a custom part number field called PN, and that field is always filled. This field holds a key into a master parts list I created. The parts list is here, as a zipped Apple Numbers spreadsheet, and here as a zipped CSV export of that database.

A python script called bomgen.py is used to parse the BOM exported from EESchema and look up the parts against the CSV parts list. Put the script and PartsDatabase.csv into the same directory as the CSV BOM exported by EESchema. Run the script from the Terminal like such:

$ python bomgen.py DesignBOM.csv PartsDatabase.csv

You will see messages as the BOM is parsed, and will be greeted at the end with a success or failure message. The result is a CSV file called FinalBOM.csv.