This page created November 2016, on a Windows 7 PC, running KiCad version 4-0-4.
The page starts with a bit of discussion about how KiCad (and many other EDAs (WP)) "hold" "the stuff" you use when using KiCad to design printed circuit boards. Getting to grips with this is critical to your progress with using the tools.
It then lurches forward into "run", without bothering much with "walk". We will design a "component" for a chip (as used in the narrow, KiCad, sense... a "thing" for putting on circuit schematic drawings) with TWO units in it.
I am fairly new to KiCad, and very new to creating things to go in user-created .lib and .mod files, but, if nothing else, perhaps "watching" my fumbling attempts will give you ideas about how to get the system to do what you want?
Be careful with terms and concepts. Apologies if I misuse any terms here. The single greatest stumbling block I've had in my early KiCad days had, at its heart, subtleties which are critical to what I am trying to convey in this tutorial.
This is at least the second time I've tried to address this topic. For another attempt, see Making and Using Multi-Gate Components
(Bear with me for a few moments of "scene setting", please?)
You want a PCB. The place to start is with a schematic. You will place various symbols on the schematic. These are, I think, called "components" in KiCad-speak. I think in KiCad, "component" is used very narrowly. It DOESN'T include the physical object which you could hold in your hand. A resistor, for instance. It only includes the symbol for showing one on a schematic. And, internally, some of the properties of the component. A resistor connects to the rest of the circuit at two points, would be one of those "properties" of which I was speaking. These components are defined in .lib files. When you are designing the schematic, you will have certain .lib files available to you as your default set, or "library"... and you can add further .lib files to the set. Files from third parties, or .lib files created by you. There are TWO sorts of "library". We've just met the first... the components library. (You might say that ".lib" was a poor choice of extension name, but we are now stuck with it. "Poor" because there are two LIBraries, on consisting of .lib files, which might lead you to think that the .lib files are THE library files. They aren't. They're only the files in the components library. there's another library, which we are just about to come to.)
Once the schematic is done, we move on (through some "glue" steps) to designing the PCB.
For the PCB, we need graphics inside the computer showing what the "thing" that will go on the PCB, a resistor, needs in the way of holes. We also usually have artwork on the PCB, an outline to show where the resistor or other device goes. And probably some text, too. The device's name, e.g. R1, and/ or it's value, e.g. 10k (kilo-ohms). All of this "stuff" comprises a "footprint". KiCad comes with some generally useful footprints, e.g. ones for resistors of different (physical) sizes, diodes, transistors, etc. And we can add footprints designed by us. The "stuff" for footprints goes in .mod files. Just as with the .lib files, when you are designing the PCB layout, you will have certain .mod files available to you as your default set, or "library"... and you can add further .mod files to the set. Files from third parties, or .mod files created by you. We've already met the components library. The library of .mod files for the current project is its footprint library.
"Libraries"/ "files": For a moment, think "library" in the usual sense: A room (or rooms) were books are held. For KiCad, the "books" are the .lib and .mod files, where component and footprint definitions, respectively, are held. (A file can hold more than one definition.) And, for KiCad, the "library" is a list held in one of the files which define the current project.
An aside: There is not a 1:1 correspondence between .lib files. and .mod files. In a moment, we are going to design a new component. That is to say we are going to put something in a .lib file. We aren't going to need a new footprint for it, though, as the actual device comes in a normal 8 pin dual in line "chip". The footprint for that is already available to us from one of the "standard" .mod files, which is included in the "standard" footprints library provided to projects when you invoke "new project".
Well... I hope that helped, even if not 100% clear. Let's move on.
If you found the pace of the first part ponderous, I hope you will enjoy the new pace which will start any moment now, after I've set a new scene. But first...
Many simple electronic devices have just "one" in each "package". Think of a light bulb. Think of an (ordinary) resistor.
But sometimes, a "package" has inside it multiple copies of something useful. Think 4001 quad 2-input NOR gate.. you get FOUR of them in ONE package. Think, outside of electronics, of a chest of drawers. One package (the chest), multiple instances of a useful "thing"... the drawers.
There's a thing called an "opto-isolator". (Very useful, but that's another story!)
One the left: A diagram of what's in a KB224 dual gate opto-isolator. We're going to create a KiCad component so that we can use KB224's in our design work. A KB224 is a small blob of plastic with 8 legs. Inside it there are TWO independent opto-isolators. (The presence of two LEDs for each means that these opto-isolators not only do the "isolating" implied by the name, but they also take AC signals in, and send a DC signal out.)
Somewhere, someday, I need to address the "simple" case of creating a new component. Today, I am addressing the creation of a "complex" component.
It wouldn't be complex, except for the fact that KiCad (and most other PCB-CAD packages) do something clever: On the schematic, the two modules inside the KB224 can appear in quite separate places.
So how is the component done?
Start eeSchema. Tools/ "Library editor" allows you access to the tool for creating new components, to be placed in a component file (extension .lib), the component being available to you when you've made the .lib file it is in part of the set of .lib files specified via the eeSchema/ Preferences/ Component Libraries dialog.
Surely that should be called the COMPONENT editor? Ah well. The title for the tool's window (KiCad vers 4-0-4): "Part Library Editor" doesn't seem right to me. The editor is for editing the PARTS (or creating new ones). Yes, you put the parts in .lib files. But would you call a wordprocessor a "folder editor", just because the product of the wordprocessor goes in a folder??
Anyway. Once the Part Library Editor is up and running, here's what's next...
(The above is the top of the Part Library Editor window, split into two parts, to make it fit the page better).
If revising an existing part, you start by connecting to the .lib file it is on. If, as we are going to, you are creating a new part, and starting a new .lib file a the same time, you can start with the part, and create the .lib file for it later. (Note that you are unlikely to want to create a separate .lib for each part, but separate .libs can be useful for keeping things organized.
There doesn't seem to be a menu item, for creating a new part. You use the icon indicated, which has "Create a new component" for it's tool-tip.
That throws up a dialog... Component name (whatever you like. Make short. I'm using OptIsoKB224. Default reference designator: "U"... fairly common for "chips"... In a given circuit, you'll may have several. They would be referred to as U1, U2, U3, etc. Number of units per package: Two, for the KB224. The others can be left in default states.
Start by placing FOUR (not 8) pins on the screen.
(When you've done the first one, use the "book" tool to "Save Current Component To New Library". I'd suggest using a "LibMod" folder within a folder for your KiCad projects. After the first save, saving subsequent work is easier. First, you make your newly created .lib file available to the current project. You do this from the eeSchema page, via the menu item Preferences, and from there Component Libraries. "Add", drill down to the new .lib, "Open" AND click "Okay" to leave the Component Libraries dialog. It isn't "Added" until you "OK" out of the dialog. Once all that's done, go (Part Library menu) to File. Set the Current Library to the one you just created and added. NOW you can use ctrl-S whenever you want to save changes! It really IS easy to use... once you get the hang of it!)
Fill in their properties as you go along, as follows...
Name / Number / Orientation / Electrical type LED1 1 right passive LED2 2 right passive C 8 left open collector E 7 left open emitter
(I also moved the field reference and field value to achieve...)
(Moving things is easy... put pointer over the item you want to move, press "M". Move mouse, item will move. Click to put it down.)
The pin names "only" matter to making the component easy to use. LED1, LED2.. the pins which connect to the LEDs inside the opto-isolator. C "Collector", E "Emitter" of photo-transmitter.
Pin numbers: These will be used to match up the "diagrammatic" schematic diagram to the actual physical device to be placed on the PCB... through the "magic" of "CvPCB", with which we "connect" the components in a schematic to the footprints on the PCB. (The device we are creating a component for will go in an 8 pin DIP, remember. For the LEDs in the KB224 which are connected to pins 1 and 2 illuminate the phototransistor connected to pins 7 and 8.
Orientation: This just sets the "direction" of the pin symbol on the component.
Electrical type: The "type" of signal here. To be honest, I don't fully understand the whys and wherefors of this field, yet. I do my best to specify the types correctly. I usually look at a similar KiCad-supplied component, and copy what I see there!
Now we are going to add some lines to the component. They will be a bit approximate. You can make them as fancy, as meticulous as you like. They are to show the engineer what's where, as he works with the component you are creating. I have moved other things about, on the path to the following.
Aside: To drag several elements, together: Drag out a box around them, and then move mouse. Click to "put them down". Only things fully inside the box you dragged out will be included in the group for dragging.
Yes! Something is "wrong"... that is slightly incomplete. (No arrow on the photo-transistor. All will be explained.)
That takes care of what's in the KB224, connected to it's pins 1, 2, 7 and 8. What about the other "unit", the second opto-isolator in the blob of plastic? The one on pins 3,4, 5 and 6?
While doing the schematic, we don't care what pins connect to what things. We don't care that the two opto-isolators in our design are in one package. But when we make the PCB all of that will matter!
There's a trick.
This is the toolbar we saw earlier. See the "Unit A" at the right hand end? If you have re-sized the window, and made it too narrow, you won't see the "Unit A". But we NEED that. Use it to change what we are working on to "Unit B". You should see...
The lines we drew, in connection with Unit A have been shown for unit B, too. (We don't have to re-draw them.) There are "proto-pins" in place... but they need to have various properties set. Go to each in turn, press "E" while the cursor is over the pin. Fill in the pin numbers. The other values will be as before, and they are already filled in for you...
Name / Number / Orientation / Electrical type LED1 3 right passive LED2 4 right passive C 5 left open collector E 6 left open emitter
Besides doing that, I have added two small lines, at the bottom right, making an "arrowhead" in the photo-transistor. I have edited each of them to REMOVE the default-provided "tick" against "Common to all units in the component". Don't worry about why I did that, for the moment.
That's it! We've made a component. Now we will use it in a design.
I did a fresh start of KiCad at this point, started new project, and invoked eeSchema.
With "Preferences/ Component Libraries", I told eeSchema that this project would be using the .lib we just created, the one with the component for the KB224 inside it.
I used "Place Component", twice, to get as far as...
I then right-clicked on the right hand instance of the opto-isolator. Once I had the Component Properties dialog open, I changed the "Unit" from "A" to "B", and NOW what I had in the eeSchema window was...
The top line is now "U?A U?B", whereas it used to be "U?A U?A". (The "?" can be changed by editing the component. "1" would be a sensible number, as there's only one chip in the circuit.)
Notice also that the right hand component HAS the little "arrow" on the photo-transistor, whereas the one on the left does not. In this case, it would have made sense to do the two little lines making the arrow the same way as we made the all other lines. However... sometimes there are multiple units, not all exact clones of one another, inside a chip, and now you've seen how to handle those circumstances.
Just to make the circuit a little more life-like, I added a few bits and pieces....
Pretty boring, really. If all we wanted was the schematic, we might as well have just done one unit, and photocopied that.
But that's not all we want. Save the netlist (button in top boarder. Allow the "annotation" it will ask to do. Run CvPcb. Most choices are obvious enough... but I had trouble finding the DIL (or DIP) socket, the first time I used 4-0-4. It was under "Power_Integrations:PDIP-8".
And, at last... a PCB design!
There you have it...
We've created a new component, one with two "units" in it, and created a PCB using one of them.
I hope bits and pieces along the way were useful?
This is at least the second time I've tried to address this topic. For another attempt, see Making and Using Multi-Gate Components
Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org.
- - - - - Page Ends - - - - -