This page continues the story of power ports, from the first page of the story.
This page may, before 10 November 2011, have had some errors in it due to a confusion between the roles of pin names and pin and pad numbers. Those errors are now, I hope, fixed. I have a page with more on this if you are really curious.
Sorry… another "detail".
You should also get into the habit of attaching a "power flag" component to power (and ground) rails. Why? We'll come to that.
The component you need is in the "power.lib" library of components, so, like, say, Vcc, you can add it with either "A" (invokes the "Place a component" mode) or "P" (invokes "Place a power port" mode).
You always(?.. as far as I know!) use the component "PWR_FLAG" to take care of this detail. In the circuit we are using as an example, connect one to the same line the "Vcc" power port is connected to. Connect one to one of the lines connected to a "GND" power port. (You should not connect a "PWR_FLAG" component to both of the lines with a "GND" power port on them. The "two" rails with "GND" power ports are "connected", are "one rail", electrically, through the magic of power ports. So put only one "PWR_FLAG" on "it".)
Seems odd, I know: You use multiple instances of the "PWR_FLAG" component on the diagram, the same type of component on different power rails. Seems odd, but it is okay! And don't try to change the name of the "PWR_FLAG" component on the drawing, either.
What is the power flag? When we attached the "Vcc" power port component to the relevant line of the drawing, we told KiCad things about that line. By adding the "PWR_FLAG" component, we've added to the information. The things we're telling KiCad with the power flag are more general, and apply to any power rail, including ground rails. Hence it is okay to put the same component on dis-similar lines.
Now… Why did we do this? I'd been using KiCad a bit quite happily without using the PWR_FLAG component. It turns out that when you start using eeSchema's electric rules check (ERC) tool (which you should be using!), it will be unhappy if you haven't put PWR_FLAGs on each power (and ground) rail.
You invoke the ERC tool with the following button….
The rules, and tests, for connecting the power flag are the same as they were for the other power port components. Within eeSchema, you can try to drag a power port. It it drags what you hope it is connected to it along with it, it is connected. Press escape… maybe escape and ctrl-z… to get things back to how they were before the "drag test". (To drag: Select the pointer tool, put cross hairs over power port, press "G", for draG. Move mouse.)
I added this bit about the PWR_FLAG component late in the day. That's why none appear on the illustrations. (Sorry!) The PWR_FLAG component looks like this…
Now for a small bit of good news for you; you've earned it!
To put a power port or power flag on your schematic, you could have simply entered "Vcc", "GND" and "PWR_FLAG" into the dialog for placing a new power port in the "name" edit box. That would save you from choosing them from the list. I didn't explain it that way because it didn't seem to convey as much information about what is going on. But by all means use the "direct" approach in your day to day work.
(And here's another little "by the way" item: Not only for power ports, but for components on general, the system is set up to accept "GND", "gnd", "Gnd", (or even "gNd"!) as all being equivalent. It will use whatever case the component designer specified… but it will recognize the name, regardless of what case you use!)
Right. That finishes putting the new components on the schematic. Because the components were power ports, we proceeded a little differently from usual, but not much, really. If you don't "get that", re-read the section, have a little think. You probably don't yet see why power ports are special, or "what they're good for"… that will, I hope, emerge as we go forward.
But what about the connections to the invisible pins? Don't worry… well come to that.
What you have now would design a nice little board for the 555. The Vcc and GND lines would all be ticky boo… but we haven't provided for a way to connect the two wires for Vcc and GND from where ever that is to be supplied.
Connector to off board battery or other PSU
Here's all that's needed. I put it in an "empty corner" of the "page" we already had.
What did I do?
- Placed a "CONN_2" component on the schematic
- Edited the component's "reference" field, made it "P1"
- Added a Vcc power port to the upper pin
- Added a GND power port to the lower pin
I could have drawn lines all over the place, connecting up the top pin to a Vcc part of the circuit, and the lower pin to a GND part of the circuit… but it would just clutter the diagram. Thanks to the "magic" of power ports, all will be well!
Hurrah! That's the schematic done! Now we move forward along the usual project development path….
Before leaving eeSchema: Save your work, and save the netlist.
Routine assignment of footprints to components.
Run CVpcb…. use the following footprints. (Others would "do" in many cases, but let's "stay on the same page".)
C1V5 for the capacitors
LED-5mm for LED
PINHEAD1-2 for CONN_2
R4 for resistors
DIP-8_300 for U1, the 555
Note that there is no footprint for the Vcc and GND components. This is another hint as to their "specialness"… and confirmation that we HAVE used something other than a "basic" component!
Save your footprints-to-components specification.
*Clear out any "old" board on the page… easiest: Start new board.
*Read the netlist… be sure to read the right netlist… I find that the first time I read the netlist, PCBnew sometimes defaults to a netlist from earlier work.
*Get the components roughly placed…
(As on other occasions: This is not meant to be a wonderful layout! It is meant to be a layout which helps you grasp the points we are working on.)
*The rat's nest does not always show all of the ways you could connect pins that need connecting. If you start drawing a track, then all of the pins it needs to reach will be highlighted. In the example above.
*If you zoom in, you see details… like the lower pad of P1 (upper left) needs to connect to the lower pad of C1 (lower left), but by the rat's nest lines, you'd take a tortuous route, rather than an easy one.
Notice an "exciting" thing: U1, the 555, does get a connection to Vcc on pin 8, and a connection to GND on Pin 1. These power port things do work. I'll explain that "magic" in a minute".
Here, just to get it out of the way, is a "finished" layout. Beautiful? Efficient? No. But it does make all the right connections! (The vertical red track, or wire, just to the right of R2, is on the "front" side of the board, the green tracks all being on the "back" side of the board. (The 555, LED, etc would go on "the front".)
*The overall task is completed more more easily if you get components placed, and suitably rotated before you start laying down tracks.
Clever! We can see from the rat's nest lines that the system "knows" that one of the pins on CONN_2 goes to Vcc. Clever that it knows that pin 8 of the DIL needs to go to that pin, and other parts of the circuit.
That's related to what I said earlier, "notice [that] U1, the 555, does get a connection to Vcc on pin 8, and a connection to GND on Pin 1."
How does the "magic" work? It is quite simple, actually. So simple that it is a bit fragile… but entirely satisfactory, as long as you remember how it works.
Before we go into that, a brief word about how KiCad "usually" matches up what went to a pin of a component to what needs to go to the pad of a footprint:
Usually, all that is down to the numbers of the pins and pads. Remember that a "number" can be something like "Vcc"… but you can usually avoid that, and thus avoid a possible confusion.
With power ports, the "match up" mechanism uses the name on hidden pins on components to add rat's nest lines to what you see in PCBnew. The mapping of visible pins to pad proceeds as normal… organized by the pin and pad numbers. It is just the linking of invisible pins to suitable pads which uses power ports.. and the name, not number, of the pin.
I have done a FAQ answer for the times you need help to find the name on an invisible pin.
In the schematic, you do not need to draw lines connecting all of the things which need to connect to GND (or Vcc… or any other power port serviced rail.) You simply connect an instance of the relevant power port to each "separate" ground, or Vcc, etc, rail line. (There are examples of this in what we did in the exercise above.)
Just in case you were worried… yes, the bottom part of the schematic could have been drawn like….
That would be equivalent to what we did by using the left hand "GND" power port symbol you see above, and a second "GND" power port symbol on the LED, instead of that long… and easily confusing… line across the whole bottom of the page.
This, however, raises an interesting issue. Suppose you have two independent circuits on the board? This is commonly done when you are using opto-isolators, for instance. In that case, you can have, a Vcc1 and Vcc2 and GND1 and GND2.
Whew! So it takes more than an opto-isolator to bring KiCad to its knees. One of the things I like about it is that the more I explore it, and discover possible problems… the more I discover that it "has an answer for everything". Well… everything I've asked so far, anyway.
Another example of "Vcc" and "Vdd"
Further up the page, I promised that at the end I'd show you an example of a circuit with a chip using the term "Vcc" and with a different chip using the term "Vdd". Whatever you call them, those are the places you connect the positive side of the voltage to make the circuit work! While the concepts are not complex, KiCad is fussy, and if the component was designed with the place the positive voltage is attached called "Vcc", if it is on an invisible pin, you have to use a "Vcc" power port.
The following circuit does almost nothing! Don't be puzzled by that. It is only here to illustrate certain KiCad issues. Whether the circuit would work isn't the point. There may even be flaws such as maybe a pull down resistor would be more suitable on the input. Just ignore that kind of issue, if you can. (And write and complain, if you can't!)
The resolution in "real life" is better, and you can pan and zoom… but I hope it is adequate to show you and example of a circuit with a "Vcc" device (the 7400) and a "Vdd" device (the 4011). See also the next two images… they show the first one, split in two to better fit the page.
And here it is in two halves….
At the upper left, you will see both Vcc and Vdd power ports attached to the power rail.
Sorry.. here we come to a few little "rough edges" which I will try to "sand down" in later editions of this page.
Missing: The "PWR_FLAG" power component which the Vcc/Vdd power rail and "GND" line should also have. (I learned about them after doing these illustrations!) ("PWR_FLAG" explained above.)
Missing: The "Vss" which the "GND" line should have. (This is analogous to the "Vdd" on the "Vcc" line. The 4011 uses "Vdd" in place of "Vcc" and "Vss" in place of "GND".
The diagram's junctions may not be 100% right, either. (The junctions are superfluous in some cases… but they never do any harm, if you want to be sure you connected the power port you thought you connected!)
A "junction" is something you see on a schematic. It is a little "blob". If two lines cross, and there is no junction, they are not connected. If you see a "T junction", often if there is no "blob" then there is no connection.
So! Not my finest hour as an illustrator. Would you rather I re-did that, to make it better, or get on with writing information about some new topic? The latter, I hope!