Re: [free-electronic-lab] ngspice .PRINT I(<component>) won't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On Tue, Sep 14, 2010 at 1:55 AM, Brennan Ashton <bashton@xxxxxxxxxxxxxxxxx> wrote:
On Mon, Sep 13, 2010 at 3:10 PM, Ashwith Rego <ashwith@xxxxxxxxx> wrote:
> Hi
> I've just begun using ngspice and found that I cannot plot the current
> output. Also, I cannot specify the name of a circuit component in a .PRINT
> or .PLOT statement. Only the node numbers seem to work. Here is an example:
> Ohm' Law

> ngspice doesn't seem to recognize R1 in the .PRINT statement. I get the
> following error:
> $ngspice -b

> Warning: can't parse 'r1': ignored

SPICE uses nodal analysis so it has the voltages at every node, it is
up to you to determine what the differential measurement will be, for
the voltage over the resistor you have to list the two nodes, 1 and 0.
 This is all normal behavior.

> -------------------------------------------------------------------------------------------------
> The simulation however works if I replace it with
> .PRINT DC V(0,1)

> Secondly, I can't seem to print current. Using
> .PRINT DC I(R1) or .PRINT DC I(0,1) gives me this error:
> $ngspice -b
> Circuit: ohm's law
> Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
> Warning: can't parse '0#branch': ignored
> Error: no data saved for D.C. Transfer curve analysis; analysis not run
> doAnalyses: not found

This is also normal, spice will only calculate the current though a
voltage source.  The normal way to get around this it to place a 0V
voltage source in series with the current path.  You can then request
the current from that.  In this case you already have that, it is vin,
the vector for current is then vin#branch, so print i(vin)  will give
you the current.

> I don't see this happening in gnucap however (in this case V(0,1) will not
> work). Am I doing something wrong or is ngspice meant to work this way? I
> went according to the ngspice manual. I'm using Fedora 13 64-bit with Free
> Electronic Lab groupinstalled.

gnucap will parse spice for the most part, but it is not the same
especially as it gives more direct access to current power frequency
and other properties of components in the circuit.

> Thanks! :-)
> Ashwith J. Rego

You might find that this overview of spice will help you better
understand how it works.
Especially read the Independent DC sources section for information
about measuring current and voltage.

I hope this helps.

--Brennan Ashton

Hi Brennan

Thanks. That explained it. Never thought about adding the 0V in series before. Thank you for your help. :)

Ashwith J. Rego
My Webpage:
Find me on LinkedIn at:
Follow Me on Twitter at:
electronic-lab mailing list

[Index of Archives]     [Fedora Users]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite Forum]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux