Math Puzzle...

Since someone (:-) will say, "Show us"...

[MACROS] pi=3.14159265 BETA(A)=I(A:c)/I(A:b) CAPINT=IMAG(-I(VAC))*IMAG(-I(VAC))-REAL(-I(VAC))*REAL(-I(VAC)) CAPRES=REAL(-I(VAC))/CAPINT CAPVAL=CAPINT/IMAG(-I(VAC))/(2*pi*FREQUENCY) CENTER(A)=A-MID(A) dBm(N,Z) = VdB(N)*sqrt(500/Z) GAIN(A,B)=(MAXX(A)-MINN(A))/(MAXX(B)-MINN(B)) GDB(A, B) = DB(PP(A))-DB(PP(B)) IMAG(A)=IMG(A) LoopGain=DB(RAWGAIN) LoopPhase=P(RAWGAIN*(-1)) MAGGAMMA=M(2*V(IN_NODE)-V(SRC_NODE)) MAGN(A)=M(A) MAXX(A)=MAX(A+100)-100 MID(A)=(MAXX(A)+MINN(A))/2 MINN(A)=MIN(A-100)+100 MODULATION(A)=(ENVMAX(A,1)-ENVMIN(A,1))/2 NF = 10*LOG10((V(INOISE)*V(INOISE))/VSRCSQ) NINETY(A)=A-0.9*MAXX(A)-0.1*MINN(A) OUTNOISE=SQRT(s(V(ONOISE)*V(ONOISE))) PF=AVG(-I(VPF)*V(VPF:+)/MAX(V(VPF:+)))*sqrt(2)/RMS(-I(VPF)) PH(A,B)=P(A)-P(B) PL1 = V(LG)@1 PL2 = V(LG)@2 PP(A)=MAXX(A)-MINN(A) PTAT(A)=(273+TEMP)/300*A Peak2Peak(A)=ENVMAX(A,1)-ENVMIN(A,1) QL1 = I(VMAC)@1 QL2 = I(VMAC)@2 RAWGAIN=PL1*(QL1*PL2+QL2*(1-PL1))/(QL2*PL1*PL1-QL1*PL2*(1+QL1)) REAL(A)=R(A) RET_LOSS=20*LOG10(MAGGAMMA) ROOT4KTR(A)=129P*SQRT(A) S11=2*(V(IN_NODE)/V(SRC_NODE))-1 S21=2*V(OUT_NODE) SATMARGIN(M,THRES)=MAGN(VD(M)-VS(M))-MAGN(VG(M)-VS(M))+MAGN(THRES) SOAG(M,VDS,VGS)=(SGN(VD(M)-VS(M)-VDS)+1)*(SGN(VG(M)-VS(M)-VGS)+1)/4 TEN(A)=A-0.1*MAXX(A)-0.9*MINN(A) VSRCSQ=16.5757565E-21*V(RSRC:1,RSRC:2)/I(RSRC) VSWR=(1+MAGGAMMA)/(1-MAGGAMMA) VdBnorm(A,B)=VdB(A)*PWR(10,(B/20))

These are all available post-simulation, and require no pre-anticipation additions to the schematic. ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142   Skype: Contacts Only  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson
Loading thread data ...

It doesn't do what I want. It is energy efficiency from time 0 to now; I want realtime efficiency, Pout/Pin. That must be smoothed in a switcher, because the true instantaneous values would be a mess.

--

John Larkin         Highland Technology, Inc 

jlarkin at highlandtechnology dot com 
http://www.highlandtechnology.com 

Precision electronic instrumentation 
Picosecond-resolution Digital Delay and Pulse generators 
Custom laser drivers and controllers 
Photonics and fiberoptic TTL data links 
VME thermocouple, LVDT, synchro   acquisition and simulation
Reply to
John Larkin

l

4

on.pdf"

Yes, sounds like he doesn't want that for some other reason, the AVG functi ons in Pspice are not confusing, they do what they should with no strange s haping or whatever.

And thats the nice thing about the Probe tool, its versatile and can do pre tty much what you want. In the good old days, it even accepted a simple ASC II formatted file, so you could export data from Excel into the Probe tool and run that without invoking spice.

Cheers

Klaus

Reply to
Klaus Kragelund

You can still do that... "export". I do that into Excel all the time. ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142   Skype: Contacts Only  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson

Apply Simpson's Rule to a 5% duty cycle pulse train.

--

John Larkin         Highland Technology, Inc 

jlarkin at highlandtechnology dot com 
http://www.highlandtechnology.com 

Precision electronic instrumentation 
Picosecond-resolution Digital Delay and Pulse generators 
Custom laser drivers and controllers 
Photonics and fiberoptic TTL data links 
VME thermocouple, LVDT, synchro   acquisition and simulation
Reply to
John Larkin

Integrals are integrals. Simpson's Rule can integrate _any_ shape. ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142   Skype: Contacts Only  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson

ng

,

at

e

JT

Jul

a
X

n.

a
X
o
s
d
e
e
s
r
u
n
d
,
g
e
t
o
l
g
e
f
e
e
a
o
t
r
o
s
P

far

X

ge 4

ution.pdf"

)
o
e
c

he

G

ng

ed

n

ple

u

ctions in Pspice are not confusing, they do what they should with no strang e shaping or whatever.

pretty much what you want. In the good old days, it even accepted a simple ASCII formatted file, so you could export data from Excel into the Probe to ol and run that without invoking spice.

I actually meant import, from Excel into Probe.

Just opened Probe 16.2 up, and I see that now have that function back in pr obe. Nice :-)

Cheers

Klaus

Reply to
Klaus Kragelund

Simpson's rule is based on quadratic interpolation, i.e. it assumes that the integrand has continuous derivatives of at least second order.

It's true that if you make the mesh sufficiently fine, it will converge to any given accuracy, but it's also true that the rectangle rule will in general do a much better job with functions that don't have continuous second derivatives.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
ElectroOptical Innovations LLC 
Optics, Electro-optics, Photonics, Analog Electronics 

160 North State Road #203 
Briarcliff Manor NY 10510 USA 
+1 845 480 2058 

hobbs at electrooptical dot net 
http://electrooptical.net
Reply to
Phil Hobbs

A lot of the things OrCAD did in their attempt to neuter PSpice are "accomplished" by lines in the INI file. A buddy at ON Semi put me on to that. You can even restore the old original MicroSim PCB stuff if you still have that installation disk ;-) ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142   Skype: Contacts Only  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson

Perhaps I'm using the wrong term... my idea of Simpson's Rule is simply rectangular strips... pure graphical integration. ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142   Skype: Contacts Only  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson

That's the rectangle rule.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
ElectroOptical Innovations LLC 
Optics, Electro-optics, Photonics, Analog Electronics 

160 North State Road #203 
Briarcliff Manor NY 10510 USA 
+1 845 480 2058 

hobbs at electrooptical dot net 
http://electrooptical.net
Reply to
Phil Hobbs

I never met him ;-) ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
| Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    | 
| San Tan Valley, AZ 85142   Skype: Contacts Only  |             | 
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  | 
| E-mail Icon at http://www.analog-innovations.com |    1962     | 
              
I love to cook with wine.     Sometimes I even put it in the food.
Reply to
Jim Thompson

You can certainly apply it to any shape. It only uses three points. It only works reasonably if the function is smooth over those three points, which a pulse train isn't.

formatting link

I can't see how Simpson's Rule makes any sense when applied to a discrete data set, or how it would be useful in averaging Spice waveforms. I can see why Mike left averaging out of LT Spice.

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation 
Picosecond-resolution Digital Delay and Pulse generators 
Custom timing and laser controllers 
Photonics and fiberoptic TTL data links 
VME  analog, thermocouple, LVDT, synchro, tachometer 
Multichannel arbitrary waveform generators
Reply to
John Larkin

The average is just the 0th term of a Fourier transform, and it has the same windowing problem. A rectangular window can create noisy averages. In the case of a switching regulator or other pulsed waveform, the difference between summing N pulses and N+1 could make an ugly graph unless N is very large. Some tapered window would be better than a rectangular one. A simulated lowpass filter acts like a smoother windowing function.

If LT Spice were to have an averaging function, it should ask for a windowing function and a timewidth/bandwidth. It would be very compute intensive to do sliding-window averaging.

It's not hard to throw a lowpass filter down on the schematic.

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation 
Picosecond-resolution Digital Delay and Pulse generators 
Custom timing and laser controllers 
Photonics and fiberoptic TTL data links 
VME  analog, thermocouple, LVDT, synchro, tachometer 
Multichannel arbitrary waveform generators
Reply to
John Larkin

I see no difference in sim speed if I delete my BV source and is efficiency equation, which includes LIMIT()

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation 
Picosecond-resolution Digital Delay and Pulse generators 
Custom timing and laser controllers 
Photonics and fiberoptic TTL data links 
VME  analog, thermocouple, LVDT, synchro, tachometer 
Multichannel arbitrary waveform generators
Reply to
John Larkin

It's easy. But you cannot change it after the simulation has run, so to change the averaging you need to run again and wait. That's the advantage of adding the math in the Probe window

Cheers

Klaus

Reply to
Klaus Kragelund

Windowing can cause big problems. Wikipedia explains what can happen with a simple moving average:

"An SMA can also be disproportionately influenced by old datum points dropping out or new data coming in. One characteristic of the SMA is that if the data have a periodic fluctuation, then applying an SMA of that period will eliminate that variation (the average always containing one complete cycle)."

"

formatting link
"

This appears to be what is happening in an example of a 100ns moving average taken from

"

formatting link
"

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 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V1 SYMATTR Value PULSE(0 2 0 5n 0 0 10n) SYMBOL bv 0 288 R0 WINDOW 3 50 94 Left 2 SYMATTR Value V=idt(V(x)-absdelay(V(x),100n))/100n SYMATTR InstName B1 TEXT 128 24 Left 2 !.tran 200n TEXT 136 -16 Left 2 ;'100ns Moving Average

I modified it to show the results on a 5ns sawtooth with a period of

10ns.

If the 100n values whown above are used, the function V increases until the analysis reaches 100ns, then it becomes a flat line. This is where the window matches the period.

If the 100n is changed to 105n, the result is dramatically different. The function increases until it reaches 100ns as before, then it changes from a flat line to a roughly sinusoidal ripple. Why it doesn't display the same ripple prior to reaching 100ns is a mystery to me.

From this, it appears the idt function may have other problems besides the ones mentioned previously. These problems do not appear when using the low pass filter method.

Using the low pass filter, you can choose the type of filter you want - RC, Bessel, Gaussian, Equiripple, Transitional, etc. You could also remove low frequency components by using a bandpass filter. You could also notch an undesired frequency with a simple twin-t. All things considered, the low pass filter offers the most flexibility, is easy to understand, and doesn't have the windowing problems of a moving average in software.

JK

Reply to
John K

John K wrote:

UPDATE: Here is a comparison of the 100ns moving average, a 100ns RC filter, and a 10MHz Bessel. If anyone needs a reason to use filtering instead of a moving average, this should help.

The 100ns RC filter is far more believable than the 100ns moving average.

The 10MHz Bessel gives the fastest risetime and the lowest ripple.

If you need a free filter program that is very easy to use, try Elsie:

formatting link

JK

Version 4 SHEET 1 880 680 WIRE 16 32 0 32 WIRE 80 32 16 32 WIRE 320 32 80 32 WIRE 480 32 400 32 WIRE 496 32 480 32 WIRE 496 48 496 32 WIRE 0 80 0 32 WIRE 496 128 496 112 WIRE 0 176 0 160 WIRE 80 176 80 32 WIRE 176 176 80 176 WIRE 272 176 256 176 WIRE 304 176 272 176 WIRE 416 176 384 176 WIRE 464 176 416 176 WIRE 496 176 464 176 WIRE 272 192 272 176 WIRE 416 192 416 176 WIRE 496 192 496 176 WIRE 16 272 0 272 WIRE 112 272 16 272 WIRE 272 288 272 256 WIRE 416 288 416 256 WIRE 496 288 496 272 WIRE 0 304 0 272 WIRE 0 400 0 384 FLAG 0 176 0 FLAG 0 400 0 FLAG 16 32 X FLAG 16 272 avgx FLAG 496 128 0 FLAG 480 32 RC FLAG 272 288 0 FLAG 416 288 0 FLAG 496 288 0 FLAG 464 176 Bessel SYMBOL voltage 0 64 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 WINDOW 3 -85 142 Left 2 SYMATTR Value PULSE(0 2 0 5n 0 0 10n) SYMATTR InstName V1 SYMBOL bv 0 288 R0 WINDOW 3 50 94 Left 2 SYMATTR Value V=idt(V(x)-absdelay(V(x),D))/D SYMATTR InstName B1 SYMBOL res 416 16 R90 WINDOW 0 0 56 VBottom 2 WINDOW 3 32 56 VTop 2 SYMATTR InstName R1 SYMATTR Value 1k SYMBOL cap 480 48 R0 SYMATTR InstName C1 SYMATTR Value 100pf SYMBOL cap 256 192 R0 SYMATTR InstName C2 SYMATTR Value 36pf SYMBOL cap 400 192 R0 SYMATTR InstName C3 SYMATTR Value 5.6pf SYMBOL ind 288 192 R270 WINDOW 0 32 56 VTop 2 WINDOW 3 5 56 VBottom 2 SYMATTR InstName L1 SYMATTR Value 15µh SYMBOL res 480 288 M180 WINDOW 0 36 76 Left 2 WINDOW 3 36 40 Left 2 SYMATTR InstName R2 SYMATTR Value 1k SYMBOL res 272 160 R90 WINDOW 0 0 56 VBottom 2 WINDOW 3 32 56 VTop 2 SYMATTR InstName R3 SYMATTR Value 1k TEXT 16 -24 Left 2 !.tran 200n TEXT 16 -48 Left 2 ;'100ns Moving Average vs 100ns RC & 10MHz Bessel TEXT 48 352 Left 2 !.param D = 100n

[Transient Analysis] { Npanes: 3 Active Pane: 1 { traces: 1 {589827,0,"V(bessel)"} X: ('n',0,0,2e-008,2e-007) Y[0]: ('m',0,0,0.03,0.3) Y[1]: ('_',0,1e+308,0,-1e+308) Volts: ('m',0,0,0,0,0.03,0.3) Log: 0 0 0 GridStyle: 1 }, { traces: 2 {524292,0,"V(rc)"} {589833,0,"V(avgx)"} X: ('n',0,0,2e-008,2e-007) Y[0]: ('m',0,0,0.06,0.6) Y[1]: ('_',0,1e+308,0,-1e+308) Volts: ('m',0,0,0,0,0.06,0.6) Log: 0 0 0 GridStyle: 1 }, { traces: 1 {524290,0,"V(x)"} X: ('n',0,0,2e-008,2e-007) Y[0]: (' ',1,-0.2,0.2,2) Y[1]: ('_',0,1e+308,0,-1e+308) Volts: (' ',0,0,1,-0.2,0.2,2) Log: 0 0 0 GridStyle: 1 } }
Reply to
John K

Okay. Change the filter caps to 100nF each. B3 gets better and the efficiency never goes over 100%.

Reply to
John S

LT Spice doesn't like that stuff at the end, beginning [Transient Analysis]

--

John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    

Precision electronic instrumentation 
Picosecond-resolution Digital Delay and Pulse generators 
Custom timing and laser controllers 
Photonics and fiberoptic TTL data links 
VME  analog, thermocouple, LVDT, synchro, tachometer 
Multichannel arbitrary waveform generators
Reply to
John Larkin

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.