Diode footprints have anode and cathode flipped - Page 1
Forum section: electronics / general

author: Ranayna
author_rank: Super Contributor
timestamp: August 20, 2018, 01:52:50 pm
content: Hi everyone,I just started laying out my schematic, found a (for me) somewhat serious issue. It seems that all my diode footprints have pin one and two flipped...I used the standard diode symbol in my schematic (just search for diode) and set the value field to the actual part number. I then assigned a footprint from the Diode_SMD library. At that point I thought I was done, but now that I started layouting, all these diodes have pin one and two reversed...I now have two questions:- What did I do wrong- How do I fix this the easiest way?I can still scrap my started layout, I found the issue early while moving components.

author: mdszy
author_rank: Unknown
timestamp: August 20, 2018, 01:56:28 pm
content: Easiest way to fix this would be either to edit the schematic symbol and flip pins 1 and 2 in that symbol, or edit the footprint library and swap the pins on the footprint. Doing so with the footprint would be slightly easier, but if you do it with the schematic symbol you'll need to reload the netlist into the layout.

author: Ranayna
author_rank: Super Contributor
timestamp: August 20, 2018, 02:13:09 pm
content: I think I found the underlying problem...I got the symbol from the pspice library. I changed to the Device:D symbol, and that one is reversed compared to the pspice symbol.I changed all parts using that symbol, created a new netlist, and selected "Update PCB from Schematic" in pcbnew. That has fixed the problem.Is this an issue that should be reported?

author: mdszy
author_rank: Unknown
timestamp: August 20, 2018, 02:31:05 pm
content: Not to be harsh, but sounds like a simple mixup on your part that doesn't really need to be reported, unless it was part of a built-in kicad library. I've never had any issue with this sort of thing in kicad before. Glad you got it sorted, though!

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: August 20, 2018, 08:09:55 pm
content: "Flipped" is a subjective term, as there is no "correct" order.KiCad library parts changed to use pin 1 as cathode in line with IPC specs. The ngspice simulator uses pin 1 as anode. You can change the pin order on any symbol for use with ngspice.

author: bson
author_rank: Unknown
timestamp: August 21, 2018, 11:03:32 pm
content: Report it! It's a serious issue, and not easy to properly fix, either. Obviously, spice netlists have the opposite pinout for diodes from those in the KiCAD libraries in general. That's a big problem.

author: Bassman59
author_rank: Super Contributor
timestamp: August 21, 2018, 11:44:10 pm
content: Quote from: bson on August 21, 2018, 11:03:32 pmAh, a lovely can of worms.As donotdespisethesnake mentioned, "KiCad library parts changed to use pin 1 as cathode in line with IPC specs." This caused a lot of consternation among some users, but it was done for the right reasons, it was publicized, and it all settled out.The problem is that Kicad is first and foremost a PCB layout tool. That ngspice or the particular diode model in question doesn't match the IPC recommendations is a problem, and there's no real good solution, other than to always verify your library parts.

author: bson
author_rank: Unknown
timestamp: August 22, 2018, 02:53:25 am
content: Quote from: Bassman59 on August 21, 2018, 11:44:10 pmYep, clearly KiCAD is correct here. And changing spice is impossible (it would invalidate a gazillion subcircuit models out there). So I guess the only thing to do is swap the pins when generating spice netlists...Oh, standards.

author: tycz
author_rank: Regular Contributor
timestamp: August 22, 2018, 05:08:43 am
content: A better way to avoid this problem is not to name the pins with numbers in the first place. Nobody knows which pin of a diode, speaker, battery, electro capacitor, etc is pin 1 and pin 2. If you assign a number it ends up being arbitrary. Give it a meaningful name instead. For example, the diode pins could be called A and K, the battery pins could be called PLUS and MINUS. This way if you end up accidentally pairing a foreign symbol with a known geometry (or vice versa), if one has pins/pads labelled PLUS and MINUS and the other with 1 and 2 you will get no connection instead of pins flipped silently.Kicad (v4 at least) has a silly terminology problem where a pin name is referred to as a 'pin number' in the software. To make it worse it has another field called 'pin name' which is actually a just a text description, unused in netlist creation. This makes users think they have to assign an arbitrary number to every pin which in not the case.

author: Bassman59
author_rank: Super Contributor
timestamp: August 22, 2018, 06:32:08 pm
content: Quote from: tycz on August 22, 2018, 05:08:43 amThe pin number is a standard thing, across every PCB CAD package and in common use. It doesn't even have to be a number. As you say, it can be A and K for a diode's anode and cathode, and for BGA and PGA packages it'll be something like A1. it is what maps a pin on your schematic symbol to the pin on the physical footprint.You are correct, the pin name field isn't used for the netlist, but it's what is displayed as part of the schematic symbol. For transistors, capacitors, resistors and such the pin name field isn't interesting (and can be left blank) but for parts like microcontrollers the pin name field is essential.None of this makes users think they need to assign an arbitrary pin number to every pin! If you want your circuit to actually work, every pin on a symbol must have a pin number (which again doesn't have to be a number) that exactly matches a pin on the footprint. This is the opposite of arbitrary.

author: tycz
author_rank: Regular Contributor
timestamp: August 23, 2018, 03:08:10 am
content: Quote from: Bassman59 on August 22, 2018, 06:32:08 pmNot true. I have many PCB packages at hand and just checked myself. Bartels AutoEngineer, Eagle, PCB Elegance, and Pulsinix all call it a pin/padname. Altium calls it a designator. The only package that I could find other than Kicad that calls that calls it a pin number is Diptrace.Quote from: Bassman59 on August 22, 2018, 06:32:08 pmYou missed the point of what I was saying. I simply said that there is no meaningful link between a number and the function of the pin on many two pin components.It's definitely a misnomer to call the pin name a pin number and I can't see any place in the Kicad documentation where it says this value can be anything but a number. The only way a new user would know to type a name in there is of he was already familiar with another PCB package.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: October 07, 2018, 11:32:33 pm
content: If you are using some generic symbol it is folly to assume that stuff like pin numbering is correct.For me the only right solution is to to make a custom library from all the parts I use.Sometimes an existing symbols gets copied from an existing library, sometimes I start with a generic symbol and put it as a "real part number" in my own library, sometimes I design new symbols from scratch.But what all my own custom symbols have in common is that every important aspect is hand checked and verified.So what you did "wrong" in my opinion is to make assumptions on a "generic" symbol to have attributes that in this case did not fit with your specific part number.Quote from: Ranayna on August 20, 2018, 01:52:50 pm

author: spudboy488
author_rank: Regular Contributor
timestamp: October 08, 2018, 11:27:34 am
content: Quote from: Doctorandus_P on October 07, 2018, 11:32:33 pmThat's exactly what I did and have always done. I built my own library where I checked the footprint against the schematic symbol for the parts I use. If I use a new part, I create a new entry. It took some time to initially set up but it was well worth it.

author: SeoulBigChris
author_rank: Regular Contributor
timestamp: February 14, 2019, 10:23:03 am
content: Quote from: Bassman59 on August 21, 2018, 11:44:10 pmIndeed, a can of worms. I just got bit by this today for the second time. I tend to agree with your comment that KiCad is first and foremost a PCB layout tool, but we can't forget schematic entry, which is an integral part of the KiCad package.After digging through this issue today out of curiosity (*), I take issue with your characterization of "pin1 = anode" as being a problem of ngspice or the diode model designer. This is just a fundamental fact of the way SPICE was first written 1971. I can only guess the IPC had a strong reason to buck this 30-year "tradition" when they formally defined the pin numbering opposite of what SPICE did.Personally, I can't see any logic in one method or the other. At all companies I've worked with in the past we stuck to the JEDEC convention of intentionally NOT numbering pins of diodes and transistors, only using the letters K,A, and E,B,C. Anyway, it turns out that the KiCad to Spice interface now has a provision to re-order the pin numbers, so it's a solvable problem, if annoying.(*) The earliest document I could clearly find which showed me the pin ordering of the integrated diode model in Spice was from the Spice 2 FORTRAN source code dated 1981. I suppose it's possible that between 1971 and 1981 the diodes were pin1=cathode, and suddenly swapped in 1981, but still, that's 20+ years ahead of IPC's declaration. I'm open to correction and learning more.

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: February 14, 2019, 04:05:04 pm
content: Fun with polarity marks:https://blog.screamingcircuits.com/2013/01/how-not-to-mark-a-diode.htmlWe have similar problems where a reel gets ordered with second-source parts from a different manufacturer, and they decided to load the reel differently. Every diode fails at test. Sometimes thesamemanufacturer decides to load the tape differently.I think the prudent engineer learns not that there is only one way to do things (whether house rules or international standard), but to be always on guard for this sort of problem.

author: bson
author_rank: Unknown
timestamp: February 14, 2019, 08:37:46 pm
content: Quote from: SeoulBigChris on February 14, 2019, 10:23:03 amIt has had this since day one, but the main difference with v5 is that there is no longer a special simulation symbol library; spice properties like pin mapping (node sequence) is part of the regular symbol properties. At some point I suspect the idea is also for parts like op amps to have a simulation model as part of the symbol properties. (It's there but not generally populated yet.) To get a view of the idea, in thev5.1v5.0.2rc/nightly (if you have this installed), hover over a schematic component, press E, the press the Edit Spice Model... button at the bottom.

author: SeoulBigChris
author_rank: Regular Contributor
timestamp: February 15, 2019, 01:27:14 am
content: Good points. I'm using KiCad 5.01, and am becoming quite familiar with that "edit spice parameters" menu. Noted about the history of the pin number re-ordering feature - while I used KiCad v4.x in the past, my first attempts at using the KiCad ==> SPICE capabilities have been with v5.x. I really like the link-up between the tools, despite a few quirks and rough edges here and there. It's a pretty powerful match-up.There still is a small PSPICE library, where I grabbed a generic op-amp for my last project. From comments I've read, the PSPICE library used to be more populated that now. The op-amp also needed the pin-number reordering feature.By the way, thinking about my comment above a little further, one could make the argument that SPICE and the JEDEC standards didn't actually NUMBER diodes and transistors. Take SPICE, the anode and cathode don't actually have the concept of a pin-1 and pin-2, rather, it's just the order of parameters to the DIODE model where anode comes first. Similarly, JEDEC didn't say anything about pin-1 for diodes or transistors - it just gives them letter names, not numbers. In the vein, you could say that IPC didn't buck the trend, rather they just assigned numbers to the pins that had never had numbers assigned in the first place.

author: langwadt
author_rank: Super Contributor
timestamp: February 15, 2019, 01:54:43 am
content: Quote from: donotdespisethesnake on February 14, 2019, 04:05:04 pmthe assembler we use at work has a pick-n-place machine that can probe components during placement checking diode directions, resistor and capacitor values etc.

author: lumostor
author_rank: Newbie
timestamp: February 16, 2019, 06:21:28 pm
content: Quote from: SeoulBigChris on February 15, 2019, 01:27:14 amThe concept of pin number vs letter(name) is quite important when it comes to assign the symbol to the footprint. For example, I prefer to choose a transistor symbol named Q_NMOS_GSD - GSD being the pin 1,2,3 respectively assigned to the footprint - rather than assigning a foot print depending of the pin correspondance. If you name the pins like G, S, D and E, B, C and all combinations it will become rapidly a mess to manage at the foot print level and the symbol level with "atomic" parts. Regarding diodes some diodes are in TO, SOT, few even 0603, ... packages. Using pin numbers they can have one SOT-23 footprint for all types (BJT, MOSFET, ...) of transistors and also for for diodes, SCRs, TRIACs, ... and manage the assignment at the symbol level. I prefer that way - the atomic way. Anyway it is at that level - schematic - that I choose the component even if sometime when doing the PCB, the component may change for physical reasons.Now why pin 1 is cathode, maybe because it is the electromotive force direction, but why they choose that direction given the fact that EEs still "like" the conventional current flow and moreover the symbol is like an arrow following the conventional current flow, that, I can't say. Maybe they flipped a coin, who knows?

author: bson
author_rank: Unknown
timestamp: February 16, 2019, 08:20:24 pm
content: Quote from: SeoulBigChris on February 15, 2019, 01:27:14 amI tend to reach for an ideal opamp, which of course is a simple VCVS with a suitably large amount of gain:Code:.subckt IDEAL 1 2 3 4 5E1 5 0 1 2 1000000.0.endsPut that as text somewhere on the schematic. Pick a generic opamp (I recall it being called "opamp2" in the past, it's been a while) and set its model/value to XIDEAL. I recall these both need to match or ngspice will do weird things. Since it's ideal it doesn't use the supply pins (those are there to simplify replacing it with a real opamp model) and its output will happily go past the supplies. Pretty ideal, right?I add resistors and capacitors as needed if I want to see what happens say if there 5pF of input capacitance, or Rin=40kΩ, or both. It's often useful to start with an ideal part and work from there, and for most simple "hmm, I wonder if this will work" kind of experiments not intended to become real circuits ever, an ideal VCVS is a quick and easy starting point.My main beef with the simulation interface is that it can only plot things it can see in the schematic. So it can't be used for something like monte carlo analysis even though ngspice will happily do it. (It could be fixed but requires the ability to add plots by name pattern, like "mcout*" since the analysis generates a large number of plots that the KiCad UI is totally unaware of and can't or won't discover on its own.)

author: jmelson
author_rank: Super Contributor
timestamp: June 07, 2019, 10:58:57 pm
content: Quote from: Doctorandus_P on October 07, 2018, 11:32:33 pmThe REAL problem here is having diodes with pins 1 and 2! No diode has a pin 1, it has an anode and cathode.So, I redo all my libraries to have pins A and K, both in the schematic and footprint. Then, there is no confusion.You just have to remember to ONLY use your own part library.Jon

author: Warhawk
author_rank: Frequent Contributor
timestamp: June 08, 2019, 11:05:07 am
content: Quote from: jmelson on June 07, 2019, 10:58:57 pmAaand here we go againIPC norms defines pin numbers for diodes. The pin 1 = cathode.QuoteNot really, Cathode is spelled with C therefore your libraries shall maintain A & C as default.

author: grbk
author_rank: Contributor
timestamp: June 08, 2019, 11:56:42 am
content: Quote from: Warhawk on June 08, 2019, 11:05:07 amThe traditional label for cathode pins is K, not C. Reference:https://electronics.stackexchange.com/questions/65981/why-is-the-symbol-for-cathode-a-k

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: June 08, 2019, 09:56:32 pm
content: Quote from: jmelson on June 07, 2019, 10:58:57 pmThat works until you have dual diodes in SOT23 packages, then you have to use pin numbers again.The only thing worse than not following an industry standard is to create you own.

author: tycz
author_rank: Regular Contributor
timestamp: June 10, 2019, 01:48:50 am
content: Quote from: jmelson on June 07, 2019, 10:58:57 pmAnother one that I've often seen people make mistakes with is potentiometers, because the pins are named 1, 2, 3. What they should be called is CW, W, CCW. This stands for clockwise, wiper, and counterclockwise. Also make sure at least one of the CW or CCW pin names is visible on the schematic symbol. Then you will never again mix up the CW and CCW terminals and end up with a pot that turns the wrong way.Quote from: donotdespisethesnake on June 08, 2019, 09:56:32 pmYou miss the point. We're not saying that pin numbers should be avoided at every conceivable opportunity. Just that they shouldn't be used if they are not normally used and not meaningful.For example, if I ask a technician to measure the voltage at pin 1 of a particular diode in a SOT23 package on a particular board, I can reasonably expect he'll know what I mean. If I ask him to measure the voltage at pin 1 of a 1n4148 diode I don't know what I'll get... probably laughed at.Quote from: donotdespisethesnake on June 08, 2019, 09:56:32 pmIf the diode pins are named with numbers you can end up with the pins silently swapped around. This can lead to a bad board being sent to be manufactured in the worst case. The only way to avoid this is to spend lots of time checking, checking, double checking. I don't like to spend my time on tedious tasks like this and will do what I can to make them unnecessary. That's why I think this IPC standard of numbering all device pins is a bad one.When you give the diode pins meaningful names the worst thing that can happen is you get an error message. A minute later and it's fixed.

author: Warhawk
author_rank: Frequent Contributor
timestamp: June 10, 2019, 01:01:41 pm
content: Quote from: grbk on June 08, 2019, 11:56:42 amOh snap! I did not know this.