Kicad NGSpice - Pls check my 741 OpAmp Simulation

I would start by using a sine wave as input for the amplifier. That gives much more confidence it works then a DC signal.

Can you zip and upload that project? then I’ll have a look at it. For me it’s a method to get to know ngSpice in KiCad a little bit better.

paulvdh,
I’ve attached the project as you asked but I went ahead and modified the signal source to AC.
Sorry, it is in v6.99. Let me me know if that is a problem and I’ll do it over in v6.0.

I setup the AC signal source for …
0v DC offset
1v Amplitude
1k Frequency
blank Delay
blank Damping Factor

When I run the simulation looking at the Input, and the Output I see a sine wave …
Input 1v peak, 2v peak to peak AC
Output 2v peak, 4v peak to peak AC

However when I run the simulation I also see this …
Warning: v3: no DC value, transient time 0 value used

Should I ignore the warning or do I have somethin setup incorrectly?

Thanks for the help.
741 Op Amp Ckt AC.zip (31.0 KB)

It was something to do with new graphics’ capabilities introduced in 6.99.
I remember mentioning 6.99, with all the appropriate warnings, of course. :slightly_smiling_face:

jmk, yes, I think that was it … new graphics’ capabilities introduced in 6.99.
Any idea when the next stable release may occur?
Thanks.

It’s purported to be an annual occasion, which means next January, maybe, but don’t hold your breath!

I’d better let you get back to your “Spicy” thread. :slightly_smiling_face:

Edit:
This post should probably be ignored.
It’s quite long and contains too many inaccuracies and faults.
I almost deleted it completely myself.

---- 8<------- 8<------- 8<------- 8<------- 8<------- 8<------- 8<------- 8<------- 8<—

So I installed KiCad:

6.99.0-unknown-ea29c66608~148~ubuntu20.04.1

First trouble was it could not find your model for the LM741, so I changed the path name to:
image

Then I changed V3 from an “amplitude modulated source”, to a sine wave source, and added a “dc 0”.

image

changing the source itself does not matter much for spice because it just get’s it’s parameter inputs from the text strings.

And I added a text window in the schematic for which spice analysis to run:
.tran 1u 10m

After that I get the simulation output below. It’s almost a DC voltage at -13.9V

I do not know how to skip some pis in the “alternate node sequence”, and to circumvent that I changed the library symbol of your LM741 with the “Simulation_Spice/Opamp” library symbol, so I do not have to mess with the offset adjustment pin numbers.
image

And I changed the alternate node sequence to what I think it should be:

After that the simulation stopped working completely. The simulation output only says:

Error: there is no circuit loaded.
Circuit: KiCad schematic
Too few parameters for subcircuit type “lm741” (instance: xxu1)
Error: there aren’t any circuits loaded.

Now I’ve got a nice sinewave output 1.6V above the power supply voltage:
image

And still a bunch of spice error messages:

Error: there is no circuit loaded.
Circuit: KiCad schematic
Error on line 0 :
a$poly$e.xu1.eos %vd [ xu1.16 xu1.49 ] %vd ( xu1.7 0 ) a$poly$e.xu1.eos
MIF-ERROR - unable to find definition of model a$poly$e.xu1.eos
Warning: Model issue on line 0 :
.model a$poly$e.xu1.eos spice2poly coef = [ 1e-3 1 ] …
Unknown model type spice2poly - ignored
Error on line 0 :
a$poly$f.xu1.f6 %vnam [ v.xu1.v6 ] %id ( /+vcc /output ) a$poly$f.xu1.f6
MIF-ERROR - unable to find definition of model a$poly$f.xu1.f6
Warning: Model issue on line 0 :
.model a$poly$f.xu1.f6 spice2poly coef = [ 450u 1 ] …
Unknown model type spice2poly - ignored
Reducing trtol to 1 for xspice ‘A’ devices
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

I did a search for “spice2poly” and found:

Which helps me nothing.
And after having spend more then an hour on this I give up.
For what it’s worth, my end result:

741 Op Amp Ckt AC_2022-05-24.zip (28.7 KB)

do you hear something? Something like a faint whisper saying, “LTSpice…LTSpice…LTSpice…never a problem…” :wink:

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