Spice netlist doubled device names

Bug #1700853 reported by buleks
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Low
Maciej Suminski

Bug Description

When i generate spice netlist using eeschema i get for each device something like this:
rr4 vg2 net-_r4-pad2_ 10
rr5 net-_d3-pad1_ vg2 1k

Instead print r5 it repeat first letter.

It not occur in stable release.
I compile code form branch master.
Source revision:commit 4bdac4de705849777f5a59e0f6f7ee1dd6274a8c

Revision history for this message
Maciej Suminski (orsonmmz) wrote :

Just to be sure, does it cause any simulation errors?

Revision history for this message
buleks (buleks) wrote :

Simulation works without errors because for spice this is not any problem.

Changed in kicad:
importance: Undecided → Low
Revision history for this message
jean-pierre charras (jp-charras) wrote :

Hi Orson,
AFAIK, we have already discussed this feature, added because Spice simulator has some constraints (the first letter of a reference is constrained).
The current behavior is very acceptable, and I am not sure it should be modified.

Revision history for this message
buleks (buleks) wrote :

I have example why it should be modified.
When i want to build transformer, on schematic i must put two inductors L1,L2.
Then i must specify coupling coefficient like this "K1 L1 L2 0.98" .
With this issue i must put this directive: K1 LL1 LL2 0.98

Revision history for this message
jean-pierre charras (jp-charras) wrote :

I am not convinced: This is not a proof.

Your 2 inductor could be named I1 and I2 (I for inductor) or T1 and T2 (T for transformer).
Each country has its habits.

Be sure in some (many?) countries, resistors are not labeled Rn and capacitors not labeled Cn.

Revision history for this message
buleks (buleks) wrote :

This is clear for me now.
I agree that it shoudnt be modified.

Changed in kicad:
status: New → Won't Fix
Revision history for this message
JKB (joel-bertrand) wrote :

There are some side effects. For example, instead of writing
    .save @r7[i]
you have now to write
    .save @rr7[i]
to save R7 current or
    .save i(vv9)
if V9 is a 0V source to measure current.

Revision history for this message
PCB Wiz (1-pcb-wiz) wrote :

I can see what KiCad spice is trying to do, but the current 'solution' is rather blunt, and it breaks spice netlist portability, as well as making ID less natural.

There is a lot of WEB info out there, around spice netlists.
http://www.spiceopus.si/getstarted.html
http://denethor.wlu.ca/ltspice/

My suggested fix would be to ADD A PREFIX ONLY AS NEEDED.
That avoids most RR,CC,VV,QQ,DD cases, but can still patch someones incorrect prefix.

eg I tried a simple sim

.title KiCad schematic
.include "ad8009.lib"
.include "fzt1049a.lib"
.include "laser.lib"
VV1 /in GND pulse(0 3 100n 1n 1n 20n 100n )
XU1 Net-_R2-Pad1_ Net-_N1-Pad1_ VDD VSS Net-_Q1-Pad2_ ad8009
VV2 VDD GND DC 10
VV3 GND VSS DC 10
CC2 /out Net-_C2-Pad2_ 1p
RR5 /out Net-_C2-Pad2_ 2.5
RR1 Net-_N1-Pad1_ GND 220
RR3 Net-_C2-Pad2_ Net-_N1-Pad1_ 220
CN1 Net-_N1-Pad1_ Net-_C2-Pad2_ 1p
DD1 /out GND laser
RR4 /out Net-_R2-Pad1_ 220
RR2 Net-_R2-Pad1_ /in 160
QQ1 VDD Net-_Q1-Pad2_ Net-_C2-Pad2_ fzt1049a
.tran 10p 150n
.end

Here we see XU1 patch is needed, as U1 is a subcircuit.
I manually changed C1 to N1, whence it promptly lost the spice model info (so it _does_ already expect you to follow conventions)
I can manually remap to Passive:Capacitor:1p, and now C prefix correctly overrides the poor choice of N

ONLY U1 and N1 here, actually need a prefix fixup applied all others are ok.

The suggested smarter (no simple repeats) fixed NETLIST would look like this :

.title KiCad schematic
.include "ad8009.lib"
.include "fzt1049a.lib"
.include "laser.lib"
V1 /in GND pulse(0 3 100n 1n 1n 20n 100n )
XU1 Net-_R2-Pad1_ Net-_N1-Pad1_ VDD VSS Net-_Q1-Pad2_ ad8009
V2 VDD GND DC 10
V3 GND VSS DC 10
C2 /out Net-_C2-Pad2_ 1p
R5 /out Net-_C2-Pad2_ 2.5
R1 Net-_N1-Pad1_ GND 220
R3 Net-_C2-Pad2_ Net-_N1-Pad1_ 220
CN1 Net-_N1-Pad1_ Net-_C2-Pad2_ 1p
D1 /out GND laser
R4 /out Net-_R2-Pad1_ 220
R2 Net-_R2-Pad1_ /in 160
Q1 VDD Net-_Q1-Pad2_ Net-_C2-Pad2_ fzt1049a
.tran 10p 150n
.end

Revision history for this message
Maciej Suminski (orsonmmz) wrote :

Let's think about it when v6 development cycle begins.

Changed in kicad:
milestone: none → 6.0.0-rc1
Revision history for this message
Maciej Suminski (orsonmmz) wrote :

I have pushed a fix for the bug, as it turned out to be a simple and low risk change in exchange for much greater benefit.

Changed in kicad:
status: Won't Fix → Fix Committed
assignee: nobody → Maciej Suminski (orsonmmz)
Changed in kicad:
milestone: 6.0.0-rc1 → 5.0.0-rc2
Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision bc67d1ad8cde85fd0d88b95b7b5c259614d08bb4
https://git.launchpad.net/kicad/patch/?id=bc67d1ad8cde85fd0d88b95b7b5c259614d08bb4

Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.