# How measure differential current in SPICE ?

• posted

Could some SPICE guru please help ? I use HSPICE and Ngspice, both text input based. I wish to measure differential current output from a test circuit. For each output node, I can add a zero voltage output voltage source as for example VTST 3 4 DC 0.0 AC 0.0 And then measure the current at each output node as .TRAN PRINT I(VTST1) ; and so on But how do I combine the output from these two zero voltage voltage sources to get the actual differential current ? Any hints, suggestions would be of immense help. Thanks in advance.

• posted

In PSpice it would be...

.PRINT (I(V1:1)-I(V2:1))

Where the "colon 1" indicates which terminal of the voltage source. ...Jim Thompson

```--
| James E.Thompson                                 |    mens     |
• posted

Two 0V voltage sources to extract the two currents and a "B" source to subtract the currents, and generate a voltage proportional to the diff current.

e.g. feed currents into nodes 1, 2 and 3,4, into a subckt.

.subckt diff_i_tester 1 2 3 4 out v1 1 2 dc 0 v2 3 4 dc 0 b1 4 0 v=i(v1)-i(v2) .ends

plot (vout) from the calling circuit.

the b source can have complicated expression, so is quite useful. Look it up in the manual!

Kevin Aylward

- SuperSpice

• posted

.subckt diff_i_tester 1 2 3 4 out v1 1 2 dc 0 v2 3 4 dc 0 b1 4 0 v=i(v1)-i(v2) .ends

ho hum...typo...

b1 out 0 v=i(v1)-i(v2)

Kevin Aylward