I am trying to simulate a circuit utilizing LM5145. I have downloaded the simulation files from TI, and using LM5145_PSPICE_TRANS/LM5145_TRANS.LIB from the zip file as simulation model.
I set compatibility mode to PSpice.
I got the following error:
Circuit: KiCad schematic
Error on line:
a.xic1.x_u4_s4.as_u4_s4 %gd xic1.clk probe_int_net-_ic1-en/uvlo__xic1_1 %gd xic1.u4_n16854848 xic1.u4_n16855005 xic1.x_u4_s4:a_u4_s4
MIF-ERROR - unable to find definition of model xic1.x_u4_s4:a_u4_s4
Error: circuit not parsed.
Background thread stopped with timeout = 0
I believe the problem is somewhere here, but I am too new to all of this to figure it out:
There is a bug in ngspice, deeply buried in the attached model. The F source with its general syntax FXXXXXXX N+ N- VNAM VALUE <m=val > does not accept mathematical symbols (like / or -) in the VNAM token. F-Source is used in a single place, line 414 of the LM5145 model. Due to the circuit, the name of your symbol IC-1 becomes part of this F-source VNAM, the name is cut into two halves at the - sign, and the whole business fails.
I have already a fix for this, which I will upload to ngspice git development branch pre-master-43 after some testing. This will appear however only in ngspice-43.
A preliminary fix is to simply rename The U1 symbol to IC_1.
Unfortunately the simulation will start, but fail.
If you want to simulate powwer supplies, some options to reduce precision requirements or others are due. So put a line .options rshunt=1e9 chgtol=1e-10 into a textbox on the Eeschema canvas.
There are also some issues with your circuit:
There is no GND connection. Place a GND symbol.
Don’t simulate connectors. Attaching a voltage source model to a connector does not work, as the connector has only a single node, the ngspice voltage source needs two. So remove the connectors from being simulated and attach a VDC from library Simulation_Spice to the circuit between GND and Vin.
The TRAN time step is much too coarse. Instead of 10m choose 10u.
Using these changes, I get a simulation with output voltage 2.73V at Vin 18V.
Thank you for the detailed reply. I got stuck with one thing however:
You say “A preliminary fix is to simply rename the U1 symbol to IC_1.”
I looked at the library code, but I could not find any standalone “U1”. I tried to s/U1/IC_1/g in vi to rename all instances of “U1” to “IC_1”, but the problem remained.
Then I thought you might wrote it backward, so I renamed my IC-1 symbol to U1.
That did not help either.
However I cannot get the simulation to not abort.
The 7z you have provided contains a project saved by a newer kicad. For some reason I cannot install from the kicad ppa, and did not yet got the strength to compile it from source too.
I did try every kind of combination of timestep and final time, and I did add a textbox with the spice options you provided (maybe in kicad 7.10 they are not read?).
I get this as the error message:
doAnalyses: TRAN: Timestep too small; time = 2.33051e-05, timestep = 1.25e-18: trouble with node "v.xic-1.v_u1_v2#branch"
run simulation(s) aborted
I feel like I am overlooking something obvious.
Now I cannot reproduce the working state, I get the original error.
I checked that the ngspice source contains the patch. Now compiling it again and will reinstall the whole thing to make sure the right version is on the system.
I also cannot open the project you provided, because any version I try (I hand-installed at least three versions from the ppa, as apt refuses to install them. First it said there is no Release file, then it does not seem to find the Packages file for the repo), all of them says that the file was saved by a newer one.
I have been using KiCad 8, today’s nightly on MS Windows. ngspice-42 is bundled with this version. I am regularily updating, as I closely accompany the KiCad development.
What is your operating system and version of KiCad and ngspice?
Here I have your project, modified, running with KiCad 7.0.10, ngspice-41, without using the ngspice patch. DCDC_KiCad7.7z (21.9 KB)
I have tried the project you provided, on the kicad version above.
I am pretty sure I have the patched libngspice0 library installed. I have created it by downloading the debianized source for ngspice_42+ds-2, overwrite the source with the pre-master-43 branch of https://git.code.sf.net/p/ngspice/ngspice, disabling the patches came with the debian source (apparently some documentation fixups), and running debuild on it. I have checked that the source indeed contains the patch you have provided here.
But in simulation using the project you have just provided, and the workbook contained in it, I get the error below. Which is strange, because I did have a state where the simulation did start, and later had some errors most probably because of bad parameters/schema in my part. I cannot reproduce that state though.
I will try the version of the project for the newer kicad as soon as I will have it compiled.
Background thread stopped with timeout = 0
Note: Compatibility modes selected: ps a
Circuit: KiCad schematic
Error on line:
a.xic_1.x_u4_s4.as_u4_s4 %gd xic_1.clk probe_int_net-_ic_1-en/uvlo__xic_1_1 %gd xic_1.u4_n16854848 xic_1.u4_n16855005 xic_1.x_u4_s4:a_u4_s4
MIF-ERROR - unable to find definition of model xic_1.x_u4_s4:a_u4_s4
Error: circuit not parsed.
I have compiled and installed kicad from the master branch, and made sure again that I have ngspice with the patch. Now the simulation works, and it indeed shows 2.7 Volt. Which is my problem now…
I tried to rename IC_1 back to IC-1, and it works as well.
Thank you for the very responsive help with all of this.