Kicad NGSpice - Pls check my 741 OpAmp Simulation

I quick look I just thought that Insheet simulation graph (lp:#1740318) (#2090) · Issues · KiCad / KiCad Source Code / kicad · GitLab had started the implementation.

If you do it in LTSpice do you select the LTSpice libraries and models in kicad or do you leave this assignment open and assign it later over at LTSPice?

Have Not tried to use LTSpice’s parts/lib’s/etc in Kicad schematics… that would be another problem to solve… Perhaps, fun, though…

I prefer simplicity so, I approach it like this:

• If I’m not going to build a PCB and only want to simulate something (perhaps for analysis, curiosity… other) I use LTSpice and draw the circuit in LTSpice

• If I am building a PCB and want to simulate it, I do the circuit in LTSpice if the circuit is simple and quick

• If I am building a PCB and want to simulate it, I do the circuit in Kicad if the circuit is not simple or quick

Not being an Expert and, having been born at end the 1940’s pushes me to ‘simple-minded’ thinking so, I say to myself, “why waste time (I don’t much of it left), just do the job and move on”

And, being a Musician, I find myself messing with (audio) Stomp-Box design and find running LTSpice useful because I can simulate circuit (with various filters/etc) using real Audio Wave files. Some folks have success doing that in NGspice (after much trouble) but, I got it to work only once! However, LTSPice always works with NO Fussing…

(An ‘aside’ note: I just upgrade my Mac and Kicad and now, can not run LTSpice directly from Kicad. But, the process of using Kicad’s Netlist in LTSpice still works :grinning: )

Try this with Kicad/NGspice (it took 30 seconds to make this circuit and run it, using LTSpice)

You may ingnore this warning. I will remove it for the next release (ngspice-38).

1 Like

Again: With a properly installed KiCad/ngspice the zip file from Fran_iii runs out of the box (I am using MS Windows). I do not know if the packager for Ubuntu has done his job correctly.

Indeed standard ngspice does not support reading wav files.

There is a special version of ngspice-32 I have made some time ago which does read, manipulate and write wav files. It is available for download (MS Windows only) at Ngspice, the open source Spice circuit simulator - Downloads (ngspice nightly and others). There has not been much interest in this project, so I did not pursue it any further (e.g. making this a standard option).

Unfortunately this is not correct.

ngspice (other simulators as well) need a proper pin sequence. This is necessary because the spice model pin sequence does typically not match the Eeschema sequence. The Eeschema pin sequence is dictated by the footprint. A simulator does not have any notion of ‘footprint’. So a translation is required.

The model with its .subckt line tells us what sequence of its 5 pins is required: non-inv, inv, V+, V-, out.

The U1 symbol has these pin (listed in the proper sequence) as 1 2 4 5 3.

And that’s the alternate node sequence for your symbol.

It tells Eeschema to place the symbol’s pins (using their autogenerated or given net names) with the correct sequence when calling the 741 subcircuit.

You have given pin numbers 28 99 50 that do not exist in the circuit, so there are no connected nets. Then they are ignored, and Eeschema sends only the net names of 2 valid pins (pins 1 and 2) to ngspice, and of course that does not match with the five pins required.

I thank you and the many others for the work/contribution to software. And, though I do occasionally use ‘Open-Source’ ware, I try to avoid it like the plague and prefer to $Pay for software that has a more refined Quality Control/Assurance aspect to the company/organization.

(My NGspice is v36)

EDIT: Now, I remember this post and perhaps I got to run then…

At least an interesting statement in the KiCad forum.

A little bit about quality checks for ngspice is found here: Ngspice, the open source Spice circuit simulator - Tests and quality assurance

1 Like

Thank you. I read through it (didn’t download the tests).

Following up on my mention of

I fixed it so LTSpice now runs from Kicad. A bit of a Repeat for those interested:

  1. Build your circuit in Kicad
  2. File>Export>Netlist [fill in the ‘External simulator command’ field]
  3. Click ‘Create Netlist and Run Simulator Command’
  4. Add .CIR extension to the filename (replace .NET with .CIR)
    LTSpice will Open
  5. Locate the netlist file .CIR
  6. Run (add/select what you want to plot)

If Kicad doesn’t have the desired spice model and you can’t download one, You can use an LTSpice model - click the Spice Model button in the Kicad panel for the widget of interest and select ‘Model’ tab and locate the desired LTSpice file (a bazillion of them to choose from). The last screenshot

Screenshot of the Export Netlist panel

Screenshot of the Kicad circuit

LTSpice Model in Kicad’s panel

We release new KiCad versions according to our policy at Stable Release Policy | Developer Documentation | KiCad.

1 Like

The last screenshot is incorrect. You have selected a symbol in LTspice’s proprietary symbol format. You want to look in the sub directory, not the sym directory.

Also, be careful with importing from the sub directory for use in ngspice. Any model that’s either encrypted or includes LTspice’s proprietary “A-devices” will fail to run in ngspice or any other SPICE.

1 Like

Yes, I know that. The purpose was Only to show example of loading an LTspice model (was not important to me to select a 741 or the correct panel-field for it).

That said, for me, there is No reason to select an LTspice model as I can select LM741 in Kicad (because I downloaded one a few year ago and it still works. Screenshot below - NOTE, I did not set parameters/etc for this - it too is simply an example. But, I did sketch the circuit Approximately similar to OP’s original)

[EDIT Replaced image with Cap deleted to Avoid further comment…]


But you didn’t select a model at all. You selected a symbol (ASY file). It’s confusing to other viewers of this thread, which is why it was pointed out. This is what you meant to show:

1 Like

Yes, but, again, my intent was/is Not to detail/Hand-Hold. Rather, simply to ‘suggest’ elements of ‘curious interest’ for a user to explore and solve the problem(s) themselves.

When teaching in college, seldom would I hold someone’s hand, figuring one of the most important aspects of a successful engineer is Exploring Curiosity to forge Neural connections for Problem solving.

Later-on as Director of Engineering for several companies, I discovered far too many engineers did not belong in Engineering. I quickly transferred them to Quality Assurance where they realized, for themselves, engineering was not the profession for them.

A few years ago I interviewed a handful of Medical Doctors, only to, again realize many folks choose a profession for Glory/Money…

But, different strokes for different folks…

Cool story, but irrelevant. If you post more erroneous information, I will continue to correct it. Thanks.

2 Likes

The PC version of LTspice works very well under Wine on both Linux and macOS.

There is also a macOS native version of LTspice.