LTspice: plotting the integral of a waveform

Status
Not open for further replies.

mikewax

Member
THANX guys for ur assistance with my spice problems

now i've made and plotted a working circuit, a DC buck convertor, with LTspice and started tweaking it around. But one of the traces on my plot shows a math function that is not producing the right #s and i can't figure out why. The current thru R1 is supposed to be equal to the instantaneous average of the current through V2.
The equation for V is the integral of the (green) current thru V2, summed over a Δt of 22u, divided by 22u. So the white trace at the top is supposed to be parallel with the green one underneath. And at the beginning, it is. But the deviation looks very linear, like there's some kind of bias goin on in B1. I have zoomed in systematically at each 10ms interval and compared the average of the two traces. the top one is definitely deviating and has the wrong slope. anyone know what the problem could be?

 

Attachments

  • buck.asc
    1.4 KB · Views: 372
Your formula for B1 is incorrect. Try this instead:
v=-idt(i(v2)+delay(i(v2),22u))/44u
 
A 10 mF (10000 uf) capacitor looks a very large value on the output of a switching regulator.

Les.
 
It works for me. Did you notice the sign change?
well i don't know what i'm not seeing, because when i use the formula for B1, V = -idt(I(V2) + delay(I(V2), 10u))/20u, what i'm getting is this:

and the numbers show the same thing:
avi1: AVG(i(v2))=-0.00927139 FROM 0.01 TO 0.0101 <--- 10ms
avr1: i(r1)=23.9429 at 0.01 <-----V = -idt(I(V2) + delay(I(V2), 10u))/20u
avi2: AVG(i(v2))=-0.00904411 FROM 0.02 TO 0.0201 <--- 20ms
avr2: i(r1)=33.2628 at 0.02
avi3: AVG(i(v2))=-0.00918508 FROM 0.03 TO 0.0301 <--- 30ms
avr3: i(r1)=42.5975 at 0.03

when i use this formula for B1, V = idt(I(V2) - delay(I(V2), 10u))/10u, i get this:

which looks fairly accurate at a scale of 40ms, but at 400ms, it looks like this:


so neither formula seems to be giving the average of the curve for the current I(V2) which is what i need to be able to do the circuit. it seems like such a simple thing, a basic integral. but it just ain't workin.
thanx alec
 
hi Mike,
Its an accumulation of transient tolerance errors in the LTS maths, to demonstrate the effect of these tolerances try changing Trtol [ Transient error tolerance] in LTS Tools.

The Default value is 1, try 7, you will see that I(R1) curve error is an an artefact of the LTS maths.

Why are you charging a super cap in this way.?

E
 
I note that the average obtained using your formula gives wildly different results depending on the value chosen for the sample interval. (Not surprising, since the samples are being taken at non-random instants related to the switching of V1). Change the '10u' to '40u', for example, and see. For a true average value I reckon the formula would be V=idt(I(V2))/time.
 
ok i had to google that. so these transient errors are coming out of my integral equation? and they accumulate? in spite of the fact that the data that i'm integrating over remains essentially constant? when i changed the Trtol to 7 i got this:
the red line is holding pretty constant at about .009, while my equation just walks away. this **** is over my head.

i work for a rich tinkerer. He grabbed a webcam, stuck it on a motorized gimbal, and said "this thing plugs into the usb port. every 60 seconds the motor has to run for 1 second at 5v, 800mA. And put limit switches to make it reverse every 200 degrees of rotation"
right away sir....
 
WOW. you're really on to something. cause when i changed Δt to 40, i got this:

that's WAY better.

OK i'm gonna keep tweakin the numbers. increasing Δt and Trtol brought the error way down. i don't really understand this, but i'm gonna keep workin n maybe i will.
THANX fellas. now i can make progress again. )))))
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…