While trying to create a new part for KiCad schematic editor, I found many caveats that took time to sort out. This small guide is to create new libraries for the ones that don't know yet, or for my future self, when I forget how to do it.
Step by step:
- While in schematic editor, you can right click on a component, go to edit component>edit With library editor. You can also press the Ctrl+e key combination.
- Once in component editor, you can edit the library directly. That is not very advisable, as you will obviously loose the default component. Also your modified version could get overwritten if for some reason KiCad updates the libraries.
- Export the component into a new file. In my version of KiCad, it was the 10th button in the top menu, from the left. Now you can save this component in a folder that makes sense to you.
This is where the trap is. The most logic following step, is that you include your new library with the preferences > edit component libraries. If you do this, you will be able to find your newly created library, but when you place it; it will load the library from where this file was created. As well explained in the video that I am taking as source, is that KiCad uses not a filename as reference, but uses a name that is written in the component name. This is why when you load your library file, it searches in the library database, and finds first the original component.
The video I am citing recommends to change the order of the libraries list. I didn't like this idea because then you will no longer have the first component available. This are two last steps I did instead:
Rename the reference name inside the library: I couln't find the way of making it using the KiCad's libary editor; but the nice thing of KiCad is that you can text-edit most of the things. I am making a 24 pin version of a multiplexor that has a different pin mapping than the provided by the library. I opened the library with my text editor and changed it's reference name in three parts. First the original file, and then the modified version, with the changed text in red:
#start of the original version ESchema-LIBRARY Version 2.3 #encoding utf-8
DEF 4067 U 0 30 Y Y 1 F N F0 "U" 250 850 50 H V C CNN F1 "4067" 300 -900 50 H V C CNN F2 "" 0 0 60 H I C CNN F3 "" 0 0 60 H I C CNN DRAW S 300 800 -300 -800 0 1 0 N X Z 1 -600 -550 300 R 50 50 1 1 I X i7 2 600 50 300 L 50 50 1 1 O X i3 3 600 150 300 L 50 50 1 1 O #file continues (...)
#start of my custom, renamed version ESchema-LIBRARY Version 2.3 #encoding utf-8
DEF 4067-24 U 0 30 Y Y 1 F N F0 "U" 250 850 50 H V C CNN F1 "4067-24" 300 -900 50 H V C CNN F2 "" 0 0 60 H I C CNN F3 "" 0 0 60 H I C CNN DRAW S 300 800 -300 -800 0 1 0 N X Z 1 -600 -550 300 R 50 50 1 1 I X i7 2 600 50 300 L 50 50 1 1 O X i3 3 600 150 300 L 50 50 1 1 O #file continues (...)
Probably the first tweak is not important, as the # starting lines are often comment lines. But I just changed lines until KiCad made a distinction between my library and the standard one.
Reload the library. I removed the custom library reference, and loaded once again, because KiCad caches these part names, so you need to remove the entry on the library list, and make it again.
The nice thing now, is that I can make much faster editions by using text tools such as regular expression text replacement, or multi-line edit, instead of pointing each pin and changing pin names.