Maker Pro
Maker Pro

AVG and RMS in LTSpice?

J

Joerg

Jan 1, 1970
0
Ok, guys, I don't use Spice much and usually get around this stuff via
some extra placed parts. Not this time.

How can one calculate the (running) average of a trace? IOW as if there
was an RC or LC lowpass. Or something where I can set a scooting window.

I know you can find out the AVG by zooming the plot, then
CTRL-right_click. But I'd like graphs that show me efficiency penalties
over the course of simulated load changes. It doesn't spit out the raw
data and I don't really want to go via Excel if possible. Also,
preferably not the V-Source plus I-Source scheme of LTSpice because
that's restricted to one each.
 
J

Joerg

Jan 1, 1970
0
D said:
Dunno if I've grasped the problem, but it reminds me of the time I was
sim'ing PWM instability.
It's goofy to check the length of hundreds of pulses in LTSpice.
So I made a spice circuit to help me spot PWM variations as LTSpice
was plotting.
Fake circuits to help design real circuits. :)
I just call'm helper circuits to get quick analysis.

Perhaps make the electronic equivalent for the behavior you want to
observe.

That's exactly what I've been doing for years. This time it would really
clutter things though. Lots of currents to be measure and filtered. I
was just wondering whether there was a reasonable math approach.
 
J

Jonathan Kirwan

Jan 1, 1970
0
Ok, guys, I don't use Spice much and usually get around this stuff via
some extra placed parts. Not this time.

How can one calculate the (running) average of a trace? IOW as if there
was an RC or LC lowpass. Or something where I can set a scooting window.

I know you can find out the AVG by zooming the plot, then
CTRL-right_click. But I'd like graphs that show me efficiency penalties
over the course of simulated load changes. It doesn't spit out the raw
data and I don't really want to go via Excel if possible. Also,
preferably not the V-Source plus I-Source scheme of LTSpice because
that's restricted to one each.

I just use the mouse to highlight a desired rectangle and release. The
chart expands. Then I use ctrl-right-mouse-click, I think, to get the
AVG and RMS figures. Something like that... it just pops up in a
small dialog box.

Jon
 
A

Andrew Holme

Jan 1, 1970
0
Joerg said:
Ok, guys, I don't use Spice much and usually get around this stuff via
some extra placed parts. Not this time.

How can one calculate the (running) average of a trace? IOW as if there
was an RC or LC lowpass. Or something where I can set a scooting window.

What about an arbitrary voltage source with something like:

V=idt(V(x)-absdelay(V(x),100n))/100n

for a 100ns moving average?
 
J

Joerg

Jan 1, 1970
0
Jim said:
Aren't functions AVG (full average) and AVGX (average over a specified
range) available in LTspice?

Nope :-(

They're in PSpice.

I have a really old DOS PSPICE license, maybe time to fire it up again.
 
A

Andrew Holme

Jan 1, 1970
0
Andrew Holme said:
What about an arbitrary voltage source with something like:

V=idt(V(x)-absdelay(V(x),100n))/100n

for a 100ns moving average?

Also needed an initial value:


Version 4
SHEET 1 880 680
WIRE 64 48 0 48
WIRE 96 48 64 48
WIRE 0 80 0 48
WIRE 0 192 0 160
WIRE 80 272 0 272
WIRE 112 272 80 272
WIRE 0 304 0 272
WIRE 0 416 0 384
FLAG 0 192 0
FLAG 0 416 0
FLAG 64 48 x
FLAG 80 272 avgx
SYMBOL voltage 0 64 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V1
SYMATTR Value PULSE(-1 2 50n 0 0 5n 10n)
SYMBOL bv 0 288 R0
SYMATTR InstName B1
SYMATTR Value V=idt(V(x)-delay(V(x),100n),V(x)*100n)/100n
TEXT 232 264 Left 0 !.tran 200n
 
Q

qrk

Jan 1, 1970
0
Ok, guys, I don't use Spice much and usually get around this stuff via
some extra placed parts. Not this time.

How can one calculate the (running) average of a trace? IOW as if there
was an RC or LC lowpass. Or something where I can set a scooting window.

I know you can find out the AVG by zooming the plot, then
CTRL-right_click. But I'd like graphs that show me efficiency penalties
over the course of simulated load changes. It doesn't spit out the raw
data and I don't really want to go via Excel if possible. Also,
preferably not the V-Source plus I-Source scheme of LTSpice because
that's restricted to one each.

Perhaps LTspice's .MEASURE (or .MEAS) statement might be useful to
you. There are two ways of using the .meas statement. You can place it
in your simulation as a statement and view the results in an error log
report or execute the statement in an external text file after the
simulation is done.

Example:
Place the .meas statement (don't put in the "---") in your schematic
(click on the ".op" button in the tool bar with the schematic as the
active window):

---
..meas tran Vt integ v(B+,d)/200us
+ trig v(gate) val=.5 td=700us rise=1
+ targ v(gate) val=.5 td=900us rise=1
---

I could have used the following and gotten the same result:
..meas tran Vt avg v(B+,d)
+ trig v(gate) val=.5 td=700us rise=1
+ targ v(gate) val=.5 td=900us rise=1

Run the simulation.
With the schematic as the active window, click on View|Spice error
log. You'll get a report as follows with your result:

---
Circuit: * E:\Proj\PowerSupply\Spice\TutorialActiveReset.asc

Direct Newton iteration for .op point succeeded.

vt: INTEG(v(b+,d)/200us)=0.0178886 FROM 0.000700805 TO 0.000900805

Date: Tue Jul 15 09:49:16 2008
Total elapsed time: 6.625 seconds.

tnom = 27
temp = 27
method = modified trap
totiter = 441476
traniter = 441461
tranpoints = 126668
accept = 99059
rejected = 27609
trancuriters = 0
matrix size = 17
fillins = 0
solver = Normal
 
J

Joerg

Jan 1, 1970
0
qrk said:
Perhaps LTspice's .MEASURE (or .MEAS) statement might be useful to
you. There are two ways of using the .meas statement. You can place it
in your simulation as a statement and view the results in an error log
report or execute the statement in an external text file after the
simulation is done.

Example:
Place the .meas statement (don't put in the "---") in your schematic
(click on the ".op" button in the tool bar with the schematic as the
active window):

---
.meas tran Vt integ v(B+,d)/200us
+ trig v(gate) val=.5 td=700us rise=1
+ targ v(gate) val=.5 td=900us rise=1
---

I could have used the following and gotten the same result:
.meas tran Vt avg v(B+,d)
+ trig v(gate) val=.5 td=700us rise=1
+ targ v(gate) val=.5 td=900us rise=1

Run the simulation.
With the schematic as the active window, click on View|Spice error
log. You'll get a report as follows with your result:

---
Circuit: * E:\Proj\PowerSupply\Spice\TutorialActiveReset.asc

Direct Newton iteration for .op point succeeded.

vt: INTEG(v(b+,d)/200us)=0.0178886 FROM 0.000700805 TO 0.000900805

Date: Tue Jul 15 09:49:16 2008
Total elapsed time: 6.625 seconds.

tnom = 27
temp = 27
method = modified trap
totiter = 441476
traniter = 441461
tranpoints = 126668
accept = 99059
rejected = 27609
trancuriters = 0
matrix size = 17
fillins = 0
solver = Normal
---

Thus, vt = 0.0179

You can read more about this in LTspice's Help under ".measure".

Thanks, Mark! That may be the ticket here. All I need is a few results,
it's ok if I don't really get an efficiency graph. Clicking around in
the plot window is too time consuming for rapid-fire optimizations.
 
Top