Author Topic: Diode footprints have anode and cathode flipped  (Read 4518 times)

0 Members and 1 Guest are viewing this topic.

Offline Ranayna

  • Regular Contributor
  • *
  • Posts: 165
  • Country: de
Diode footprints have anode and cathode flipped
« on: August 20, 2018, 01:52:50 pm »
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.
 

Offline mdszy

  • Supporter
  • ****
  • Posts: 291
  • Country: us
  • somehow has an ee degree
    • szy.io
Re: Diode footprints have anode and cathode flipped
« Reply #1 on: August 20, 2018, 01:56:28 pm »
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.
somehow allowed to be a Pixie Wrangler in Training
eBay Store | My site | Hackaday.io Projects | my mastodon.technology profile
 

Offline Ranayna

  • Regular Contributor
  • *
  • Posts: 165
  • Country: de
Re: Diode footprints have anode and cathode flipped
« Reply #2 on: August 20, 2018, 02:13:09 pm »
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?
 

Offline mdszy

  • Supporter
  • ****
  • Posts: 291
  • Country: us
  • somehow has an ee degree
    • szy.io
Re: Diode footprints have anode and cathode flipped
« Reply #3 on: August 20, 2018, 02:31:05 pm »
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!
somehow allowed to be a Pixie Wrangler in Training
eBay Store | My site | Hackaday.io Projects | my mastodon.technology profile
 

Offline donotdespisethesnake

  • Frequent Contributor
  • **
  • Posts: 884
  • Country: gb
  • Embedded stuff
Re: Diode footprints have anode and cathode flipped
« Reply #4 on: August 20, 2018, 08:09:55 pm »
"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.
Bob
"All you said is just a bunch of opinions."
 

Offline bson

  • Supporter
  • ****
  • Posts: 1564
  • Country: us
Re: Diode footprints have anode and cathode flipped
« Reply #5 on: August 21, 2018, 11:03:32 pm »
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.
 

Online Bassman59

  • Super Contributor
  • ***
  • Posts: 1265
  • Country: us
  • Yes, I do this for a living
Re: Diode footprints have anode and cathode flipped
« Reply #6 on: August 21, 2018, 11:44:10 pm »
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.

Ah, 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.
 

Offline bson

  • Supporter
  • ****
  • Posts: 1564
  • Country: us
Re: Diode footprints have anode and cathode flipped
« Reply #7 on: August 22, 2018, 02:53:25 am »
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.
Yep, 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...  |O

Oh, standards. :)
 

Offline tycz

  • Regular Contributor
  • *
  • Posts: 74
Re: Diode footprints have anode and cathode flipped
« Reply #8 on: August 22, 2018, 05:08:43 am »
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.
 
The following users thanked this post: Siwastaja

Online Bassman59

  • Super Contributor
  • ***
  • Posts: 1265
  • Country: us
  • Yes, I do this for a living
Re: Diode footprints have anode and cathode flipped
« Reply #9 on: August 22, 2018, 06:32:08 pm »
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.

The 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.
 

Offline tycz

  • Regular Contributor
  • *
  • Posts: 74
Re: Diode footprints have anode and cathode flipped
« Reply #10 on: August 23, 2018, 03:08:10 am »
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.

The 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.

Not true. I have many PCB packages at hand and just checked myself. Bartels AutoEngineer, Eagle, PCB Elegance, and Pulsinix all call it a pin/pad name. 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.

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.

You 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.
 

Offline Doctorandus_P

  • Frequent Contributor
  • **
  • Posts: 579
  • Country: nl
Re: Diode footprints have anode and cathode flipped
« Reply #11 on: October 07, 2018, 11:32:33 pm »
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.


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?
 

Offline spudboy488

  • Regular Contributor
  • *
  • Posts: 107
Re: Diode footprints have anode and cathode flipped
« Reply #12 on: October 08, 2018, 11:27:34 am »
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.

That'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.
 

Offline SeoulBigChris

  • Contributor
  • Posts: 34
  • Country: kr
  • "Unencumbered by the thought process"
Re: Diode footprints have anode and cathode flipped
« Reply #13 on: February 14, 2019, 10:23:03 am »
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.

Indeed, 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.
 

Offline donotdespisethesnake

  • Frequent Contributor
  • **
  • Posts: 884
  • Country: gb
  • Embedded stuff
Re: Diode footprints have anode and cathode flipped
« Reply #14 on: February 14, 2019, 04:05:04 pm »
Fun with polarity marks: https://blog.screamingcircuits.com/2013/01/how-not-to-mark-a-diode.html

We 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 the same manufacturer 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.



Bob
"All you said is just a bunch of opinions."
 

Offline bson

  • Supporter
  • ****
  • Posts: 1564
  • Country: us
Re: Diode footprints have anode and cathode flipped
« Reply #15 on: February 14, 2019, 08:37:46 pm »
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.
It 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 the v5.1 v5.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.
« Last Edit: February 14, 2019, 09:23:46 pm by bson »
 

Offline SeoulBigChris

  • Contributor
  • Posts: 34
  • Country: kr
  • "Unencumbered by the thought process"
Re: Diode footprints have anode and cathode flipped
« Reply #16 on: February 15, 2019, 01:27:14 am »
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.
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 1493
  • Country: dk
Re: Diode footprints have anode and cathode flipped
« Reply #17 on: February 15, 2019, 01:54:43 am »
Fun with polarity marks: https://blog.screamingcircuits.com/2013/01/how-not-to-mark-a-diode.html

We 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 the same manufacturer 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.

the 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.
 
The following users thanked this post: SeoulBigChris

Offline lumostor

  • Newbie
  • Posts: 2
  • Country: ca
Re: Diode footprints have anode and cathode flipped
« Reply #18 on: February 16, 2019, 06:21:28 pm »
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.

The 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?
« Last Edit: February 16, 2019, 07:10:33 pm by lumostor »
 

Offline bson

  • Supporter
  • ****
  • Posts: 1564
  • Country: us
Re: Diode footprints have anode and cathode flipped
« Reply #19 on: February 16, 2019, 08:20:24 pm »
There still is a small PSPICE library, where I grabbed a generic op-amp for my last project.

I tend to reach for an ideal opamp, which of course is a simple VCVS with a suitably large amount of gain:

Code: [Select]
.subckt IDEAL 1 2 3 4 5
E1 5 0 1 2 1000000.0
.ends

Put 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.)
« Last Edit: February 16, 2019, 08:27:13 pm by bson »
 

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 1259
  • Country: us
Re: Diode footprints have anode and cathode flipped
« Reply #20 on: June 07, 2019, 10:58:57 pm »

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.
The 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
 

Offline Warhawk

  • Frequent Contributor
  • **
  • Posts: 458
  • Country: 00
    • Personal resume
Re: Diode footprints have anode and cathode flipped
« Reply #21 on: June 08, 2019, 11:05:07 am »

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.
The 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

Aaand here we go again  ::)
IPC norms defines pin numbers for diodes. The pin 1 = cathode.

Quote
So, I redo all my libraries to have pins A and K, both in the schematic and footprint.  Then, there is no confusion.


Not really, Cathode is spelled with C therefore your libraries shall maintain A & C as default.


Offline grbk

  • Contributor
  • Posts: 45
  • Country: us
Re: Diode footprints have anode and cathode flipped
« Reply #22 on: June 08, 2019, 11:56:42 am »
Quote
So, I redo all my libraries to have pins A and K, both in the schematic and footprint.  Then, there is no confusion.


Not really, Cathode is spelled with C therefore your libraries shall maintain A & C as default.

The traditional label for cathode pins is K, not C. Reference: https://electronics.stackexchange.com/questions/65981/why-is-the-symbol-for-cathode-a-k
 

Offline donotdespisethesnake

  • Frequent Contributor
  • **
  • Posts: 884
  • Country: gb
  • Embedded stuff
Re: Diode footprints have anode and cathode flipped
« Reply #23 on: June 08, 2019, 09:56:32 pm »

The 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.

That 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.
Bob
"All you said is just a bunch of opinions."
 

Offline tycz

  • Regular Contributor
  • *
  • Posts: 74
Re: Diode footprints have anode and cathode flipped
« Reply #24 on: June 10, 2019, 01:48:50 am »
The 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.

Another 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.



That works until you have dual diodes in SOT23 packages, then you have to use pin numbers again.

You 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.

The only thing worse than not following an industry standard is to create you own.

If 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.
 

Offline Warhawk

  • Frequent Contributor
  • **
  • Posts: 458
  • Country: 00
    • Personal resume
Re: Diode footprints have anode and cathode flipped
« Reply #25 on: June 10, 2019, 01:01:41 pm »
Quote
So, I redo all my libraries to have pins A and K, both in the schematic and footprint.  Then, there is no confusion.


Not really, Cathode is spelled with C therefore your libraries shall maintain A & C as default.

The traditional label for cathode pins is K, not C. Reference: https://electronics.stackexchange.com/questions/65981/why-is-the-symbol-for-cathode-a-k

Oh snap! I did not know this.  ;)


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf