Too few parameters for subcircuit type "foo" (instance: xxbar)

Hi

I have been playing around with the circuit simulator in eeschema, but am struggling to figure out how to fix the subcircuit with the voltage reference on U1.

It looks like there is something on the imported pspice models that ngspice does not interpret correcly. I did set the alternative pin mapping manually, although I am not sure I got it right.

This seems like a similar error to what was proposed as fix in KiCAD netlist wrong wrt ngspice AD8001 by @holger, but I am not sure if I need to modify the model or I am just misunderstanding how to use the models.

Too few parameters for subcircuit type "lm385-adj_trans" (instance: xxu1)
Error: there aren't any circuits loaded.

I only noticed the error about no circuits loaded, on a second review of the problem, but I guess that is caused by the too few parameters issue.

The design can be fetched from https://github.com/nickoe/msoon_ovp/tree/00a25dee6619a23247b125d153a81bbf2cbbca3b

I am using 5.1.7-1-gca8f026bc with ngspice-git r6966.0ca66abd3-1

The root problem is that the Eeschema to SPICE netlist parser trims off floating nodes. This is the same reason why you need to add a dummy high-Z load resistor if you want to probe the voltage output of an opamp that doesn’t have a feedback resistor.

Anyway, in your specific case you’re attempting to map the extra unused pins of the SOIC8 to the model’s NC pins via the alternating node sequence. The model/subcircuit provides you with pins (NC_x) to do this along with dummy 1meg load resistors connected to each of those pins (the R_NCx’s at the beginnning of the .subckt). However, Eeschema is trimming your extra connections (1, 2, 3, 6, 7) because they don’t exist on the schematic and then SPICE is yelling at you for not matching the node count of the subcircuit…even though that’s exactly what you were attempting to do!

There are a couple ways to solve this:
1.) Edit the model such that the extra pins aren’t even part of the model anymore and it matches the schematic node count exactly. This includes removing the NC_x on the subckt line along with those 5x 1meg dummy resistors.
2.) Attach one (or more) of the real symbol pins to the dummy pins. I prefer using things connected to the GND node when you can, so in your case:
4 5 8 4 4 4 4 4
3.) Ideally, Eeschema should not be doing this sort of trimming, so if this can be fixed then your project should work as-is. But for the record, I think it’s better to use node 0 to fill out any dummy pins, so like this:
4 5 8 0 0 0 0 0

1 Like

There is also this thread https://e2e.ti.com/support/power-management/f/196/t/831066 which reports the TI model of the lm385-adj to be buggy.

1 Like

@Ste Thank you very much for the detailed explanations.

If I try 4 5 8 0 0 0 0 0 I get this error

Too few parameters for subcircuit type "lm385-adj_trans" (instance: xxu1)
Background thread stopped with timeout = 0
Error: circuit not parsed.

If I try 4 5 8 4 4 4 4 4 I get:

Circuit: KiCad schematic
Error: no such function 'if'
Error on line 0 :
r.xu1.r_r18 0 xu1.n16955548 1 tc=0,0
unknown parameter (0) 
Background thread stopped with timeout = 0
Error: circuit not parsed.

@holger Thank you for the heads up about the model defect.

My goal is just to simulate a crowbar circuit with a programmable voltage reference, I don’t mind it being not the exact same models. I wonder where I can find alternative models or how exactly I can fix the current ones. I have not yet tried the model for the ATL431LI.

EDIT: I tried with the average model for the ATL431LI and it fails with similar errors as the 4’s dummy, but there the ports for the device do not specify any no connects and hence I don’t have the extraneous 4’s.

This may occur if the PSPICE compatibility flag is not set. Please have a look at http://ngspice.sourceforge.net/ngspice-eeschema.html#setting

2 Likes

You misunderstood me. You cannot try 4 5 8 0 0 0 0 until the Eeschema parsing thing I mentioned gets changed in a future update or something like that. 4 5 8 4 4 4 4 will simulate with the current release after you set the PSPICE compatibility flag @holger mentioned.

1 Like

Ok, with the pspice compatibility flag set and the pin sequence as described by Ste then it plots stuff.

Thank you both @Ste and @holger.

Considering the fact that people simulating with KiCad/Eeschema will typically use PSPICE models, it might be feasible that Eeschema directly sends this flag to ngspice (right after initializing ngspice, before any circuit is loaded) as a command ‘set ngbehavior=ps’. Then all models entered as a subcircuit will get a special compatibility treatment within ngspice.

10000% agreed. But is there any downside to using set ngbehavior=ltps instead? Giving every KiCad user instant access to that simple diode model would help with some of the subcircuits I’m working on for public release.

@holger @Ste Lets move the discussion about the ngbehavior on to a gitlab issue