eeschema ngspice noise simulation is buggy

Bug #1821366 reported by Holger Vogt
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Unknown

Bug Description

eeschema ngspice
simulation .noise with error

take example C:\Program Files\KiCad\share\kicad\demos\simulation\sallen_key
copy to user writable place
start eeschema
load sallen_key.sch
edit text window (mark as comment) -> *.ac dec 10 1 1Meg
Tools --> Simulator --> Settings --> Noise
Measured node /lowpass
Reference node <empty>
Noise source V1
Decade
Number of points 10
Start frequency 1
Stop freuency 10k
ok

run/Stop Simulation

simulation runs, but emits only error messages:
Error: no such vector 3
Error: no such vector 6
Error: no such vector 2
Error: no such vector 1
Error: no such vector 4
Error: no such vector 5

Reason is that after command 'bg_run' has finished, commands
print v(3)
print v(6)
...

are sent to ngspice.

The netlist
Spice Simulator --> Simulation --> Show Spice Netlist ... does not
contain node names 1 to 6 (see below), so ngspice reports errors.

Spice Simulator --> Add Signals
does not show the noise vectors, but only the op vectors

The netlist itself is buggy:
The line
.noise v(3) V1 dec 10 1 10k
does contain an non-existing node. It should read
.noise v(/lowpass) V1 dec 10 1 10k

The noise-relevant inputs and outputs are not saved and thus are not available for printing or plotting
It would probably be ok to add a
.save all
to the list of saves.

For this noise simulation ngspice generates two 'plots'.
plot noise1 contains
frequency : frequency, real, 41 long, grid = xlog [default scale]
inoise_spectrum : voltage-density, real, 41 long
onoise_spectrum : voltage-density, real, 41 long

These should be made available in the graphics, not the op vectors

plot noise2 contains the integral noise values
inoise_total : voltage, real, 1 long
onoise_total : voltage, real, 1 long

These should be printed.

The netlist generated during noise simulation:

.title KiCad schematic
.include "D:\Spice_general\kicad\sallen_key-op-test\ad8051.lib"
V1 Net-_R1-Pad2_ GND AC 1
XU1 Net-_C2-Pad1_ /lowpass VDD VSS /lowpass AD8051
V2 VDD GND DC 10
V3 GND VSS DC 10
R2 Net-_C2-Pad1_ Net-_C1-Pad2_ 1k
R1 Net-_C1-Pad2_ Net-_R1-Pad2_ 1k
C1 /lowpass Net-_C1-Pad2_ 100n
C2 Net-_C2-Pad1_ GND 100n
.save @v1[i]
.save @v2[i]
.save @v3[i]
.save @r2[i]
.save @r1[i]
.save @c1[i]
.save @c2[i]
.save V(/lowpass)
.save V(GND)
.save V(Net-_C1-Pad2_)
.save V(Net-_C2-Pad1_)
.save V(Net-_R1-Pad2_)
.save V(VDD)
.save V(VSS)
.noise v(3) V1 dec 10 1 10k
.end

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

Application: eeschema
Version: (5.1.0)-1, 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

Holger Vogt (h+vogt)
tags: added: eeschema ngspice
Changed in kicad:
status: New → Confirmed
importance: Undecided → Medium
milestone: none → 5.1.1
Revision history for this message
Jon Evans (craftyjon) wrote :

I'm a bit confused here -- the Noise tab in simulation settings is hidden since Orson's commit 324d277 years ago... so presumably that feature is not working yet. How is there a build where this tab is accessible?

The same goes for operating point tab as referenced in this issue: https://bugs.launchpad.net/kicad/+bug/1821360

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

All tabs in 'Simulation settings' are visible in a MS Windows build (since ngspice support has been added, as far as I remember).

Tabs Distortion, Pole Zero, Sensitivity, and Transfer Function display an empty screen.

Tab operating point states 'This tab has no settings' (in fact that's true, nothing is needed.)

Tabs AC, dc transfer, noise, Transient and Custom show the required edit boxes for entering simulation settings.

There has already been some action on noise simulation https://bugs.launchpad.net/kicad/+bug/1784282

Revision history for this message
Jon Evans (craftyjon) wrote :

It looks like there are two bugs:

1) the noise tab is supposed to be hidden. In Linux, the only tabs that are shown are AC, DC Transfer, Transient, and Custom. So, it is a bug that the extra tabs are shown in Windows.

2) We should get those extra tabs working! It looks like they were hidden because they were not finished or untested. This probably isn't practical to do in 5.1.1

Changed in kicad:
milestone: 5.1.1 → 5.1.2
Jon Evans (craftyjon)
Changed in kicad:
assignee: nobody → Jon Evans (craftyjon)
Changed in kicad:
milestone: 5.1.2 → 5.1.3
Jon Evans (craftyjon)
Changed in kicad:
assignee: Jon Evans (craftyjon) → nobody
Revision history for this message
Jim Groves (jgroves9) wrote :

@craftyjon - I just downloaded the (5.1.2)-1, release build on a Windows machine this morning. The tools / simulator / settings tab only contains AC, DC Transfer, Transient, and Custom. No other tabs. So, I don't think your bug 1) propagated to 5.1.2

Revision history for this message
Jon Evans (craftyjon) wrote :

Yes, I fixed the bug of extra tabs showing in commit d18b12c1a373c49b07ea9c670a2de6e9f2fea658

If you are interested in working on this, you can look at that commit to see where to re-enable the tabs

Revision history for this message
Jim Groves (jgroves9) wrote :

cool. I will.

Revision history for this message
Jon Evans (craftyjon) wrote :

Moving milestone to 6.0 since this is actually a new feature

Changed in kicad:
importance: Medium → Wishlist
milestone: 5.1.3 → 6.0.0-rc1
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/2369

Changed in kicad:
status: Confirmed → 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.