Node names (Net-_c1-pad1..) cause simulator syntax error for .IC or .NODESET

Hi,
While trying to diagnose a convergance issue with ngspice in Kicad 5.0.2 on a simple 555 circuit model, I couldn’t figure out how to add .IC or .NODESET commands to the simulation without causing a syntax error. The following (in a text annotation in eescheema) doesn’t work:

.ic V(Net-C2-Pad1)=0

It causes a syntax error in the simulator:

Warning : IC on non-existant node - net
Error on line 23 :
.ic v( net-_c1-pad1_ )=0
Error: .ic syntax error.

It seems like ngspice does not like the ‘-’ in the node names that Kicad generates, at least for IC/NODESET. Anyone have suggestions or run into this issue?
Thanks,
Josh

Below is the ngspice netlist for the circuit:

.title KiCad schematic
.include "/home/tuser/bike-light/TLC555ng.LIB"
XU1 GND Net-_C2-Pad1_ Net-_R1-Pad2_ Net-_R2-Pad1_ Net-_C1-Pad1_ Net-_C2-Pad1_ Net-_R2-Pad2_ Net-_R2-Pad1_ TLC555
C2 Net-_C2-Pad1_ GND 1u
V1 Net-_R2-Pad1_ GND DC 5
C1 Net-_C1-Pad1_ GND 0.01u
R2 Net-_R2-Pad1_ Net-_R2-Pad2_ 20k
R3 Net-_R2-Pad2_ Net-_C2-Pad1_ 20k
R1 GND Net-_R1-Pad2_ 10meg
.save @c2[i]
.save @v1[i]
.save @c1[i]
.save @r2[i]
.save @r3[i]
.save @r1[i]
.save V(GND)
.save V(Net-_C1-Pad1_)
.save V(Net-_C2-Pad1_)
.save V(Net-_R1-Pad2_)
.save V(Net-_R2-Pad1_)
.save V(Net-_R2-Pad2_)
.ic V("Net-_C1-Pad1_")=0
.ic V(Net-_C2-Pad1_)=0
.tran 100u 100ms 0 uic
.end

And the Eescheema schematic is:

EESchema Schematic File Version 4
LIBS:throb-cache
EELAYER 26 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title ""
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L Timer:LM555 U1
U 1 1 5C33A2D9
P 5250 2800
F 0 "U1" H 5400 3250 50  0000 C CNN
F 1 "LM555" H 5450 3150 50  0000 C CNN
F 2 "" H 5250 2800 50  0001 C CNN
F 3 "http://www.ti.com/lit/ds/symlink/lm555.pdf" H 5250 2800 50  0001 C CNN
F 4 "X" H 5250 2800 50  0001 C CNN "Spice_Primitive"
F 5 "TLC555" H 5250 2800 50  0001 C CNN "Spice_Model"
F 6 "Y" H 5250 2800 50  0001 C CNN "Spice_Netlist_Enabled"
F 7 "/home/tuser/bike-light/TLC555ng.LIB" H 5250 2800 50  0001 C CNN "Spice_Lib_File"
	1    5250 2800
	1    0    0    -1  
$EndComp
$Comp
L Device:C C2
U 1 1 5C33A5D9
P 6000 3150
F 0 "C2" H 6115 3196 50  0000 L CNN
F 1 "1u" H 6115 3105 50  0000 L CNN
F 2 "" H 6038 3000 50  0001 C CNN
F 3 "~" H 6000 3150 50  0001 C CNN
	1    6000 3150
	1    0    0    -1  
$EndComp
$Comp
L power:GND #PWR05
U 1 1 5C33A71F
P 5250 3400
F 0 "#PWR05" H 5250 3150 50  0001 C CNN
F 1 "GND" H 5255 3227 50  0000 C CNN
F 2 "" H 5250 3400 50  0001 C CNN
F 3 "" H 5250 3400 50  0001 C CNN
	1    5250 3400
	1    0    0    -1  
$EndComp
Wire Wire Line
	5250 2400 5250 2000
Wire Wire Line
	5750 3000 5900 3000
Wire Wire Line
	4750 2600 4750 2100
Wire Wire Line
	4750 2100 5900 2100
Connection ~ 5900 3000
Wire Wire Line
	5900 3000 6000 3000
Wire Wire Line
	4750 3000 4600 3000
Wire Wire Line
	4600 3000 4600 2000
Wire Wire Line
	4600 2000 5250 2000
Connection ~ 5250 2000
$Comp
L Device:Battery_Cell V1
U 1 1 5C33FE82
P 4250 2150
F 0 "V1" H 4368 2246 50  0000 L CNN
F 1 "DC 5" H 4368 2155 50  0000 L CNN
F 2 "" V 4250 2210 50  0001 C CNN
F 3 "~" V 4250 2210 50  0001 C CNN
	1    4250 2150
	1    0    0    -1  
$EndComp
$Comp
L Device:C C1
U 1 1 5C340222
P 4300 3000
F 0 "C1" H 4415 3046 50  0000 L CNN
F 1 "0.01u" H 4415 2955 50  0000 L CNN
F 2 "" H 4338 2850 50  0001 C CNN
F 3 "~" H 4300 3000 50  0001 C CNN
	1    4300 3000
	1    0    0    -1  
$EndComp
$Comp
L power:GND #PWR03
U 1 1 5C34024A
P 4300 3250
F 0 "#PWR03" H 4300 3000 50  0001 C CNN
F 1 "GND" H 4305 3077 50  0000 C CNN
F 2 "" H 4300 3250 50  0001 C CNN
F 3 "" H 4300 3250 50  0001 C CNN
	1    4300 3250
	1    0    0    -1  
$EndComp
Wire Wire Line
	4300 3150 4300 3250
Wire Wire Line
	4750 2800 4300 2800
Wire Wire Line
	4300 2800 4300 2850
Wire Wire Line
	5900 2100 5900 3000
$Comp
L Device:R R2
U 1 1 5C340851
P 6650 2900
F 0 "R2" H 6720 2946 50  0000 L CNN
F 1 "20k" H 6720 2855 50  0000 L CNN
F 2 "" V 6580 2900 50  0001 C CNN
F 3 "~" H 6650 2900 50  0001 C CNN
	1    6650 2900
	1    0    0    -1  
$EndComp
$Comp
L Device:R R3
U 1 1 5C34088B
P 6650 3300
F 0 "R3" H 6720 3346 50  0000 L CNN
F 1 "20k" H 6720 3255 50  0000 L CNN
F 2 "" V 6580 3300 50  0001 C CNN
F 3 "~" H 6650 3300 50  0001 C CNN
	1    6650 3300
	1    0    0    -1  
$EndComp
Wire Wire Line
	6650 3450 6400 3450
Wire Wire Line
	6400 3450 6400 3000
Wire Wire Line
	6400 3000 6000 3000
Connection ~ 6000 3000
Wire Wire Line
	6650 3150 6650 3100
Wire Wire Line
	5750 2800 6500 2800
Wire Wire Line
	6500 2800 6500 3100
Wire Wire Line
	6500 3100 6650 3100
Connection ~ 6650 3100
Wire Wire Line
	6650 3100 6650 3050
Text Notes 5500 1700 0    50   ~ 0
* .nodeset V(Net-_C1-Pad1_)=0\n* .nodeset V(Net-_C2-Pad1_)=0\n.ic V("Net-_C1-Pad1_")=0\n.ic V(Net-_C2-Pad1_)=0\n.tran 100u 100ms 0 uic
Wire Wire Line
	5250 3200 5250 3300
Wire Wire Line
	6000 3300 5250 3300
Connection ~ 5250 3300
Wire Wire Line
	5250 3300 5250 3400
Wire Wire Line
	4250 1800 4250 1950
Wire Wire Line
	6650 2650 6650 2750
$Comp
L power:GND #PWR0103
U 1 1 5C34D88C
P 4250 2400
F 0 "#PWR0103" H 4250 2150 50  0001 C CNN
F 1 "GND" H 4255 2227 50  0000 C CNN
F 2 "" H 4250 2400 50  0001 C CNN
F 3 "" H 4250 2400 50  0001 C CNN
	1    4250 2400
	1    0    0    -1  
$EndComp
Wire Wire Line
	4250 2250 4250 2400
Wire Wire Line
	4250 1800 5250 1800
Wire Wire Line
	5250 1800 5250 2000
Wire Wire Line
	6900 1800 6900 2650
Wire Wire Line
	6900 2650 6650 2650
Connection ~ 5250 1800
Wire Wire Line
	5250 1800 6900 1800
$Comp
L Device:R R1
U 1 1 5C3FA383
P 6200 2450
F 0 "R1" H 6270 2496 50  0000 L CNN
F 1 "10meg" H 6270 2405 50  0000 L CNN
F 2 "" V 6130 2450 50  0001 C CNN
F 3 "~" H 6200 2450 50  0001 C CNN
	1    6200 2450
	1    0    0    -1  
$EndComp
$Comp
L power:GND #PWR?
U 1 1 5C3FA447
P 6200 2150
F 0 "#PWR?" H 6200 1900 50  0001 C CNN
F 1 "GND" H 6205 1977 50  0000 C CNN
F 2 "" H 6200 2150 50  0001 C CNN
F 3 "" H 6200 2150 50  0001 C CNN
	1    6200 2150
	-1   0    0    1   
$EndComp
Wire Wire Line
	6200 2150 6200 2300
Wire Wire Line
	6200 2600 5750 2600
$EndSCHEMATC

This is a bug in ngspice. In the old times ‘-’ for node names was not supported. Now it is, but we forgot to adapt the code for the IC and the nodeset statements.

I will prepare a fix.

1 Like

Would this make “-” ambiguous when we need to do some math with net voltages ? And would this cause also issue for other pspice simulator? If yes, I would think KiCad need to be fix instead of ngspice to adapt with KiCad.

Thanks, that would be great.
Josh

Totally agree with @nhatkhai here. Several problems discovered with ngspice have actually been issues with how KiCad generates netlists or communicates data, and not ngspice itself.

This is only about net names, not net voltages etc.

A fix is available at ngspice git branch pre-master.

1 Like

Thanks for the quick fix!

That nice. But I have to tell you, KiCad need to work on their net name. If people like me run interactive ngspice mode, and plot with bunch of equation for study the design, I would think they will quick see that with the “-” in the net name, it very hard to do expression, and you have to use addition special character to escape them.

And then, if I need to verify if ngspice trust able by using TLSpice let say, I have to manually rename and the net. It all same to the “GND” nets. So having ngspince auto understand GND is 0 is nice, but not going to help for me.

And having simulation run directly from KiCad is very nice, but for many design, we need to be able the run them from script automatically. It also help to search for optimal value. Using interactive from KiCad simply not going to help in this case, and may may KiCad software overly unnecessary complex.