Generate sawtooth with PIC?


Results 1 to 11 of 11

Threaded View

  1. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Sawtooth wave form

    One way to do it would be to use Darrel Taylor's instant interrupts and PWM with a lookup table.

    You could use this code on a PIC18, and just change the lookup values to a linear increase, dropping back to zero when it gets to 1.5v. http://www.picbasic.co.uk/forum/cont...-DT-interrupts . You would have to modify the speed of the interrupt. You could probably get by with a lot less steps.

    For instance, the sinewave generated by the above code, is kind of like the red sine wave in this picture. If you were to change all the values in the lookup, you could generate your sawtooth, like the one in blue.

    You can pretty much change the lookup table to create any wave form you like. Since your's is linear, you wouldn't really need a lookup table, you could just do some addition inside your interrupt handler, to increase the duty. And drop to zero after reaching X.



    Let us know how it goes, whichever way you choose to go.

    Walter
    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 2nd August 2010 at 18:48.
    http://www.scalerobotics.com

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts