Errors message when I click on simulation

I didn’t said that Spice in KiCad need not be as good as possible (as everything). I just said that not all KiCad users need spice. If it is less or more than 50% of users - I don’t know.

I don’t think more than 1% of KiCad users are doing something like you.

This is an often repeated argument and too often abused as a stop gap answer.
Holger already posted a link to Spice models and model parameters for ngspice circuit simulator and in for example MicroCap-LIBRARY.7z/m_opamp.lib there is a license statement with:

  • Motorola Operational Amplifier Macromodel Library
  • Rev 1.1
  • Macromodels, simulation models, or other models provided by
  • Motorola, directly or indirectly, are not warranted by
  • Motorola as fully representing all of the specifications and
  • operating characteristics of the semiconductor product to
  • which the model relates. Moreover, these models are
  • furnished on an “as is” basis without support or warranty of
  • any kind, either expressed or implied, regarding the use
  • thereof and Motorola specifically disclaims all implied
  • warranties of merchantability and fitness of the models for
  • any purpose. Motorola does not assume any liability arising
  • out of the application or use of the models including
  • infringement of patents and copyrights nor does Motorola
  • convey any license under its patents and copyrights or the
  • rights of others. Motorola reserves the right to make
  • changes without notice to any model.

Looks like they are mostly concerned with waving away any sort of liability then protecting copyright claims. I also interpret the “as is” part as “free to use” / “public domain”. But my head always starts spinning from legalese. It’s an interesting library for beginners because it has a lot of “old fashioned” opamps such as TL081 and LM358.

The license above is still a bit vague, but I have also seen spice libraries that have an explicit public domain license. I think the main obstacle is that there is simply no attention at all to an implementation for KiCad in this direction.

Some Ideas towards an implementation:

  1. A change on the licensing page of KiCad itself, with a statement that spice models are released with whatever license they already have in their files.
  2. For a few models (NE555, opamps and such) they could be added to Simulation_SPICE library, but that would only work for a handful of (common) models.
  3. For a more universal implementation, I think a flag inside the library system is preferred. It could filter for symbols with available spice models. Maybe have a direct link to show the library text (inclusive it’s license).
  4. Several of KiCad’s standard library symbols could have very simple spice models. For example, a fuse could have a simple resistance (under assumption the current is “low”). Resistors and capacitors could have some “sensible defaults” for parasitic values. This is not with the intention to be very accurate (for seasoned spice users), but to give beginners an easier start.
  5. Symbols like connectors and net ties can have the Exclude from simulation attribute set. (I’m thinking about making a feature request for this).

What if for parts that do have a more vague license you would link to the model?

I would also waive the liability. A simulation model can only do so much and was designed for some usecase, not all corner cases.

Anyway form a legal standpoint thats much like all rights reserved as it does not mention copying and distributing.

This might have implications for Open Source *nix distributions. The licenses should be verified to be compatible with the guidelines of the distro, and if it’s not, the file can’t be distributed in the official repository. If some library files wouldn’t be distributed in some distro, that would cause problems for the end users: some would have a file and some wouldn’t. Imagine the mess in this forum if some symbols or footprints were missing from some users’ installations!

As for an example, this Motorola license doesn’t meet Open Source or Free Software requirements (if the quoted text is all there is). “All [possible legal] rights reserved unless otherwise stated” is the default starting point for licencing, everything which gives more rights to recipients/users must be explicitly stated. That specific “license” is just denying any responsibility of the copyright owner (legally or not), it doesn’t give any rights to users which aren’t already legal rights without a license.

This is a more general problem in our field: 3D models are usually distributed by the part manufacturers but they don’t give any rights to re-distribute the models, not even as-is, unmodified and mentioning the original source.

IANAL either, but lawyers do give me pain in that general direction…

Another one from the *basic_models.7z file, the Lm358.

  • Legal Notice: This material is intended for free software support.
  • The file may be copied, and distributed; however, reselling the
  • material is illegal

It seems very permissive, but also vague.

That is one I had not considered. IANAL at all and only thought about KiCad’s own license.

That would be a big mess. Nobody can keep an overview of that, so that’s not a usable option.

When I first started with Linux several distributions had multimedia codecs as a separate package and they were not installed by default because of legalese. Maybe similar can be done for KiCad. Have a spice library that is verified legal and another one that may be unclear, but it’s left to user discrepancy whether he installs it or not. Many Linux distributions have a provision for non-free stuff. It’s often video and WiFi that have problems in this direction. Debian is quite strict in this regard because it’s a root distribution of many other distributions, and Debian has a specific non-free.

It’s a lot of trouble for some text files. It’s not software, it’s not even a software library but just some tables in a text file. .

Related: I find that often the encrypted/encoded (?) spice models for PSPICE or LTSPICE, such as the one below, don’t run in ngspice even with “PSPICE and LTPSICE” compatibility mode (when lanched in KiCAD, I haven’t tried external ngspice yet). Is this expected behavior?

NCS2005 PSPICE MODEL.LIB (18.6 KB)

Indeed.
The whole idea of encrypted model is to thwart attempts to read it. There are even countries who have made laws against breaking encryption.

Hello,
I finally found the solution by removing the LT3032 and his model with “varistors” (well done and thank you Holger, you were right) and replacing it with a TPS7A3901 whose model is well accepted.

No more problems with it, but, because there is always a but, Kicad gives me know a problem with the model of zeners I use which he had neglected to mention before. A bottomless pit…

Note: Compatibility modes selected: ps lt a
ERROR: mal formed B line: bzx55c6v2
Error: ngspice.dll cannot recover and awaits to be detached

Nah, not bottomless. you are making progress.
Replacing the model of a zener with something that does work can’t be too difficult. There are a bunch of libraries on the ngSpice website and there probably are a bunch of zeners that work with ngSpice among them.

Thank you,
Guessing you’re right… I’ll follow your advice

Have an idea of what is the “mal formed B line” in the model I use, below ?

********************************
* Copyright:                   *
* Vishay Intertechnology, Inc. *
********************************
BZX55C6V2				

* Technology:        DISCRETE DEVICE				
* Device:            Zener Diode BZX 55C 6V2				
* Type:              Typical (nom)				
* Model established: 12.11.1996, by S.Reuter, TM1iC63-HN				
* Wafer:				
* Remarks:           Macro model				
* Revision:				
* Simulator:         PSPICE				

.SUBCKT BZX6V2 a c				

 DF a c DFOR				
 DR c a DREV				
 DB b a DBRE				
 EB c b POLY(1) d 0 4.6 1				
 IB 0 d 1m				
 RB 0 d 1k TC=4m				

.MODEL DFOR D				
 + IS =  32p  RS =    0  N  =  1.6  CJO= 128p				
 + VJ = 685m  M  = 342m  FC = 700m  XTI=    3				
 + EG =1.186				

.MODEL DREV D				
 + IS = 100f  N  =   12  XTI=    3  EG =1.186				

.MODEL DBRE D				
 + IS =  10f  N  =    1  XTI=    0  EG =1.186				
				
.ENDS BZX6V2
********************************
* Copyright:                   *
* Vishay Intertechnology, Inc. *
********************************
BZX55C6V2				<----------------------------------------- ???

* Technology:        DISCRETE DEVICE				

Just take the error message serious. What is this line? In a netlist a line starting with a B is assumed to be a B source. But what you have is the device name, probably by mistake added to the model, but not a B source (ngspice manual chapter 5). So remove this line.

Malformed B line is a quite cryptic error message. If the message made it clear it was interpreting that line as being a “B source” then it’s a lot easier to diagnose.

And what about line numbers? It’s common to add line numbers in error messages, does ngSpice not do that, or is this a configuration option?

Hello,
Thank you. It’s better.
NGspice is now just warning me and don’t want to be detached. Warnings concern :
IC 7, D15, D16, D18, D17, Q1, Q10, Q9, Q10, Q3, Q4, Q5, Q6, Q7, Q8, Q12, Q13, Q14, Q2, D19, D20, D14, D13, D8, D7, D11, D12, D10, D9, D6, D5

IC7 is the TPS7A3901 that was OK before correcting the model of BZX55C6V2…
D5 to D12 are 1N4004
D13 to D20 are BY4
Q1 to Q14 are IXTH1N200P3HV Littlefuse mosfets

For example I check the line .IC V(NR/SS )=0 in the model of IC7 (TPS7A3901)
Kicad change it in .ic v(xic7.nr/ss )=0.
For me NR/SS is node3. What does “non-existent node” mean ? I don’t know.

Note: Compatibility modes selected: ps lt a
Circuit: KiCad schematic
Warning : IC on non-existent node - xic7.nr/ss, ignored
Please check line .ic v(xic7.nr/ss )=0
Warning: Model issue on line:
.model xd15:rectifier d(is= 5.000000000000000e-08 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd16:rectifier d(is= 5.000000000000000e-08 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd18:rectifier d(is= 5.000000000000000e-08 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd17:rectifier d(is= 5.000000000000000e-08 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xq1:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.00 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq9:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.00 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq10:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.0 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq11:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.0 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq3:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.00 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq4:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.00 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq5:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.00 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq6:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.00 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq7:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.00 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq8:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.00 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq13:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.0 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq12:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.0 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq14:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.0 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xq2:mm111 nmos level=3 l=2.0000e-6 w=1.2000 kp=1.0258e-6 rs=10.00 …
unrecognized parameter (rds) - ignored
unrecognized parameter (rg) - ignored
unrecognized parameter (rb) - ignored
Warning: Model issue on line:
.model xd19:rectifier d(is= 5.000000000000000e-08 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd20:rectifier d(is= 5.000000000000000e-08 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd14:rectifier d(is= 5.000000000000000e-08 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd13:rectifier d(is= 5.000000000000000e-08 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd8:rectifier d(is= 1.250000000000000e-07 bv= 4.2000000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd7:rectifier d(is= 1.250000000000000e-07 bv= 4.2000000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd11:rectifier d(is= 1.250000000000000e-07 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd12:rectifier d(is= 1.250000000000000e-07 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd10:rectifier d(is= 1.250000000000000e-07 bv= 4.200000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd9:rectifier d(is= 1.250000000000000e-07 bv= 4.2000000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd6:rectifier d(is= 1.250000000000000e-07 bv= 4.2000000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored
Warning: Model issue on line:
.model xd5:rectifier d(is= 1.250000000000000e-07 bv= 4.2000000 …
unrecognized parameter (vpk) - ignored
unrecognized parameter (iave) - ignored
unrecognized parameter (vp) - ignored

Does your circuit have a net called NR/SS? I guess it does not. You may set initial conditions of nets. Add a label (a name) to the net you want to set the initial condition (for example cap1). Then add this name to the .ic statement, prepended by a ‘/’.

.ic v(/cap1)=0

The slash is required as Eeschema prepend a slash to each net name internally. As I do not know your circuit, that’s all I can say for now.

Hello,

You’re guessing right. NR/SS is just the name of pine 3 of IC7.
As I said the line I check is in the spice model of TPS7A3901.
Do you think the space between SS and the end parenthesis in .IC V(NR/SS )=0 can disturbe ngspice ? I don’t know what it’s for.

See my circuit attached below.

Schéma.pdf (125.8 KB)

You want to set the initial conditions (voltage upon start of the transient simulation) across capacitor C4?

To do so, you will need the netnames on both sides of C4. Its lower side is connected to GND, so it is sufficient to set ic on the upper side. What is the spice net name of the upper side? It is not 3, and it is not NR/SS. So .IC V(NR/SS )=0 is wrong. KiCad/Eeschema sets the net names. Or you attach a label to this net. If you choose a ‘global label’, say name it c4v, then the net name becomes c4v. If you choose a ‘net label’, the net name becomes /c4v. With a global label the initial condition is then set by .ic v(c4v)=0

May I suggest that you strip down your circuit: just use the TPS7A3901, two fixed input voltages and the output circuitry, just to get it going without all the other circuit parts. Check independently the rectifier diodes and T1. Only when both are running satisfactorily, put them together.

Starting a simulation with a complete circuit will almost never run in the beginning. So then divide and conquer is a must.

Hello holger,
Thank you for your time.

“You want to set the initial conditions (voltage upon start of the transient simulation) across capacitor C4?” The only thing I want is for ngspice to stop annoying me with warnings and allow me to test the power supplies by putting a 230V RMS source at the input of the transformers. Not so simple…

" To do so, you will need the netnames on both sides of C4. Its lower side is connected to GND, so it is sufficient to set ic on the upper side. What is the spice net name of the upper side? It is not 3, and it is not NR/SS. So .IC V(NR/SS )=0 is wrong. KiCad/Eeschema sets the net names. Or you attach a label to this net. If you choose a ‘global label’, say name it c4v, then the net name becomes c4v. If you choose a ‘net label’, the net name becomes /c4v. With a global label the initial condition is then set by .ic v(c4v)=0"
Where can I found the netname of C4?. Here is the netlist of C4. I see lot of names but no netname. Is it 1 ?

(comp (ref “C4”)
(value “10e-9”)
(footprint “Capacitor_SMD:C_1825_4564Metric”)
(datasheet “https://www.vishay.com/docs/45200/vjhirelseries.pdf”)
(description “Unpolarized capacitor”)
(fields
(field (name “Sim.Device”) “C”)
(field (name “Sim.Type”) “=”)
(field (name “Sim.Params”) “c=10e-9”)
(field (name “Sim.Pins”) “1=+ 2=-”)
(field (name “Footprint”) “Capacitor_SMD:C_1825_4564Metric”)
(field (name “Datasheet”) “https://www.vishay.com/docs/45200/vjhirelseries.pdf”)
(field (name “Description”) “Unpolarized capacitor”))
(libsource (lib “Device”) (part “C”) (description “Unpolarized capacitor”))
(property (name “Sim.Device”) (value “C”))
(property (name “Sim.Type”) (value “=”))
(property (name “Sim.Params”) (value “c=10e-9”))
(property (name “Sim.Pins”) (value “1=+ 2=-”))
(property (name “Sheetname”) (value “Racine”))
(property (name “Sheetfile”) (value “AMPLI HV.kicad_sch”))
(property (name “ki_keywords”) (value “cap capacitor”))
(property (name “ki_fp_filters”) (value “C_*”))
(sheetpath (names “/”) (tstamps “/”))
(tstamps “c4b145ef-bd44-4e87-bdea-a6f99ca9a9e5”))

The last thing I don’t understand is why C4 is so special and not C8, C9, C10 or C11 which are all related to TPS7A3901.

BR

The only thing about C4 is that you tried to set initial conditions by .IC V(NR/SS )=0 which is wrong. Obviously there is no urgent need to set this.

So simplify your circuit, repair the zener model, and start the simulation, as I have described above.

Warnings are warnings, not more. They may be ignored for now.

Yes, agreed. The defaults worked well to guide me, but of course the actual circuit behaves differently.

TLDR… As a happy outcome, the circuit actually works much better because of the actual op-amp and switches that I chose. For example I can get stable circuit behavior up to 10 kHz and 1 A, but the model goes unstable above 1 kHz. Probably the existing spice model for my OPA548 (as gate driver) is not great. Next step will be to tinker with the parameters of the existing spice models for that and the switches, and/or learn how to make my own using the data sheets as a guide. If this effort proves fruitful, then for my lab users the goal is to use this circuit as an example of bridging that gap. I’ll do a new example post here if it works.

Hello Holger,

“The only thing about C4 is that you tried to set initial conditions by .IC V(NR/SS )=0 which is wrong. Obviously there is no urgent need to set this.”

I think I expressed myself badly (Sorry…).
When I said I tested the line 224 “.IC V(NR/.SS )=0” in the spice model of the TPS7A3901, I meant that Texas Instrument built their spice model this way ! In short, I didn’t do (and set) anything at all.

Since I’m a little stubborn (just a little), I actually “corrected” the spice model provided by TI by removing the space between NR and ) from the line .IC V(NR/SS )=0, that way .IC V(NR/SS)=0, and the warning disappeared.

As you said, I just have to correct the rectifiers and NMOS models.
Hope to be as lucky as with the TPS7A3901 model…

BR