Reading forum I know that real diodes have K=1 and simulation models have A=1. So I expected diode in Simulation library having A=1. But not - it also has K=1. As I have never before tried using Spice in KiCad I suppose that it was changed to avoid problems if someone take this diode and select footprint to it.
In that symbol there is:
So the correction of reversed pins is made here - OK.
I have my simple BAV99 model I have done in 90s based on 1991 Philips data book:
.model BAV99 D (IS=10f RS=1.5 CJO=1.5p TT=8.656n BV=70)
So I decided to start from this simple model to add this diode to my simulation symbols lib.
I:
did āSave-asā those D from Simulation_SPICE library to my library,
changed model from āBuild-in SPICE modelā to āSPICE model from fileā,
selected file containing my model,
selected model.
And then I found my diode works reversed.
During this 4 step process Pin assignment was changed without any action on my side to:
Donāt you think it is a bug?
After changing to āSPICE model from fileā on the model side we have twice āNot connectedā. And then when model is selected I suppose the old values (when diode for simulation was draw reversed (as I suppose) are written here.
If it is so that in past diode for simulation was reversed and now is as all other diodes than here it should behave consistently.
Does it matter?
You are already used to maintaining your own verified libraries, and KiCadās libraries do not come with spice models. So you just fix whatever is needed when you update your personal libraries to work with spice.
And the location of the anode is an issue, but a very minor one. Diodes in SOT-23 are very common, and also dual diodes in SOT-23 with a bunch of different combinations. I am already happy that the disambiguation of the location of pin 1 on a SOT-23 seems to have become an historical anecdote.
If a faulty combination of a diode symbol and a spice model was part of KiCadās default libraries I would consider it a bug that needs fixing. But because there are a gazillion parts āout thereā I do not have much faith in some rule of thumb of where the anode of a diode should be.
I have even seen examples of SMT leds from the same manufacturer which looked identical, but one LED had the anode marked, and the other had the cathode marked. I assume that somebody in the factory made a mistake, and they only discovered it after a million or so LEDās had been made, and instead of throwing them away, they just made a new datasheet.
For me not specially.
But I think the less user traps in KiCad the better and we are here to make it better. Arenāt we?
If all diodes were reversed to K=1 then I suppose automatic filling of Pin Assignment should also follow this convention. I would be sure of my assumptions if I were using KiCad Spice for years and not since yesterday.
For v7 we changed the sim diode symbol to have the cathode on pin 1 (like real diodes) and added the alternate pin ordering so spice sees the anode on pin1 like it expects. I think we also added the alternate pin ordering to all the ārealā diode symbols, or at least the single diodes (duals, arrays, etc would need a model).
The idea was to avoid the backwards diode on your board footgun, and also to allow any of the diode symbols to be used for simulation. There should no longer be any real distinction between the sim diode and the real diodes (although I think we made sure the sim model is set up out of the box for the diode in the spice library)
Edit: yes there is a trap in that changing the spice model for any symbol deletes the alternate pin ordering. I donāt particularly like this behavior - you could raise an issue if you want, but I believe it is that way on purpose.
When I changed for Default model to from file model it was reset to āNot connectedā.
When I selected file it was still āNot connectedā.
When I selected model it was filled like you see.
I think it was reasonable default when diode symbol for simulation had A=1 (I believe it was such in past). When all symbols have K=1 I think default should be reversed.
Not changed texts written (still A=1 K=2) on the right table side but the same texts written in reversed order or in diode symbols the order of filling table changed so when this is filled automatically it would be just OK.
Diode and transistor pin numbers seem to be inconsistent between vendor datasheets. So I donāt think you need to get into simulation in order to encounter contradictory pin number information.
I have not gotten into NG Spice. I have used PSpice, PSIM, LTSpice, Simplis/Simetrix, TINA-TI. My first one was in Fortran Watfiv compiler, and have done sims in Excel and on a programmable calculator. I am not looking for another one!
Of course this was known since before 5.1 but the ngspice developers failed to convince the library maintainers to add the field and most lead developers didnāt care before 7.99 started.
From what I remember, the argument for keeping the swapped diode in the āSimulation_Spiceā was for maintaining compatibility with existing legacy schematics. And that was important in old KiCad versions because changing the library symbols would break all existing schematics.
Starting from KiCad V5 the project was independent from the libraries (First with the [Project]-cache.lib file), and from V6 onward, the symbols are fully integrated into the project, and that has now been around long enough to justify breaking compatibility with KiCad V4 or earlier. Also, if you care about your projects, you should archive them properly. I still have some memories of KiCad V3 and/or V4 and creating project specific libraries to make projects independent of the main libraries for archiving purposes. Back then there were also scripts to help with that.
It also looks like the Simulation_Spice library has gotten a big overhaul. It used to have much bigger (and ugly) resistor, capacitor and diode symbols for example. The resistor and capacitor have now been completely removed from the simulation library, transistors now have the same graphics as from the other default libraries. Voltage and other sources now have the same style as other KiCad libraries.
And also: Itās a simulator Start with a source, resistor, diode and GND reference for your fist simulation or just to verify you can get any simulation started, and whether the diode behaves as expected.
After that you can try to sort out the 12 variants of the BAT54.
This is indeed bad and unexpected behavior of Eeschema. The pin sequence and diode polarity have absolutely nothing to do with the model. Attaching a model (talking about a .model line, not a subcircuit) should not touch it, when I already have my circuit up and running! Pin sequence and diode polarity are only connected to the symbol and its polarity in my circuit. And this I did not change.
Fortunately I have never need to simulate real schematic of my PCB. My simulations were always a different schematics just to check something so I can have one BAT54 single diode model
My symbol libraries for Spice will be separate libraries from real part libraries.