Display simulation results in EEschema

Hey lads,

For a university assignment, I’m supposed to run a pspice simulation on a certain circuit - they intend for us to use OrCad to do this, and submit the schematic with the voltages across certain components and the currents along certain nodes. When running a pspice simulation on OrCad, these things can be viewed right on the schematic. I have been doing these assignments as well as my own projects in KiCad for a little while now, and I was wondering if this is something that can be accomplished with EESchema/ngspice? I would very much prefer to not have to deal with OrCad and it’s licensing, not to mention it won’t run on my system (debian). If this is not possible, could I at least export the results in a presentable way, perhaps a spreadsheet or even a table outputted to the simulator console? I have had no issues running the simulation, and the results are what I’m looking for - I just need a way to ideally embed them onto the schematic and/or view them in some other way other than the graph window.

Any tips are greatly appreciated :slight_smile:

What level of study are you at? A collection of these types of simulations might be good for others.

Undergraduate level electrical/computer engineering. Fairly basic so far, but I’d be open to making some of them available if there’s a good way to do that? Would you happen to know anything with regards to my question though? :stuck_out_tongue:

Appear that you want to do nodal / electrical loop circuit analysis (classical circuit classes). Most of undergraduate students are habituated with the interactive simulator and not the Spice it self (set a fix end time and step of simulation and get a graph). This second option is already in KiCad, maybe is possible to just get the nodal values from ngspice (I am not an expert user of this resource).

About the interactive (just play and get the result) still on features request:
Interactive simulation
Insheet graphs
Power proble
General improvements

Yes, for the time being that’s all we’re doing. I know there are commands to print and plot nodal values - I’ll look into those a bit more, however each node has to be explicitly specified, which is rather inconvenient.

If you want to simply end up with a graphic of the Circuit/schematic and Simulation results, all on the same graphic, you can do this (I do it for my File info)… Of course, it could be the Data and/or Plot of signals…

Example shows:
• Step #1 (on left side): a quick simulation (not used in step #2)
• Step #2 (on right side): a previous simulation (because I’m lazy) screenshot with White background, pasted into Schematic.
• Step #3 (lower section of schematic): Exported Netlist and then used it in LTspice and screenshot pasted into Schematic. With instructions…

Sounds like you need some way to show all the voltages and currents on the schematic all at the same time. Or at least make a printout of all those values. Are you only concerned with DC circuits? Do you specifically need voltage across each component, or is voltage at each node respect to ground sufficient?

Both with respect to ground and across - mostly DC for the time being.

Without doing a bunch of snipping, as shown above, the only way I know how to do this effectively (especially with DC circuits) is within LTspice which should run on Debian under Wine. The .op command will show a printout of all the node voltages and branch currents.

But you can also put data labels up on the schematic which can show the same thing, or you can create mathematical expressions from all that data. For example, the voltage across R1 would be [V(n001) - V(n002)].

It might also be possible to get similar data by creating the schematic in KiCad and pushing the simulation out to LTspice, or even external ngspice (but I’m less familiar with that one):

It sounds like you would need the evaluation of the operating point. You are placing suitable voltages to your circuit, and the dc answer is calculated by ngspice. Operating point is also involved if you do an ac analysis, where you need to know at which operating point of the circuit, or a transient analysis, where you need a starting point.

Unfortunately the eeschema/ngspice interface currently does not support plain op analysis. You can however design your circuit, and add a .control script to do the op analysis.

To obtain a simulation, you have to define one of the currently supported simulation types, ac, dc, tran.

Then you may add a script (put text into a text box and place it onto the eeschema circuit schematic) like

* wait until the internal simulation has finished
set controlswait
* do the operating point analysis
* print the data on the screen
print all
* write the data into a file (provide a path where you have access rights)
print all > D:\Spice_General\KiCad\op.out

I have adde some comments to explain the commands.

As an example, I have taken the demo project to be found in kicad/share/kicad/simulation/sallen_key. The demo does an ac analysis. The script shown above adds the op analysis. File op.out then reads:

/lowpass = 2.290120e-03
@c1[i] = 0.000000e+00
@c2[i] = 0.000000e+00
@r1[i] = 2.039206e-07
@r2[i] = 2.039206e-07
@v1[i] = 2.039206e-07
@v2[i] = -1.83307e-03
@v3[i] = -1.83287e-03
net-_c1-pad2_ = 2.039206e-04
net-_c2-pad1_ = 4.078412e-04
net-_r1-pad2_ = 0.000000e+00
vdd = 1.000000e+01
vss = -1.00000e+01

How did you get the values to display on the schematic - could you go into more detail? This is exactly what I need.

I tried doing this, and this is what I got. Several questions - why is it saying ‘v-sweep not found’ when I try to plot a symbol? Why are not all of the resistor values being displayed? And as shown in a previous post, can these values that are being printed to the console possibly be referenced to place symbols on the schematic?

Sorry for the delay in replying - I really appreciate all the help.

There are two ways. After running the .op simulation, you can left-click on any node/net and the voltage at that node will pop up as a label. You can then right-click that label and edit the expression to whatever you want and move the label to any place on the schematic. Alternatively, you can right-click anywhere on the screen that’s blank and hit “Draft->.op Data Label” and it’ll place down a blank data label which you can right-click and edit in the same exact way.

This only works because LTspice is an all-in-one solution and therefore contains back-annotation between the SPICE engine and the schematic. I don’t believe this exact thing is possible in KiCad (yet) because KiCad simply pushes the netlist out to ngspice and then the simulator app interprets/plots the resultant data. There is currently no existing mechanism to place the data back onto the schematic (as far as I know).

I see - forgive me if I missed it, but what software were you using to view the schematic?

I am able to get LPSpice running w/ wine - is there any way to import my kicad schematics into it? When I try it throws a 'bad magic number error?

To allow plotting with eeschema after op simulation, we have to enhance the script a little bit:

* wait until the internal simulation has finished
set controlswait
* store the current plot
set cp = $curplot
* do the operating point analysis
* print the data on the screen
print all
* write the data into a file (provide a path where you have access rights)
* print all > D:\Spice_General\KiCad\op.out
* go back to the previous plot
setplot $cp
1 Like

You can’t import the schematics, only the netlist as shown here at this timestamp:

Therefore, if you want the back-annotation to work, you need to re-draw the schematic from scratch within LTspice.