Changing simulation element names can crash KiCad

Bug #1853481 reported by daddyzaur
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Unknown

Bug Description

KiCAD 5.1.4
Virtual SPICE components inside a SUBCKT schematic must be annotated like real PCB components. Reannotating internal SUBCKT schematic components will destroy the meaning of the SUBCKT

Revision history for this message
Seth Hillbrand (sethh) wrote :

Please add your _full_ KiCad version information to all bug reports.

This is from Help->About KiCad->Copy Version information.

Please do not link to external sites in bug reports. All information needs to be contained in the report itself.

Changed in kicad:
status: New → Incomplete
Revision history for this message
daddyzaur (daddyzaur) wrote :

Application: KiCad
Version: 5.1.4, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.67.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh2/1.9.0 nghttp2/1.39.2
Platform: Linux 5.3.11-1-MANJARO x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.71.0
    OpenCASCADE Technology: 7.4.0
    Curl: 7.66.0
    Compiler: GCC 9.2.0 with C++ ABI 1013

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=OFF
    KICAD_USE_OCC=ON
    KICAD_SPICE=ON

tags: added: eeschema ngspice
Revision history for this message
daddyzaur (daddyzaur) wrote :

I was told a KiCAD project archive is not really fully contained, ready to run on any other machine. One must add all kind of extra resources. I tried to add some library files I created and used for this example. I hope it is a complete example and can be executed on other systems. I suspect some library files must be placed in the KiCAD folder somewhere.

description: updated
Revision history for this message
Seth Hillbrand (sethh) wrote :

I'm afraid that I don't understand the bug report here. What action are you asking for KiCad to have?

Revision history for this message
daddyzaur (daddyzaur) wrote :

@Seth
Virtual SPICE components inside a SUBCKT schematic must be annotated like real PCB components. Reannotating internal SUBCKT schematic components will destroy the meaning of the SUBCKT

What that means: a subcircuit is not a PCB real estate. It is "virtual", hence does not have PCB rules. The most damaging enforced rule is the annotation in a schematic that can accidentally change the reference designator inside a subcircuit.

How to replicate: In the attached project, go inside the subcircuit and change the reference designation from Vc1 to V1. Now the simulation will crash, because the Bi3 current source needs the expression of the current trough Vc1. What that means: I had to apply a work-around and create a very special name "Vc1" unique in the schematic that will always be re-annotated to "Vc1" since there is only one source with "Vc" prefix. If you work with something like "V1" then you can end-up with any other number after re-annotation, like "V28" for example. The re-annotion rules must be disabled or modified inside a subcircuit, cannot follow PCB/schematic rules.

Revision history for this message
Ian McInerney (imcinerney) wrote :

You have the option to keep existing reference designations when you reannotate. I would think, if you used this option it wouldn't break.

Revision history for this message
Seth Hillbrand (sethh) wrote :

I agree with Ian here. We're probably not adding specific sub circuit component elements that follow different annotation rules. But once the element is annotated, it doesn't change unless you clear the annotations.

The crash on bad annotation, however, seems like an addressable issue that we can fix.

Changed in kicad:
status: Incomplete → Triaged
importance: Undecided → Critical
milestone: none → 5.1.6
summary: - SUBCKT schematic reannotation
+ Changing simulation element names can crash KiCad
Revision history for this message
daddyzaur (daddyzaur) wrote :

@Ian
True, it can be avoided with extra care. But a new component will be added with a question-mark, and one must annotate the sub-circuit. The full re-anotation must be disabled for sub-circuits, or the full re-annotation must be applied inside expressions also.

Revision history for this message
daddyzaur (daddyzaur) wrote :

@all
In fact, full and unconditional re-annotation is required for both schematic and PCB, in most cases, at least before manufacturing. Any virtual circuit inside a subcircuit with a component schematic meaning and an associated PCB footprint will make thew whole re-annotation quite useless.

Revision history for this message
Ian McInerney (imcinerney) wrote :

@daddyzaur, if you add a new component in a subcircuit, you can annotate that subcircuit with the keep annotations option to give it an annotation and keep the original ones for all the other components.

I don't think we will support reannotating inside the expressions, but a possible way that this could be handled would be to implement this request: https://bugs.launchpad.net/kicad/+bug/1835921 and ensure that the references are expanded before the spice netlist is generated.

Revision history for this message
daddyzaur (daddyzaur) wrote :

@Ian, yes, looks that way. The problem: a real schematic and PCB project cannot have any components with associated Hierarchical Sheet subcircuits. As soon as you apply the needed full re-annotation on the main, higher level schematic, all other components in the sub-circuit schematic page are going to be also fully re-annotated, all of them. You cannot disable the hidden subcircuit components from the full re-annotation in the higher level schematic. Any schematic Hierarchical Sheet used or declared as subcircuit (for modular black-box or SPICE use) must be excluded from re-annotation.
The best option would be to allow the creation of a schematic component with a schematic symbol, from an existing schematic Hierarchical Sheet.

Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

KiCad bug tracker has moved to Gitlab. This report is now available here: https://gitlab.com/kicad/code/kicad/-/issues/1756

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

Other bug subscribers

Remote bug watches

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