@SteveFalco Can you send me your output file? Let’s see if we can separate the useful from not in this.
What is the name of the output file? Or is it just what appears in the Spice Simulator viewport ?
Thank you, @holger
After adjusting the height and width of the black viewport, I confirmed Plot 1 was identical to the one shown on the website.
After closing the viewport and appending “F” to the capacitor values (still no space between numerals and text), I reran the simulation. YAHOO!
Same graph showing a low-pass response Bode plot around a corner frequency of about 10.8 kHz and a -39dBV/decade rolloff in the last decade, -2.5% lower than
the -40 dbV/decade you’d expect. Close.
Next I generated Plot 2, the 5V step time response. I saw a 66 ms rise time, 16% lower than the 78.4 ms rise time shown on the website. Not quite so close, but not so bad considering the top of the graph was
very flat after 55ms. Pretty good. Still can’t complain.
Here’s the text:
I will continue testing ngspice with the NPN transistor and the digital gates before drawing a conclusion about the usefulness of KiCad/ngspice simulation tools. I did see results close to what one would expect from a second-order low-pass filter. I will not post further graphs unless somebody asks me to. I have not yet seen any runaway data as @SteveFalco described.
It would be helpful to have the plot (that is, the black rectangle) appear in a separate viewport from the Spice Simulator, because I wasted a lot of time scaling the Spice Simulator viewport to have the same aspect ratio on my plot compared to the website’s plot. Matching aspect ratios makes comparing graph readings of your simulation
to published (or to previous sim.data before you changed something) graphs sooooooo much easier.
output.zip (17.3 KB)
@Seth_h I attached the output from my simulation run.
@Russ I don’t think you can save the output from what appears in the Spice Simulator viewport. For me, it is far too lengthy, and causes a crash when I try to select it. It probably overflows the clipboard!
The way to save it is as follows:
- In the Simulaton window, pull down the Simulation menu and select “Show Spice Netlist”.
- Copy-paste the netlist to a file. Let’s call it “netlist.file”.
- Run the simulation directly via ngspice:
a) ngspice | tee log.file
b) source netlist.file
c) run
d) ^D
That way, the log data will go directly into “log.file” and you won’t crash KiCad.
If you meant run ngspice from a linux shell, I don’t have that capability. I just tried.
On Fedora, you can install ngspice:
dnf install ngspice
@SteveFalco
I installed spice_30.2-1~bpo9+1_amd64.deb.
ngspice ran from a shell, but not with the tee.
$ ngspice
******
** ngspice-30 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Please get your ngspice manual from http://ngspice.sourceforge.net/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
** Creation Date: Thu Jan 3 08:23:44 UTC 2019
******
ngspice 1 -> source net.list
net.list: No such file or directory
ngspice 1 -> source netlist.file
Circuit: KiCad schematic
ngspice 1 -> run
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
Warning: v1: no DC value, transient time 0 value used
Initial Transient Solution
--------------------------
Node Voltage
---- -------
net-_c1-pad1_ 0
in 0
out 0
v1#branch 0
Reference value : 8.07305e-02
No. of Data Rows : 100021
ngspice 1 -> ^Dngspice-30 done
My netlist:
$ ls netlist*
netlist.file
$ cat netlist.file
.title KiCad schematic
C1 Net-_C1-Pad1_ GND 1uF
R1 Net-_C1-Pad1_ in 10k
R2 out Net-_C1-Pad1_ 1k
C2 out GND 100nF
V1 in GND PULSE (0 5 1u 1u 1u 1 1)
.save @c1[i]
.save @r1[i]
.save @r2[i]
.save @c2[i]
.save @v1[i]
.save V(GND)
.save V(Net-_C1-Pad1_)
.save V(in)
.save V(out)
.tran 1u 100m
.end
@Russ I guess debian / ubuntu has already disabled the “percent complete” status messages, which is why you are not seeing the garbage that I am seeing on Fedora.
@Seth_h I looked through the code a bit, and found this:
void SIM_PLOT_FRAME::onSimReport( wxCommandEvent& aEvent )
{
m_simConsole->AppendText( aEvent.GetString() + "\n" );
m_simConsole->SetInsertionPointEnd();
}
It might be the right place to do some filtering. Perhaps a test like the following should be added - it would be good to defend against excessive output, regardless of when the library gets fixed:
If the length of aEvent.GetString() is more than 255 characters, discard the string
.
No reasonable string should be longer than that.
Attached is the ngspice code that generates the offensive output:
/* show a time process indicator, by Gong Ding, gdiso@ustc.edu */
if (ckt->CKTtime / ckt->CKTfinalTime * 100 < 10.0)
printf("%%%3.2lf\b\b\b\b\b", ckt->CKTtime / ckt->CKTfinalTime * 100);
else if (ckt->CKTtime / ckt->CKTfinalTime * 100 < 100.0)
printf("%%%4.2lf\b\b\b\b\b\b", ckt->CKTtime / ckt->CKTfinalTime * 100);
else
printf("%%%5.2lf\b\b\b\b\b\b\b", ckt->CKTtime / ckt->CKTfinalTime * 100);
fflush(stdout);
If someone wants to create a filter…
It is called after each successful time step.
@SteveFalco, as @holger points out that is the code the does the “lots of text data” thing, which is what get removed when the --enable-ndev is removed. Hence I think it should be enough for us to get libngspice rebuilt without that and we should be good to go.
I understand that, but I was trying to see if there was any interest in a simple patch on the KiCad side that would let us move forward without waiting for the library.
For fun, I’ll still play with that - I haven’t done any C++ coding for a few years, so it will be interesting to see if I can come up with a patch. Whether anyone wants it when I’m done will be another story.
Good luck
@Russ , sort of unrelated this thread, but related to https://bugs.launchpad.net/kicad/+bug/1810311
I see that the first screenshot you have you have “smooth” graphs, yet the number of data rows are few. Could you share your version information? Possibly on the bug report and say that it does not seem stepped on your version.
$ ngspice -v
ngspice compiled from ngspice revision 30
Written originally by Berkeley University
Currently maintained by the NGSpice Project
Copyright (C) 1985-1996, The Regents of the University of California
Copyright (C) 1999-2011, The NGSpice Project
$ cat kicad5/version.txt
Application: kicad
Version: 5.0.2+dfsg1-1~bpo9+1, release build
Libraries:
wxWidgets 3.0.4
libcurl/7.52.1 OpenSSL/1.0.2q zlib/1.2.8 libidn2/2.0.5 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3
Platform: Linux 4.18.0-0.bpo.1-amd64 x86_64, 64 bit, Little endian, wxGTK
Build Info:
wxWidgets: 3.0.2 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
Boost: 1.62.0
OpenCASCADE Community Edition: 6.8.0
Curl: 7.52.1
Compiler: GCC 6.3.0 with C++ ABI 1010
Build settings:
USE_WX_GRAPHICS_CONTEXT=OFF
USE_WX_OVERLAY=OFF
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=ON
KICAD_USE_OCC=OFF
KICAD_SPICE=ON
Ok - I have a patch that works for me. I just toss any status line beginning with a ‘%’. Any interest, or is it too much of a hack?
--- a/eeschema/sim/sim_plot_frame.cpp 2019-01-13 15:57:18.798891439 -0500
+++ b/eeschema/sim/sim_plot_frame.cpp 2019-01-13 15:58:03.648978524 -0500
@@ -1282,8 +1282,12 @@
void SIM_PLOT_FRAME::onSimReport( wxCommandEvent& aEvent )
{
- m_simConsole->AppendText( aEvent.GetString() + "\n" );
- m_simConsole->SetInsertionPointEnd();
+ wxString t = aEvent.GetString();
+
+ if( t[0].GetValue() != '%' ) {
+ m_simConsole->AppendText( t + "\n" );
+ m_simConsole->SetInsertionPointEnd();
+ }
}
Here is a better version of the patch. In this one I search for the backspaces, rather than the percent signs. That should eliminate any chance of false positives being discarded.
kicad-5.0.2-ngspice.patch (1.3 KB)
Mamoru TASAKA from Fedora project told me that his is currently redoing the ngspice build with an updated set of configure flags
Yes - he commented on the bug I opened here:
https://bugzilla.redhat.com/show_bug.cgi?id=1666505
Once it is done, we can test. If enough karma is given, we can close this issue pretty soon.
I tested kicad with the new ngspice and it resolves the issue for me so I gave it +1 karma. The karma threshold is “2”, so if one other person tests the package, it can move from “testing” to “updates” quickly. If not, then we simply wait a week.
The karma page for ngspice for Fedora 29 is here:
https://bodhi.fedoraproject.org/updates/FEDORA-2019-b71d912484
In case you didn’t notice, I have reverted @SteveFalco’s patch to workaround the ndev spam. So in summary, the fedora copr package is using official ngspice and everything is like it should be. [Unless I missed something].
@aimylios are there any more changes in your version of the copr packages that needs attention? As far as I understand it does not add anything new anymore.
Thank you for your work!