sinusoidal PWM


Closed Thread
Results 1 to 40 of 84

Thread: sinusoidal PWM

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Quote Originally Posted by bwaxing View Post
    hi everybody,

    i'm here again with the sinusoidal PWM, please bear with me,

    It seems there were some problems with my compiler but after re-installing it,things work pretty well,i've included the file DT_INTS-14.bas in the folder containing the source code and although there some errors,its a good start to me.
    there are few things which are not clear to me from the example ofhttp://www.picbasic.co.uk/forum/cont...-DT-interrupts
    How to obtain the correspond value for each step is not clear to me,i want to learn how to create a lookup table the way it is done in the example as i dont know how to create it using excel.what formula was used to get these values from that example?
    ; Set sine "table" in an array
    sineval var byte[32]
    sineval[1] = 128
    sineval[2] = 148
    sineval[3] = 167
    sineval[4] = 185
    sineval[5] = 200 etc.
    To be quite honest, I copied them from the application note I reference in the example I gave. It shows you a little more about it in the notes in the assembly code. If you wanted to make your own, you just need to figure out how many steps you are going to make. If you were doing 36 steps, each step would be 10 degrees. Sin(10 degrees) * 102 + 128 = number. In the Microchip example, they had the max = 90 percent. So 90 percent * 255 = 230. 230 - 128 (the midpoint) = 102. So it will swing + or - 102 from the midpoint (128).

    Then we can make a spreadsheet for our steps. I put the Microchip steps in on the left, then degrees for each step, then the formulated value on the right. As you can see, these pretty much match the Microchip values. You would have to do something similar for your 72 steps.

    Name:  steps.PNG
Views: 31244
Size:  22.2 KB
    Also for 50Hz,PR2 will be loaded with 78 for 20MHz oscillator frequency of 16f877,but i dont how to arrive in determination of the value loaded for variable'' timerone''.
    You will have to experiment with a scope to see what it comes out at. At least, that is how I did it. There are a lot of coming in and out of interrupts and such.
    Should i include DT_INTS-18.bas file or DT_INTS-14.bas file?it seems to me they perform different functions!which link will i get DT_INTS-18.bas file?
    Read my previous reply, I think I answered this already.
    Finally,is there any other modification i should do in that program that it could work better in pic16f877?
    Only change what won't work on a PIC16877 to what will work on a Pic16f877

    I have not checked to see all that is incompatible. You will have to do a little homework, checking the data sheets, and seeing if you get errors for registers that are incompatible. Seeing if the PWM is compatible, or if the way you address it needs to be changed. It's definately doable, as you can see from the Microchip application note which was written for a 16F device.
    Last edited by ScaleRobotics; - 4th March 2011 at 01:41. Reason: 109?? changed to 102 + 128

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