Math Puzzle...

Jul 06, 2013 176 Replies

OK, you can't make it work.

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

If I could ever persuade you to eat a fried oyster po-boy, you'd be even more impressed.

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

Yes >:-} ...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.

My refusal to give you the learning you were supposed to have does not in any way mean that i cannot do the work. I have been making it work about once every three to five years for a long time. I usually use the 5 point sliding form.

I think it does.

I have been making it work about

How can that work from a Spice sim of a low duty cycle pulse train, as you would find in a switching regulator? You can't just pick 5 points and essentially model them as a low-order polynomial. The resulting averages would be all over the place.

And if the sim has a time step of, say, 1 ns, would you pick 5 points that span 4 ns? That wouldn't be very good for, say, a 1 MHz switcher.

More generally, if you have numerical time-series data in a computer file, it doesn't make sense to use a classical continuous-function polynomial approach to find running averages.

The Simpson algorithm is essentially a windowed summation. But the number of samples is going to have to be large to smooth out the sorts of waveforms you see in a switcher sim. Numerically, one could do a gaussian or trapezoidal windowed running average of enough points to span many (10? 50?) cycles of the switcher period. Rectangular windowing (a simple sliding average) would need to span hundreds of cycles to get a smooth graph.

You get a nice smooth windowed sliding average from a simple lowpass filter, and you don't have to know the Spice time step. And you can compute and graph it as the sim is running, not as some post-sim compute-and-plot process.

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

[snip]

Nonsense! PSpice Probe has had marching waveforms ever since I can remember... and do the "compute and graph" following along as the "parade" progresses >:-}

(BTW: AVGX doesn't require _any_ knowledge of "Spice time step")

Someone should set up a simulation that compares AVGX against your "filter" method. ...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.

Someone? You're the Pspice expert. Do it.

Or are you in the jkk camp, claiming something is easy but refusing to demonstrate? I've posted my filter things, with both 1st and 2nd order filtered current shunts.

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

Of course I am, and will >:-}

I'm curious as to the outcome myself. I don't know off the top of my head what the errors will be. But I will set it all up and find out... AND post it. ...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.

What does AVGX do? Is there a user parameter that sets the averaging window?

Is it a rectangular window? Averaging is basically convolution, so you could test it be averaging a narrow pulse.

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

Yes. Syntax: AVGX(signal-name,interval)

I don't know and you're right... I will experiment to find out exactly what it does. ...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.

Posted at...

Subject: AVGX==Convolution - AVGX_ConvolutionVsFilter.png Date: Fri, 12 Jul 2013 11:53:41 -0700 Message-ID: ...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.

Step response posted at...

Newsgroups: alt.binaries.schematics.electronic Subject: Re: AVGX==Convolution - Step Response - AVGX_ConvolutionVsFilter_WithStep.png Date: Fri, 12 Jul 2013 16:36:40 -0700 Message-ID: ...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.

It guess AVGX is rectangular integration.

Here are a few filters. The 2nd order one is a good compromise between ripple, speed, and delay.

Version 4 SHEET 1 932 680 WIRE 304 -224 96 -224 WIRE 528 -224 384 -224 WIRE 816 -224 608 -224 WIRE 880 -224 816 -224 WIRE 928 -224 880 -224 WIRE 96 -80 96 -224 WIRE 304 -80 96 -80 WIRE 672 -80 384 -80 WIRE 880 -80 672 -80 WIRE 928 -80 880 -80 WIRE 96 64 96 -80 WIRE 176 64 96 64 WIRE 304 64 176 64 WIRE 496 64 384 64 WIRE 880 64 496 64 WIRE 928 64 880 64 WIRE 496 112 496 64 WIRE 672 112 672 -80 WIRE 816 112 816 -224 WIRE 96 128 96 64 WIRE 96 240 96 208 WIRE 496 272 496 176 WIRE 672 272 672 176 WIRE 816 272 816 176 WIRE 96 352 96 320 FLAG 96 352 0 FLAG 496 272 0 FLAG 672 272 0 FLAG 816 272 0 FLAG 880 64 A FLAG 880 -80 B FLAG 880 -224 C FLAG 176 64 GEN SYMBOL voltage 96 112 R0 WINDOW 3 -397 15 Left 2 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V1 SYMATTR Value PULSE(0 1 0 1n 1n 100n 1u 100) SYMBOL voltage 96 224 R0 WINDOW 3 -404 12 Left 2 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V2 SYMATTR Value PULSE(0 1 50u 1n 1n 100n 1u 50) SYMBOL res 400 48 R90 WINDOW 0 -21 85 VBottom 2 WINDOW 3 -45 46 VTop 2 SYMATTR InstName R1 SYMATTR Value 1 SYMBOL res 400 -96 R90 WINDOW 0 -18 81 VBottom 2 WINDOW 3 -43 41 VTop 2 SYMATTR InstName R2 SYMATTR Value 1 SYMBOL res 400 -240 R90 WINDOW 0 -26 81 VBottom 2 WINDOW 3 -54 40 VTop 2 SYMATTR InstName R3 SYMATTR Value 1 SYMBOL cap 480 112 R0 WINDOW 0 -58 25 Left 2 WINDOW 3 -61 63 Left 2 SYMATTR InstName C1 SYMATTR Value 10µ SYMBOL cap 656 112 R0 WINDOW 0 -55 19 Left 2 WINDOW 3 -56 59 Left 2 SYMATTR InstName C2 SYMATTR Value 50µ SYMBOL cap 800 112 R0 WINDOW 0 -43 9 Left 2 WINDOW 3 -47 54 Left 2 SYMATTR InstName C3 SYMATTR Value 5µ SYMBOL ind 512 -208 R270 WINDOW 0 62 19 VTop 2 WINDOW 3 89 64 VBottom 2 SYMATTR InstName L1 SYMATTR Value 1.6µ TEXT -168 -16 Left 2 !.tran 150u TEXT -248 -184 Left 2 ;Some Smoothing Filters TEXT -184 -120 Left 2 ;JL July 2013

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

It's a convolution divided by the "box" width'

All schemes have delay. The difference is step response.

...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.

Convolution of what? Looks like a rectangular pulse.

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

Put on your reading glasses ;-)....

Newsgroups: alt.binaries.schematics.electronic Subject: AVGX_Test_Convolution_Expanded (SED) - AVGX_Test_Convolution_Expanded.png Date: Sat, 13 Jul 2013 18:07:22 -0700 Message-ID: ...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.

Good grief, they didn't even bother to center the window. So it combines the worst features of rectangular integration (sinc response) with the worst features of filtering (time delay.)

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

Well, doesn't it just perform what would be expected? That is a running average from from the last displayed valued and x back? (at least that would be what I would want in a probe window, no shaping that needs to be taken into consideration)

Regards

Klaus

Klaus Kragelund wrote:

You still get the windowing effect when the window size matches the period of the signal. This changes the resulting average and you get a different number. So you cannot depend on software integration to deliver a reliable result.

The same effect occurs when using idt in LTspice. I show below the results with two different averaging formula. One requires an extremely small maximum timetep, the other is independant of the timestep.

Notice how the avgx signal flattens to a straight line at T=100ns.

Both version show different averaging results when the window size is changed from 100ns to 105ns. The result changes from a flat line to a semi-sinusoidal ripple signal.

You do have to fiddle with the window size parameter to avoid these effects. But if the input frequency changes during the analysis, you may find it imossible to avoid the windowing effect and the resulting changes in the average.

I include a simple RC filter with a time constant equal to 10 times the period of the input signal, plus a simple 3 pole Bessel with a cutoff of

1/10 the input frequency.

In all cases, the 3 pole Bessel exhibits the fastest risetime and the lowest ripple of all.

The Bessel and RC filters are not affected by the time step setting or the window size.

In addition, you can include a high pass function in the LC and Bessel filters to remove a DC component. You can also add a simple Twin-T notch filter to remove some unwanted frequency. You cannot do either with the AVGX software function.

JK

Here is the LTspice ASC file. It is followed by the PLT file which shows the desired signals grouped into 3 different panes for clarity. Please save the PLT file with the same prefix as the ASC file, but with the PLT extension. As usual, please fix the wrap in the ASC file at the end.

Version 4 SHEET 1 880 680 WIRE 16 32 0 32 WIRE 80 32 16 32 WIRE 304 32 80 32 WIRE 480 32 384 32 WIRE 496 32 480 32 WIRE 496 48 496 32 WIRE 0 64 0 32 WIRE 496 128 496 112 WIRE 0 160 0 144 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 160 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 48 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 WINDOW 3 -67 146 Left 2 SYMATTR Value PULSE(0 2 0 5n 0 0 10n) SYMATTR InstName V1 SYMBOL bv 0 288 R0 WINDOW 3 53 24 Left 2 WINDOW 0 11 13 Left 2 SYMATTR Value V=(idt(V(x)-absdelay(V(x),D)))/D SYMATTR InstName B1 SYMBOL res 400 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 -160 Left 2 !.tran 0 200n 0 1ps TEXT -16 -184 Left 2 ;'100ns Moving Average vs 100ns RC & 10MHz Bessel TEXT 160 -160 Left 2 !.param D = 100n TEXT 416 -160 Left 2 !.options plotwinsize=0 TEXT 56 400 Left 2 ;2. V=(idt(V(x)-absdelay(V(x),D)))/D TEXT 56 376 Left 2 ;1. V=(idt(V(x))-delay(idt(V(x)),D))/D TEXT 56 352 Left 2 ;Versions TEXT -8 -112 Left 2 ;Notes:\n1. Set param D to 105ns to show effect of window size on AVGX\n2. Set Max Timestep to 10ps to show effect an AVGX \n3. Use Version 2 and delete Max Timestep to show effect of absdelay

Here is the PLT file. Save it with the same file prefix but with a PLT file extension.

[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 } }

Oops - I had switched the avgx formlua to the absdelay version for testing and forgot to switch it back. This would confuse people, so here is the ASC file with the original formula.

You can use the same PLT file. As usual, please fix the wrap at the end. This is caused by the news client.

JK

Version 4 SHEET 1 880 680 WIRE 16 32 0 32 WIRE 80 32 16 32 WIRE 304 32 80 32 WIRE 480 32 384 32 WIRE 496 32 480 32 WIRE 496 48 496 32 WIRE 0 64 0 32 WIRE 496 128 496 112 WIRE 0 160 0 144 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 160 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 48 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 WINDOW 3 -67 146 Left 2 SYMATTR Value PULSE(0 2 0 5n 0 0 10n) SYMATTR InstName V1 SYMBOL bv 0 288 R0 WINDOW 3 53 24 Left 2 WINDOW 0 11 13 Left 2 SYMATTR Value V=(idt(V(x))-delay(idt(V(x)),D))/D SYMATTR InstName B1 SYMBOL res 400 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 -160 Left 2 !.tran 0 200n 0 10ps TEXT -16 -184 Left 2 ;'100ns Moving Average vs 100ns RC & 10MHz Bessel TEXT 160 -160 Left 2 !.param D = 100n TEXT 416 -160 Left 2 !.options plotwinsize=0 TEXT 56 400 Left 2 ;2. V=(idt(V(x)-absdelay(V(x),D)))/D TEXT 56 376 Left 2 ;1. V=(idt(V(x))-delay(idt(V(x)),D))/D TEXT 56 352 Left 2 ;Versions TEXT -8 -112 Left 2 ;Notes:\n1. Set param D to 105ns to show effect of window size on AVGX\n2. Set Max Timestep to 100ps to show effect an AVGX \n3. Use Version 2 and delete Max Timestep to show effect of absdelay

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required