Adding spice components that do not exist in pspice library


#1

Hi,
PSpice library has only a few components. Is there a way to obtain a bigger library with other common simulator components such as voltage controlled switch?

Thank you


How to specify MOS transitor parameters like length and width?
#2

I had develop a ngspice.lib for symbol, and parrallel with ngspice.cir file to expose addition spice model…
I hope it help you as it help me… This should work for all KiCad version from 4.0 to 5.0.
You need to add spice directive to include the ngpsice.cir file in your schematic.

ngspice.cir (1.6 KB)
ngspice.lib (10.7 KB)


Current source symbol, ISOURCE, in pspice library has current direction arrow backwards
Simulation of circuit with power nodes
Kicad ngspice github repository
Spice simulation of switch
Too many parameters for subcircuit type:
AC motors simulation (1 phase & 3 phase)
Something wrong with coupled inductors
#3

I didn’t succeeded yet. It seems that there is no way to use kicad simulations without diving into ngspice manual first.
Thank you for your help.


#4

This is the general problem for simulation, the well known simulators like LTSpice are closed source.
Many device models are encrypted or at least have opensource unfriendly copyright.


#5

I think adding some hidden fields in the pspice symbol may reduce amount of time you have to go back to ngspice manual. I use the value to add the ngspice syntax like into the symbol to help me remember it. But still, after 1.5 year not using ngspice, then comeback to use it for project - I had total lost how did I do it. So lucky I have some note in README of my project, and re-learn with ngpsice manual. So yes, it is a problem, but I think it help me understand in detail again - sometime very convenient tool (like Visual Studio) make us lose the inside out of understand thing – you known.


#6

I installed the “ngspice.lib” file. Now, I have a “ngspice” directory with components.

But I don’t know what to do with the “ngspice.cir” file. What do you mean by:

You need to add spice directive to include the ngpsice.cir file in your schematic.

I have a text “.TRAN 0.0001 0.2 0” in my schematic. Is this enough? And where to click to import the ngspice.cir file? I imported the .lib file with the Symbol Library Editor (File -> Add Library).

Edit: I got it. I used the “Edit spice model” button and selected the .cir file (selection was possible after I selected “All files (*)” on the dropdown menu). Is this the correct way? And I need to do this for every symbol in the schematic.

Also, how to use the “TOGGLE” and “SWITCH” components - how to change their position? Can I program them to change their position at specified time after the beginning of the simulation?


#7

I not familiar with 5.x version. However, you can just add spice directive ".include “…/ngspice.cir” as a text object in your schematic would be enough (to avoid add into every symbols).


#8

You need to apply voltage on the control signal to make it switch. The voltage can be pulse, or pice-wise type of source to make it on/ off at particular time. Or if you need a feedback circuit, you can use voltage-to-voltage control source symbol/model. or opamp…


#9

I want to simulate user’s interaction.

With Qucs it’s more simple, I can specify the times when the button/switch is changing it’s state:

But with KiCad I need to learn and write spice code, it’s not very user-friendly.


#10

Ngspice has been added to Kicad quite recently. Obviously there is work to do. As with any open source project how much of that work is forthcoming is based on a lot of things.


#11

In my professional work, interactive simulation have no use for me. It may be help full for learning how circuit work only. It like step-by-step debugging in coding also have similar taste for me. I afraid, to have ngspice interactive simulator support, would required ngspice design change for supporting it before KiCad can do it. So good luck with this path, I will be your cheerleader :slight_smile:


#12

There would be no need to redesign ngspice.

The ngspice shared library offers access to every step and parameter before, during and after the simulation. You may run single time steps, stop the simulation based on time progress or based on simulation results, change device parameters, resume simulation, change the circuit, reload it and simulate it again. All circuit and simulation data are available through the interface, all (interactive) commands are available as well. So its just the imagination (and time available) necessary for advancing the KiCad-ngspice interface.


#13

Val wants a time controlled push-button.

An ngspice example subcircuit is attached.

What else is needed: create a symbol, allow the subcircuit parameters t1, t2, and on as text next to the symbol, invoke the subcircuit, find a place to publish the switch model.tswitch.cir (1.4 KB)