Spice Issue: Current for in a RC Circuit with Sinusoidal Source

Hi,

I am simulating the circuit given below using PSpice Student version and ngspice.

A Capacitor Connected Across a Sinusoidal Source

  • vin 1 0 sin(0 1 1K 0 0 0) R1 1 2 1 C1 2 0 0.1m
  • .tran 1us 2m .end

I see that the current plot is +(-)180 degree shifted! More specifically, I see a -cosine wave instead of a +cosine wave (for a sine wave voltage).

I am surprised to see this behaviour in both the Spice simulators. I also see something similar reported on another site:

formatting link

(See "Once again, SPICE confusingly prints the current phase angle at a value equal to the real phase angle plus 180o (or minus 180o).")

Could somebody please explain why this is so? Is this an accepted bug or am I missing something.

Thanks, Anand

Reply to
Anand P. Paralkar
Loading thread data ...

Anand, You have to be careful in thinking on polarity when talking about currents. Probe looks at currents going INTO the pin, so you often get turned around when probing currents in a circuit.

Charlie

Reply to
Charlie E.

Current where? The current in 'vin' will be 'backwards', because SPICE defines the current in a voltage source as being positive _into_ the '+' terminal.

As mentioned elsewhere, in graphical SPICE tools that let you probe, the current is often defined as the current _into_ a selected pin, or from pin 1 to pin 2 of a device (which can be confusing, as you can never remember which pin is which on a passive).

So think of it as a 'quirk' -- it's probably on purpose, and put there to maintain consistency, but sometimes what's consistent isn't what you expect.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

Thank you Charlie and Tim for your explanations. It kind of relieves me that it was just the Spice convention that I didn't know.

I must add that it would have been great if they had stuck to the usual text book convention that:

  1. To specify the direction of a current flow, we specify the direction in which positive charge carriers would move. (Which is opposite to the direction in which electrons would move.)
  2. Positive charge carriers move out from the higher potential point (the +ve terminal of the voltage source) seeking a lower potential point (the -ve terminal of the voltage source).

You see, when you put a probe in the Spice GUI (or for that matter when you plot a current using commands), you are thinking about the series current that goes through the whole branch. After all, the probe is placed between two components and we don't know which component would be chosen to interpret INTO and OUT.

I guess it is the voltage source which must be considered as the reference.

Thanks once again, Anand

Reply to
Anand P. Paralkar

Anand, A voltage probe is placed on a net, between parts. A current probe ALWAYS is attached to a pin. At Tim said, if you take I(vout) then the parts pin numbers gives it polarity...

Charlie

Reply to
Charlie E.

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.