Author Topic: Error when running KiCad opamp spice simulation  (Read 5567 times)

0 Members and 1 Guest are viewing this topic.

Offline GreyAreaTopic starter

  • Contributor
  • Posts: 39
  • Country: gb
Error when running KiCad opamp spice simulation
« on: August 23, 2020, 12:14:54 pm »
Hello, I have a need to use an op-amp in a project which I've never used before so I'm trying to run some spice models to help me understand what's going on.

I've based my attempt around the following links
http://ngspice.sourceforge.net/ngspice-eeschema.html#OpAmp
"Non-Inverting op-amp gain" here https://www.electronics-notes.com/articles/analogue_circuits/operational-amplifier-op-amp/gain-equations.php

I've used the opamp model in the pspice library but when I run the simulation I get a coupld of errors:

Code: [Select]
warning, can't find model nc_01
Circuit: KiCad schematic
Error on line 5 :
u1 in net-_r1-pad1_ output nc_01 vm opamp
Unable to find definition of model nc_01 - default assumed
unknown parameter (vm)
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
 Reference value :  1.00000e+02
No. of Data Rows : 41

I'm not sure how to correct these errors - I tried removed the VH voltage source and copying it from the VM source, as it's doesn't seem to error on that one - but I can't see what the difference is.

Thanks.
 

Offline thinkfat

  • Supporter
  • ****
  • Posts: 2150
  • Country: de
  • This is just a hobby I spend too much time on.
    • Matthias' Hackerstübchen
Re: Error when running KiCad opamp spice simulation
« Reply #1 on: August 23, 2020, 12:26:44 pm »
if you look into the ngspice netlist, it needs to read X1 (because the opamp model is a subcircuit, likely). You may need to edit the simulation related properties of U1 to make sure the netlist is exported correctly to ngspice.
Everybody likes gadgets. Until they try to make them.
 

Offline bson

  • Supporter
  • ****
  • Posts: 2265
  • Country: us
Re: Error when running KiCad opamp spice simulation
« Reply #2 on: August 23, 2020, 06:33:23 pm »
Your power global label is VH while the opamp expects VP.  The VM and VP labels on the op amp are also "inputs".  In fact, all your global labels are "inputs".

Use power nodes for power, not labels.
The P key places a power node.

Here's an example of a simulation in KiCad.



Note the canonical split supply drawing with ground in the middle.
The use of power nodes for power.
The direction of the global labels.

You also have some weird green circles near your ground power nodes.  Not sure what that is...  But the error at net-_r1_pad1_ might suggest it's not connected.

And, as noted, call the opamps "X?" rather than "U?".  You CAN make it work, but it's just very fiddly.  (My schematic above is output by a filter synthesizer, which writes KiCad files directly, but it would be a bit fiddly and error prone to do manually through the UI.)
« Last Edit: August 23, 2020, 06:46:03 pm by bson »
 

Offline GreyAreaTopic starter

  • Contributor
  • Posts: 39
  • Country: gb
Re: Error when running KiCad opamp spice simulation
« Reply #3 on: August 23, 2020, 08:31:51 pm »
Ah thanks - I had given up and used LTSpice instead - I like using the KiCad interface though so I'll give it another go with your tips, thanks again.

The weird green circles are zeroes, they are drawn by default when I choose a ground from the pspice library in KiCad 5.1.6.  Looking at your screenshots you don't have them.  Maybe a different version?
 

Offline hvogt

  • Newbie
  • Posts: 9
  • Country: de
Re: Error when running KiCad opamp spice simulation
« Reply #4 on: March 16, 2022, 09:19:20 pm »
There is no ngspice OpAmp model attached to the OpAmp symbol. So the simulator does not know what to simulate. The tutorial at http://ngspice.sourceforge.net/ngspice-eeschema.html#OpAmp will tell you what to do.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf