Connect with us

LTspice: plotting the integral of a waveform

Discussion in 'Electronics Homework Help' started by mike wax, Nov 10, 2016.

Scroll to continue with content
  1. mike wax

    mike wax

    34
    2
    Oct 10, 2016
    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
     

    Attached Files:

  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,997
    2,813
    Nov 17, 2011
    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?
     
  3. mike wax

    mike wax

    34
    2
    Oct 10, 2016
    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
     

    Attached Files:

  4. Alec_t

    Alec_t

    3,060
    834
    Jul 7, 2015
    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
     

    Attached Files:

  5. mike wax

    mike wax

    34
    2
    Oct 10, 2016
    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: Nov 11, 2016
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    11,997
    2,813
    Nov 17, 2011
    Here you go:
     
  7. mike wax

    mike wax

    34
    2
    Oct 10, 2016
    yeah that's what i thought. the first #, avr1, is pretty close, but the 2nd and 3rd #s are way off. my equation just doesn't work. gotta find a different way to do this.

    thanx Harald :)
     
  8. Harald Kapp

    Harald Kapp Moderator Moderator

    11,997
    2,813
    Nov 17, 2011
    How about this:
    upload_2016-11-11_8-29-55.png
     
  9. mike wax

    mike wax

    34
    2
    Oct 10, 2016
    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?
     
  10. Harald Kapp

    Harald Kapp Moderator Moderator

    11,997
    2,813
    Nov 17, 2011
    Easy as pie:
    In your original post the integration is over 22µs. 1 kΩ*22 nF = 22 µs ;)
     
  11. mike wax

    mike wax

    34
    2
    Oct 10, 2016
    thanx Harald i gotta dust the cobwebs in my head :oops:
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-