Enable "personalizing" of subcircuits by adding parameters to the instance line

Bug #1829618 reported by Holger Vogt
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Unknown

Bug Description

The accompanying example of a potentiometer (device:R_POT) does show it:
In the eeschema circuit drawing, in the line

R_POT wiper=0.3 val=100k

the tokens wiper=0.3 val=100k are ignored when creating the ngspice instance line

XRV1 "/VDD" "/out" 0 POTI

in the netlist. It is desirable to have

XRV1 "/VDD" "/out" 0 POTI wiper=0.3 val=100k

instead. Thus it would be possible to simulate different potentiometers just
by adding some parameters to each symbol value field and finding them at
the end of the instance line XRV1... in the netlist. Of course the
corresponding subcircuit in the lib file has to show the same parameters
in its .subckt line. But only a single subcircuit in its ngspice lib file
would be needed then for all different potentiometers in a circuit.

Revision history for this message
Holger Vogt (h+vogt) wrote :
Revision history for this message
Holger Vogt (h+vogt) wrote :

KiCad version used in the above example:

Application: Eeschema
Version: (5.1.0-599-gde055031a), release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.61.1 OpenSSL/1.1.1 (WinSSL) zlib/1.2.11 brotli/1.0.6 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) nghttp2/1.34.0
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8)
    Boost: 1.68.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.61.1
    Compiler: GCC 8.2.0 with C++ ABI 1013

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

tags: added: eeschema
Changed in kicad:
importance: Undecided → Wishlist
status: New → Triaged
Seth Hillbrand (sethh)
Changed in kicad:
milestone: none → 6.0.0-rc1
Revision history for this message
Juan José (blascoburguillos) wrote :

I'm also affected by this bug. Additionally the program completely crashes in arch:

https://bugs.launchpad.net/kicad/+bug/1835547

Revision history for this message
Jonatan Liljedahl (kymatica) wrote :

I do this all the time, exactly for pots. See attached screenshot.
The "pot k=0.25 r=100k" is the Spice_Model field.

The sub circuit looks like this:

.SUBCKT pot 1 2 3 r=100k k=0.5
*
R1 2 3 {r*(1-k)}
R2 1 2 {r*(k)}
.ENDS

Revision history for this message
Pepijn de Vos (pepijndevos) wrote :

The solution proposed by Jonathan indeed works for me.

However, it would be great if there were an option to display and change the individual parameters in the schematic. Currently it only appears to be possible to display the entire Spice_Model parameter.

Maybe there could be either a way to pass symbol parameters to spice, like Spice_Model="pot k={k}", or make special parameters like Spice_k, which would pass k to the model, etc, etc. there are many ways to go about it. The end goal is that it's easy to see and change the parameters passed to the spice model.

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/2426

Changed in kicad:
status: Triaged → Expired
Changed in kicad:
importance: Wishlist → Unknown
status: Expired → New
Changed in kicad:
status: New → 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.