New to SPICE, errors simulating LM3886

Hi there,


I'm very new to SPICE simulation.


I'm getting this when trying to simulate my circuit in KiCad:


Code:
warning, can't find model -v
warning, can't find model zf16v
warning, can't find model -v
Circuit: KiCad schematic
Error on line 3 :
u1 +v nc_01 out -v +v nc_02 powerground net-_d3-pad1_ net-_cf1-pad1_ net-_cc1-pad1_ nc_03 lm3886
Unable to find definition of model -v - default assumed
unknown parameter (+v) 
Error on line 13 :
jout1 out_t speakerground conn_01x03
Unable to find definition of model  - default assumed
Error on line 18 :
d3 net-_d3-pad1_ net-_cm1-pad2_ zf16v
Unable to find definition of model zf16v - default assumed
Error on line 27 :
joutsingle1 out powerground conn_01x03
Unable to find definition of model  - default assumed
Error on line 29 :
jinput2 in+ signalground conn_01x02
Unable to find definition of model  - default assumed
Error on line 30 :
jpower1 +v speakerground powerground -v conn_01x04
Unable to find definition of model -v - default assumed
unknown parameter (conn_01x04) 
Background thread stopped with timeout = 0
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Fatal error: tp_in_gnd1: transmission line z0 must be given
doAnalyses: no such parameter on this device
run simulation(s) aborted
I'm not sure if I can safely ignore the warnings for the connectors.
The Zener diode model might be relevant, as it's connected to pin 8 of the LM3886 (U1).


Really not sure what the -v model warnings are about. I've got a VEE component added, and global label of "-V" to make connections easier.


Anyone able to shed some pointers for me please?
 

Attachments

  • Screenshot_20210408_141941.png
    Screenshot_20210408_141941.png
    35.6 KB · Views: 331
The issue I found with KiCad is the netlist is quite spartan and I'm not sure how you add things to it (I suppose through the spice options on the devices). I don't know if Kicad then provides an interactive way of exploring - I didn't get that far.

I find LTspice more interactively useable for sim but then you're cut and pasting between the two.. given you can export from LTspice and import into kicad.
 
A line like

jout1 out_t speakerground conn_01x03

specifies a j, that is a junction field effect transistor in SPICE syntax, with the drain connected to node out_t, the gate to node speakerground and the source connected to node conn_01x03 and with no JFET model name. Hence, SPICE doesn't know what type of JFET to connect to nodes out_t, speakerground and conn_01x03.

Similarly, in SPICE syntax,

jpower1 +v speakerground powerground -v conn_01x04

is a JFET called jpower1 of type -v connected between nodes +v, speakerground and powerground. It has an extra parameter conn_01x04, which probably gets interpreted as a multiplication factor.

All in all, the problem is that KiCad syntax isn't SPICE syntax.
 
Last edited:
I'm more of an LTspice person, but I noticed you have PWR_FLAG connected to both Vee and Vcc. That means they are connected, right? Probably not what you want.
I also think you should add a speaker load for realistic results.

Jan


Ouch. I'll check that. I added the PWR_FLAG items because the Electrical Rules Check said nothing was sourcing power into the LM3886 pins.


I'll add a speaker load, but it now says: warning, can't find model speaker
 
A line like

jout1 out_t speakerground conn_01x03

specifies a j, that is a junction field effect transistor in SPICE syntax, with the drain connected to node out_t, the gate to node speakerground and the source connected to node conn_01x03 and with no JFET model name. Hence, SPICE doesn't know what type of JFET to connect to nodes out_t, speakerground and conn_01x03.

Similarly, in SPICE syntax,

jpower1 +v speakerground powerground -v conn_01x04

is a JFET called jpower1 of type -v connected between nodes +v, speakerground and powerground. It has an extra parameter conn_01x04, which probably gets interpreted as a multiplication factor.

All in all, the problem is that KiCad syntax isn't SPICE syntax.


Perhaps I need to post on a KiCad mailing list.


jpower1 is actually a connector, same as jout1. Definitely not a JFET.


I'll try renaming the annotations for the connectors and see what happens.
 
In some SPICE versions, U is a uniform RC line with two ends and a common node, so

u1 +v nc_01 out -v +v nc_02 powerground net-_d3-pad1_ net-_cf1-pad1_ net-_cc1-pad1_ nc_03 lm3886

is a uniform RC line called u1 connected between points +v and nc_01, with common node out, model -v and a whole bunch of extra parameters.

tp_in_gnd1 specifies a losless transmission line.

On top of that, there are no commands telling SPICE what analyses to run.
 
Perhaps I need to post on a KiCad mailing list.


jpower1 is actually a connector, same as jout1. Definitely not a JFET.


I'll try renaming the annotations for the connectors and see what happens.


I understand that, but SPICE doesn't. In SPICE syntax, the first letter indicates what kind of component it is, and J stands for JFET. The LM3886 itself would have to be called Xsomething to be understood by SPICE, as X stands for subcircuit.

You probably have to get rid of the connectors, or change them into X's and define an empty subcircuit for them. Basically you are then hacking your KiCad circuit to get something out that looks like a SPICE netlist, it would be nice if there were some more convenient way to do it. You could decide to use LTSpice's schematic entry for simulation and KiCad for PCB layout, but then you need to keep two schematics consistent with each other.
 
Last edited:
Texas Instruments has their version of PSpice freely available and you can use their LM3886 model -- TINA can also use the encrypted TI model.
LM3886 model does not run in PSpice for TI, returning in my case "ERROR(ORPSIM-15142): Node X_U1.11 is floating". I reported the error in January, they confirmed it, but the model apparently hasn't been corrected yet (I checked it 15 minutes ago, and all model files are still dated 2017).


Regards,
Braca
 
Attached you will find a working example for KiCad 6.0.1.

You will need a fresh download of the TI model LM3886.lib.

And you will need to set in Eeschema
Inspect -> Simulator -> Sim Parameters -> Compatibility Mode PSPICE and LTSPICE

Then the simulation should run.
 

Attachments

To the message by the OP:

line u1 +v nc_01... does show that the model of the LM3886 has not been attached correctly.

Lines jout1 out_t... and others starting with j do show, as already has been said, that ngspice tries to establish a device instance. Unfortunately device instances starting with j are JFETs. We do not have JFETs. And nobody wants to simulate a connector. To get rid of these error, one has to do the following:
Eeschema -> double click onto the connector symbol -> Symbol Properties show up, edit line Spice_netlist_Enabled -> N (instead of Y).

Line d3 net-d3-pad1 again does show that the diode model has not been attached correctly.

One might ask: Why is this so complicated, compared to other simulators? Compared to plain simulators, KiCAD/Eeschema/ngspice are part of a PCB design tool which primarily has to serve the board designers. Thus we have connectors and maybe other items we do not want to simulate. KiCad does not offer ngspice simulation models. So the user has to care for them, for example search for them at http://ngspice.sourceforge.net/modelparams.html .