Failedl DC Simulation of LM317 regulator

I’m trying to verify the operation of an LM317 as a current limiter in a test circuit (project attached). The screenshot shows that the DC operating point simulation failed. Could someone please advise me on these possible issues, or make other suggestions?

  1. The TI Spice model is listed as a “Transient” type. Will this work also for DC operating point simulation?

  2. Do I need to play with the NgSpice DC simulation parameters to achieve convergence (perhaps including one or more discussed in the link below? Can these convergence parameters be accessed directly within the KiCad simulation environment, or do I need to add text directives manually?

Overcoming SPICE Convergence Issues

LM317.zip (422.0 KB)

Thank you very much!

TBH, I’ve never used DC analysis in ngspice, the transient simulation tells me all I need to know plus more.

Inspect–>Simulator–>Edit Analysis tab (for DC)–>uncheck Save all currents, Save all power dissipations

That works, thanks. I can calculate the currents from various voltage measurements, but the current probe function would be convenient. Does that work in DC operating point mode? I saw a wire being highlighted turn pink when clicked on, but no numeric values. I also tried running a DC sweep, however nothing showed up in the plot window, the results pane looked like that seen below.

There is a bug in the LM317 model from TI.

Line 35 currently is
.SUBCKT LM317_TRANS IN ADJ OUT_0 OUT_1
that is a subcircuit with 4 nodes. OUT_1 however is connected to nothing inside of the subcircuit. This creates a problem during current or power measurement as this node will be floating.The correct line should read
.SUBCKT LM317_TRANS IN ADJ OUT_0

Another option is to connect each node to ground via a large resistor (so not disturbing the signals of interest), by putting
.options rshunt=1e15
in a text box onto the Eeschema canvas.

1 Like

I do not understand this:

I agree that a subcircuit for an LM317 probably should not have 4 nodes, but I don’t understand why ngSpice chokes on this. Unconnected nodes have no current. It does not seem difficult (in my limited view) to handle them appropriately. I’ve read numerous posts of having to add 100 GOhm resistors just to get around problems with running an ngSpice simulation. It’s one of the pitfalls that make it difficult to get started with ngSpice. And I assume Ti has tested their own models, so apparently their simulator can handle this, maybe it just ignores singular nodes (is that the right term?) Maybe it does something more intelligent with them, but a simulation getting stuck on this is probably not the optimal decision.

As far as I know ngSpice is built more around “theoretical correctness” (no floating nodes). and other simulators are more into the practical choice (floating node can have a voltage but no current), so that engineers can get going with getting the job at hand done.

Out1 in this case is the large tab connected to Out0 internally (for heat sinking) for this regulator. I happened to choose a symbol that doesn’t include this tab as an electrically separate pin, whereas TI’s data sheet does, so deleting the Out1 node in the model makes sense for applying to the symbol I chose. It seems that I could have used the original Spice model had I created a custom symbol (and footprint) that included the explicit 4th pin.

Anyway, everything works now, including re-enabling the Save All Currents option. For the DC Sweep plot, I had simply overlooked selecting the check boxes to show the traces.

Thanks for all the suggestions!

My post definitely is not the solution to your original post.
I changed this to Holgers post, as apparently that extra pin in the simulation was indeed the problem.

This solution thing is meant to guide people who search the forum to answers quicker. My post was more extra / background concerns and ideas.

Yes, I didn’t catch that the Solution button is intended to be post-specific.