Maker Pro
Maker Pro

LTspice: plotting the integral of a waveform

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
Hello,
i have this circuit that i did with LTspice, a DC buck voltage convertor. When I did the simulation, 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. See Bellow. The picture shows the current coming out of V2, the green part.
on the bottom right, the equation for V is the integral of the (green) current thru V2, summed over a Δt of 22u seconds, divided by 22u. So the current thru the resistor (the top trace) is supposed to be equal to the instantaneous average of the current through V2.
Therefore the top trace 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?

buck.jpg
 

Attachments

  • buck.asc
    1.4 KB · Views: 77

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
THe lines are very parallel in my simulation:
upload_2016-11-10_9-21-56.png

I'm using LTSPICE XVII. Could this make a difference?
 

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
THe lines are very parallel in my simulation:
I'm using LTSPICE XVII. Could this make a difference?

looking at the picture i can't tell. could you try this one for me and see what the numbers are?
buck.jpg
thanx, mike
 

Attachments

  • buck.asc
    1.7 KB · Views: 76

Alec_t

Jul 7, 2015
3,587
Joined
Jul 7, 2015
Messages
3,587
I think your problem is that you haven't allowed for the current through the zener.
Here's a mod of your sim, with B2 added to monitor the inductor current rather than V1 current. The two curves now coincide.
Buck-mod.JPG
 

Attachments

  • buck-mod.asc
    2.1 KB · Views: 74

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
I think your problem is that you haven't allowed for the current through the zener.
Here's a mod of your sim, with B2 added to monitor the inductor current rather than V1 current. The two curves now coincide.

yeah i see what you mean but what i have to do is see the average current in V2. this is because V2 represents a usb port. i'm trying to charge a supercap off the usb line, so the point is to control how much current the circuit is drawing at V2.
 
Last edited:

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
could you try this one for me and see what the numbers are?
Here you go:
Direct Newton iteration for .op point succeeded.

avi1: AVG(i(v2))=-0.00927009 FROM 0.01 TO 0.0101
avr1: i(r1)=0.00832488 at 0.01
avi2: AVG(i(v2))=-0.00892225 FROM 0.04 TO 0.0401
avr2: i(r1)=0.017155 at 0.04
avi3: AVG(i(v2))=-0.00879679 FROM 0.08 TO 0.0801
avr3: i(r1)=0.0297595 at 0.08
 

mike wax

Oct 10, 2016
34
Joined
Oct 10, 2016
Messages
34
How about this:
THAT'S IT!!! it's PERFECT, ZERO ERROR! it never occured to me to integrate it with a cap! now i'm gonna proceed with my design. what a relief.
but i don't quite get it. how did you figure the size of the cap?
 
Top