Installing and using ngspice - an opensource simulator

Member
Joined 2011
Paid Member
wingspread simulation

Viola. Wingspread plot of the SA2015 IXYS MOSFET output stage.
The results are exactly the same as using ltspice.

BR, Toni

P.S.: better variable string handling using ngspice scripting is wanted ... If an output of a shell command could be directly inserted into a variable that would be helpful... (or I simply cannot find it in the manual)
 

Attachments

  • ngspice_wingspread.zip
    254.7 KB · Views: 72
  • wingspread_plot_result.png
    wingspread_plot_result.png
    8.6 KB · Views: 326
  • wingspread_schematic.png
    wingspread_schematic.png
    153.5 KB · Views: 312
Member
Joined 2011
Paid Member
ngspice - new command "setcs" - set case sensitive variables

...
Attached 3 small ngspice patches which I currently need against ngspice-30+ pre-master. Maybe Holger can have a look into it to implement the patches.

  • ngspice_add_gnuplot_png_batch_option.diff
  • ngspice_allow_mixed_case_vars_using_prefix.diff
  • astx_ngspice_write_ignore_currents.diff
...
Using the current pre-master source the patch "ngspice_allow_mixed_case_vars_using_prefix.diff" is no more needed - thanks to Holger!
If mixed case variables are needed just use the "setcs" command instead of "set".
An updated opamp stepping script will follow.

BR, Toni
 
Last edited:
Member
Joined 2011
Paid Member
POC: Directly get the first line of a shell command output into a variable

Just posted an experimental patch to implement a new command "setcmd" which sets a ngspice variable using the results of a shell command ...

Example output including debug lines:
Code:
ngspice 8427 -> shell cat t.pl
#!/usr/bin/perl
printf("%f\n", 5.38135e+006/1000000);
ngspice 8428 -> setcmd myvar=perl ./t.pl
setcmd: 1 <myvar=perl ./t.pl>
setcmd: 2 <myvar> <perl ./t.pl>
setcmd: 3 var=<myvar> result=<5.381350>
ngspice 8429 -> set
...
  myvar 5.381350
...
ngspice 8430 -> quit

BR, Toni
 

Attachments

  • ngspice_poc_add_setcmd_command_to_directly_send_shell_output_to_variable.diff.txt
    4.6 KB · Views: 51
I've used LTspice (IV) quite a bit in the past and I am a "atleast above greenhorn" using Kicad that have been my EDA of choice having tried a few different ones.

Now to the point...

It would seem, for me, it is harder to get the more basic stuff going in ngspice.

Granted, I've not read the ngspice30 manual. I have a hard time keeping my focus for longer periods of time due to chronic pain.

Are there any good, as in even I will understand, guides/tutorials out there?
 
Member
Joined 2011
Paid Member
Just found/got the information, that backticks/backquote is working in ngspice. Thanks to Marcel from ngspice developer team!
Searching for "backticks" will not find "backquote" ... :D
Fine!

E.g.:
Code:
ngspice 8531 -> set
...
* curplottitle  Constant values
...
ngspice 8532 -> set myvar=`echo $curplottitle|cut -d' ' -f2`
ngspice 8533 -> set
...
* curplottitle  Constant values
...
  myvar values
Works as expected, as long as your result string data doesn't contain any space ... a bit confusing ... but mostly enough for automated scripts.

Forget my poc patch ... :D
BR, Toni
 
Member
Joined 2011
Paid Member
...
Are there any good, as in even I will understand, guides/tutorials out there?
Dear Mayday,

with some ltspice experience and reading the ngspice manual it should be possible to use ngspice for most simulation tasks you've done before.
I try to port all my ltspice standard simulations for amplifier design to ngspice and will make them available in this thread.

BR, Toni
 
Hi Toni,
Thank you.

I've started reading the manual a couple of times. Those times has all been when I've been forced to rest due to pain. That is not the best time as my concentration suffers from constant and chronic pain, but the time I'm in less pain I spend with my 2yo daughter as much as possible. I will make more attempts at the manual, taking notes while reading, and hopefully I'll get through it and understand it even if it takes a while.

I really don't wish to install wine and use ltspice as I much prefer opensource software.

There are a few things I want to learn over time, I've installed some logic simulators and a gui for ngspice and, of course, I have KiCad installed as I really love that EDA.

BR,
Jonas
 
Member
Joined 2011
Paid Member
...
An updated opamp stepping script will follow.

Attached the reworked opamp stepping scripts. Now with parallel processing to speed up simulations. My 16 processor machine need only a few seconds to calculate all 134 opamp simulations.


Code:
 3800 pts/0    Ss     0:01      \_ /bin/bash
 7657 pts/0    S+     0:00          \_ /bin/bash ./step_opamps_loopgain.sh
 9130 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9316 pts/0    R+     0:00              |   \_ ngspice -i tmp_opamp_loopgain.ad8641.inc tmp_opamp_loopgain.ad8641.net
 9160 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9333 pts/0    R+     0:00              |   \_ ngspice -i tmp_opamp_loopgain.ad8642.inc tmp_opamp_loopgain.ad8642.net
 9190 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9363 pts/0    R+     0:00              |   \_ ngspice -i tmp_opamp_loopgain.ad8643.inc tmp_opamp_loopgain.ad8643.net
 9220 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9410 pts/0    R+     0:00              |   \_ ngspice -i tmp_opamp_loopgain.ad8648.inc tmp_opamp_loopgain.ad8648.net
 9251 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9423 pts/0    R+     0:00              |   \_ ngspice -i tmp_opamp_loopgain.ad8663.inc tmp_opamp_loopgain.ad8663.net
 9280 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9454 pts/0    R+     0:00              |   \_ ngspice -i tmp_opamp_loopgain.ad8667.inc tmp_opamp_loopgain.ad8667.net
 9309 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9340 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9342 pts/0    Rl+    0:00              |   \_ gnetlist -g spice-sdb -o tmp_opamp_loopgain.ad8671.net opamp_loopgain.sch
 9370 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9372 pts/0    Rl+    0:00              |   \_ gnetlist -g spice-sdb -o tmp_opamp_loopgain.ad8672.net opamp_loopgain.sch
 9398 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9401 pts/0    Rl+    0:00              |   \_ gnetlist -g spice-sdb -o tmp_opamp_loopgain.ad8674.net opamp_loopgain.sch
 9430 pts/0    S+     0:00              \_ /bin/bash ./step_opamps_loopgain.sh
 9432 pts/0    Rl+    0:00                  \_ gnetlist -g spice-sdb -o tmp_opamp_loopgain.ad8675.net opamp_loopgain.sch


BR, Toni
 

Attachments

  • ngspice_opamp_stepping_to_the_max_png.zip
    931.8 KB · Views: 56
  • ngspice_opamp_stepping_to_the_max.png
    ngspice_opamp_stepping_to_the_max.png
    425.7 KB · Views: 240
  • ngspice_opamp_stepping_to_the_max.zip
    15 KB · Views: 57
Last edited:
Hi Holger, Yes I have the latest, nightly, KiCad. It took some tinkering as I'm on Fedora 29 on the notebook I use most of the time (running arch on the other notebook). So, yes I have ngspice integrated in eeschema. I am looking at several tools, I have qucs installed and a logic sim and some other tools. In the past, when running win, I used ltspice for sims and KiCad purely as an EDA. All, or atleast most, of my models are in .txt format. What is the best format for ngspice? .lib? .sub?

My attention is a bit divided atm as I am trying to get the hang of my pickit2 as I need that to flash firmware to my (almost ready for firmware) UniSolder52 build.
 
I have a question. LTspice and ngspice both support MEXTRAM models, but have you ever actually... seen one? I've seen as many MEXTRAM models as I've seen unicorns. NXP has a section of their website dedicated to them, but I think I failed the psychological assessment. I can only assume that is the purpose of the misleading and futile website design.

I downloaded the libraries, but as far as I can tell they are pure code. If they contain any models they are in binary and only compatible with software which I could trade for a new car.

Libs or it didn't happen!
 
This is the clash of two different worlds.


MEXTRAM is made for integrated bipolar IC simulation. People simulate chip set for 77GHz radar with such models. Very sophisticated bipolar devices, fmax beyond 300 GHz or so, several hundres or thousands integrated on a chip.



And the nomenclature is different. The code, the equations, that is the model. To make it alive you need model parameters. These are offered by the foundries, the companies that produce the ICs. These parameters are never public, available only under NDA.


So, if you read 'model' on the NXP web site, that's the code. And tat's o.k. for the IC people.


For discrete bipolars, there is no need for MEXTRAM. The modified Gummel-Poon models (the set of equations describing the transistor coded into the simulator) are o.k. And people here call 'model' the parameters that go into the model to calculate current versus voltage.
 
For discrete bipolars, there is no need for MEXTRAM. The modified Gummel-Poon models (the set of equations describing the transistor coded into the simulator) are o.k.

Eh, I don't know. They are useful up to the point where you have to start keeping track of whether a flaw in the model will be a problem in the prototype. Admittedly, after adding basic quasi-saturation support most of that may be in the past. But the collector resistance modeling could be improved.

https://www.nxp.com/wcm_documents/models/bipolar-models/mextram/jssc01epilaag.pdf

Both VBIC and SGP in LTspice show the quasi-saturation kink in the Kull model, figure 6.

The collector resistance modeling is crucial for modeling the distortion of BJTs in the VAS:

http://www.nanovolt.ch/resources/power_amplifiers/pdf/audio_power_amp_design_comments.pdf
 

Attachments

  • VBIC-SGP-Kull-kink.png
    VBIC-SGP-Kull-kink.png
    41.6 KB · Views: 249
Next issue then is the model parameter extraction.


The most recent MEXTRAM (505) model has about 120 parameters. Same with VBIC. You will need a lot of measurements, and probably a parameter extraction software. I fear that data sheets are not that helpful anymore.


VBIC is implemented in ngspice, so one has to look for adequate model parameters.
 
I have a question. LTspice and ngspice both support MEXTRAM models, but have you ever actually... seen one? I've seen as many MEXTRAM models as I've seen unicorns. NXP has a section of their website dedicated to them, but I think I failed the psychological assessment. I can only assume that is the purpose of the misleading and futile website design.

I downloaded the libraries, but as far as I can tell they are pure code. If they contain any models they are in binary and only compatible with software which I could trade for a new car.

Libs or it didn't happen!

Maybe this document could help a bit:

Paaschens et al. Parameter Extraction for the Bipolar Transistor Model MEXTRAM


Some more informations are to be found at:

Introduction

https://www.nxp.com/wcm_documents/models/bipolar-models/mextram/nlur2001801_2.pdf
 
Last edited:
I'm not sure that guy understood the original script. It's limited in some ways, but fairly sophisticated and understands some unconventional SGP usages.

Note how he doesn't recognize that the person who WROTE the PDF he references was the SAME guy who wrote the script he is criticizing. This probably deserves to be looked at by someone with the right credentials.

Is it possible some Bash script syntax has changed since 1996 when the original script was written?