Electronics-Related.com
Forums

LTspice differentiation

Started by Piotr Wyderski November 15, 2016
Hello,

I have a resistor R5 with some current flowing through it.
It is possible to plot I(R5) by simply selecting the resistor.
But is it possible to plot dI(R5)/dt? If yes, then how?
An example circuit:

Version 4
SHEET 1 916 680
WIRE 256 16 144 16
WIRE 464 16 336 16
WIRE 592 16 464 16
WIRE 720 16 592 16
WIRE 848 16 720 16
WIRE 464 48 464 16
WIRE 592 48 592 16
WIRE 720 48 720 16
WIRE 848 48 848 16
WIRE 848 64 848 48
WIRE 144 112 144 16
WIRE 416 112 384 112
WIRE 800 112 768 112
WIRE 384 144 384 112
WIRE 464 144 464 128
WIRE 464 144 384 144
WIRE 544 144 544 112
WIRE 592 144 592 128
WIRE 592 144 544 144
WIRE 672 144 672 112
WIRE 720 144 720 128
WIRE 720 144 672 144
WIRE 768 160 768 112
WIRE 848 160 848 144
WIRE 848 160 768 160
WIRE 464 176 464 144
WIRE 592 176 592 144
WIRE 720 176 720 144
WIRE 848 176 848 160
FLAG 144 192 0
FLAG 464 240 0
FLAG 592 240 0
FLAG 720 240 0
FLAG 848 240 0
SYMBOL voltage 144 96 R0
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR InstName V1
SYMATTR Value PWL(0 0 1 3 2 6 3 9)
SYMBOL zener 480 240 R180
WINDOW 0 24 64 Left 2
WINDOW 3 0 -35 Left 2
SYMATTR InstName D2
SYMATTR Value 1N750
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL zener 608 240 R180
WINDOW 0 24 64 Left 2
WINDOW 3 -42 -32 Left 2
SYMATTR InstName D3
SYMATTR Value BZX84C6V2L
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL zener 736 240 R180
WINDOW 0 24 64 Left 2
WINDOW 3 -22 -29 Left 2
SYMATTR InstName D4
SYMATTR Value TFZ6_8B
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL zener 864 240 R180
WINDOW 0 24 64 Left 2
WINDOW 3 -25 -38 Left 2
SYMATTR InstName D5
SYMATTR Value UMZ7_5K
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL res 352 0 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R5
SYMATTR Value 1
SYMBOL njf 416 48 R0
SYMATTR InstName J1
SYMATTR Value U309
SYMBOL njf 544 48 R0
SYMATTR InstName J2
SYMATTR Value U309
SYMBOL njf 672 48 R0
SYMATTR InstName J3
SYMATTR Value U309
SYMBOL njf 800 48 R0
SYMATTR InstName J4
SYMATTR Value U309
TEXT 110 216 Left 2 !.tran 4
On Wed, 16 Nov 2016 00:04:13 +0100, Piotr Wyderski wrote:

> Hello, > > I have a resistor R5 with some current flowing through it. > It is possible to plot I(R5) by simply selecting the resistor. > But is it possible to plot dI(R5)/dt? If yes, then how? > An example circuit:
Not directly, but you can make a current-dependent voltage source that has a Laplace transfer function for the gain. It'll need to be of the form H = s / (tau * s + 1), because SPICE doesn't like nekkid differentiators. -- Tim Wescott Control systems, embedded software and circuit design I'm looking for work! See my website if you're interested http://www.wescottdesign.com
On Tue, 15 Nov 2016 17:17:00 -0600, Tim Wescott <tim@seemywebsite.com>
wrote:

>On Wed, 16 Nov 2016 00:04:13 +0100, Piotr Wyderski wrote: > >> Hello, >> >> I have a resistor R5 with some current flowing through it. >> It is possible to plot I(R5) by simply selecting the resistor. >> But is it possible to plot dI(R5)/dt? If yes, then how? >> An example circuit: > >Not directly, but you can make a current-dependent voltage source that >has a Laplace transfer function for the gain. It'll need to be of the >form H = s / (tau * s + 1), because SPICE doesn't like nekkid >differentiators.
Or just use a buffer and a C-R circuit. -- John Larkin Highland Technology, Inc picosecond timing precision measurement jlarkin att highlandtechnology dott com http://www.highlandtechnology.com
On Wed, 16 Nov 2016 00:04:13 +0100, Piotr Wyderski
<piotr.wyderski.no.spam@gmail.com> wrote:

>Hello, > >I have a resistor R5 with some current flowing through it. >It is possible to plot I(R5) by simply selecting the resistor. >But is it possible to plot dI(R5)/dt? If yes, then how? >An example circuit: > >Version 4 >SHEET 1 916 680 >WIRE 256 16 144 16 >WIRE 464 16 336 16
[snip]
>SYMATTR Value U309 >TEXT 110 216 Left 2 !.tran 4
If the x-axis is time, simply add to the plot... d(I(R5)) At least that's how I do it in PSpice, which is Berkeley Spice compliant. In LTspice YMMV. ...Jim Thompson -- | James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | STV, Queen Creek, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I'm looking for work... see my website.
On Tue, 15 Nov 2016 15:25:33 -0800, John Larkin wrote:

> On Tue, 15 Nov 2016 17:17:00 -0600, Tim Wescott <tim@seemywebsite.com> > wrote: > >>On Wed, 16 Nov 2016 00:04:13 +0100, Piotr Wyderski wrote: >> >>> Hello, >>> >>> I have a resistor R5 with some current flowing through it. >>> It is possible to plot I(R5) by simply selecting the resistor. >>> But is it possible to plot dI(R5)/dt? If yes, then how? >>> An example circuit: >> >>Not directly, but you can make a current-dependent voltage source that >>has a Laplace transfer function for the gain. It'll need to be of the >>form H = s / (tau * s + 1), because SPICE doesn't like nekkid >>differentiators. > > Or just use a buffer and a C-R circuit.
Killjoy. -- Tim Wescott Control systems, embedded software and circuit design I'm looking for work! See my website if you're interested http://www.wescottdesign.com
On Tuesday, November 15, 2016 at 6:03:55 PM UTC-5, Piotr Wyderski wrote:
> Hello, > > I have a resistor R5 with some current flowing through it. > It is possible to plot I(R5) by simply selecting the resistor. > But is it possible to plot dI(R5)/dt? If yes, then how? > An example circuit: >
In general differentiation blows up at high frequency, (where things are changing faster) and you have to roll it off. <snip ltspice circuit> George H.
On Tue, 15 Nov 2016 20:08:22 -0600, Tim Wescott <tim@seemywebsite.com>
wrote:

>On Tue, 15 Nov 2016 15:25:33 -0800, John Larkin wrote: > >> On Tue, 15 Nov 2016 17:17:00 -0600, Tim Wescott <tim@seemywebsite.com> >> wrote: >> >>>On Wed, 16 Nov 2016 00:04:13 +0100, Piotr Wyderski wrote: >>> >>>> Hello, >>>> >>>> I have a resistor R5 with some current flowing through it. >>>> It is possible to plot I(R5) by simply selecting the resistor. >>>> But is it possible to plot dI(R5)/dt? If yes, then how? >>>> An example circuit: >>> >>>Not directly, but you can make a current-dependent voltage source that >>>has a Laplace transfer function for the gain. It'll need to be of the >>>form H = s / (tau * s + 1), because SPICE doesn't like nekkid >>>differentiators. >> >> Or just use a buffer and a C-R circuit. > >Killjoy.
I like to build my own test equipment in Spice. -- John Larkin Highland Technology, Inc lunatic fringe electronics
George Herold wrote:

> In general differentiation blows up at high frequency, > (where things are changing faster) and you have to > roll it off.
I think it is a general question of doing math operations on the sim results, which AFAIK is not something very user-friendly in LTspice. Exporting the results and finishing processing in, say, Octave is doable, but very inconvenient. Another option is to co-simulate your own analog computer the John Larkin's way, but if the operation is more complex, this approach quickly runs out of steam. c.
On 16/11/16 00:04, Piotr Wyderski wrote:
> Hello, > > I have a resistor R5 with some current flowing through it. > It is possible to plot I(R5) by simply selecting the resistor. > But is it possible to plot dI(R5)/dt? If yes, then how?
Copy the current at R5 with a current-controlled current source and apply this current to an auxiliary inductor. The voltage across the inductor will be L*dI(R5)/dt Pere
On Wednesday, November 16, 2016 at 6:36:43 AM UTC-5, circuitmaker wrote:
> George Herold wrote: > > > In general differentiation blows up at high frequency, > > (where things are changing faster) and you have to > > roll it off. > > I think it is a general question of doing math operations > on the sim results, which AFAIK is not something very > user-friendly in LTspice. Exporting the results and finishing > processing in, say, Octave is doable, but very inconvenient. > Another option is to co-simulate your own analog computer > the John Larkin's way, but if the operation is more complex, > this approach quickly runs out of steam. > > c.
Yeah, my mistake. Late at night and too quick a read. George H.