sinusoidal PWM


Closed Thread
Results 1 to 40 of 84

Thread: sinusoidal PWM

Hybrid View

  1. #1
    Join Date
    Feb 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    thanx..m working on them

  2. #2
    Join Date
    Feb 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Hi,i've read the Microchip appliction notes for sine wave with the 16F series chip..http://ww1.microchip.com/downloads/en/AppNotes/00655a.pdf together with the examples given in http://www.picbasic.co.uk/forum/content.php?r=229-Sine-wave-using-DT- interrupts and http://www.picbasic.co.uk/forum/showthread.php?t=14359.

    there are number of things which i've not understand from these readings and i'm asking for help from anyone who can help me to understand.these things are:
    1)how to generate a lookup table for the sine waveforms
    2)how to include DT_INTS-18.bas file so that when i compile,the compiler will be able to open it
    3)what is the purpose of this piece of code from example of http://www.picbasic.co.uk/forum/cont...-DT-interrupts

    asm
    __CONFIG _CONFIG1H, _OSC_HSPLL_1H
    __CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WDPS_512_2H
    __CONFIG _CONFIG4L, _LVP_OFF_4L
    endasm

    thank you in advance.

  3. #3
    Join Date
    Oct 2005
    Location
    Loveland CO USA
    Posts
    83


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    1) You could use the 32 location array you pointed at in question 3. I used M.S. EXCEL.
    3) Get the data sheet for the PIC in PDF format and search for _OSC_HSPLL_1H or some piece of that. In the first of the 3 you can see these bits setup the oscillator and PLL. Most of the PICs have many modes for the oscillator. Internal/ external, divide by 32/ multiply by 4, etc.

    1)how to generate a lookup table for the sine waveforms
    2)how to include DT_INTS-18.bas file so that when i compile,the compiler will be able to open it
    3)what is the purpose of this piece of code from example of http://www.picbasic.co.uk/forum/cont...-DT-interrupts

    asm
    __CONFIG _CONFIG1H, _OSC_HSPLL_1H
    __CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WDPS_512_2H
    __CONFIG _CONFIG4L, _LVP_OFF_4L
    endasm

    thank you in advance.[/QUOTE]

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    to bwaxing:

    My advice : read this great post with exemples, the sine is stored in an array :
    http://www.picbasic.co.uk/forum/cont...-DT-interrupts
    Last edited by Ioannis; - 8th May 2011 at 15:32.

  5. #5
    Join Date
    Feb 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    thanks for the advice,i read examples from that post and I've not understand how to create the lookup table.From that post sine is stored in the array and i don't understand how the value for a particular step have been determined.for example i want to use 8-bit resolutions (256 steps),how will i determine the value of each step?is there a formula or something?
    thanks again.
    Last edited by Ioannis; - 8th May 2011 at 15:32.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    sine[1]=0
    .
    .
    .
    sine[128]=255

    Excel can do that. The first number is the angle (1->128, like 0-360°), the second is the result of the sine (0->255, like 0-1).

    For each interruption, the command duty=sine[counter] will read the sine value located in the array and the position of this value in the array is determined by the "counter" variable. The result of this command is stored in the "duty" variable.

    A little example:

    Code:
    counter=128
     
    loop:
     
    duty=sine[counter]
     
    PWM pin,duty,cycle
     
    counter=counter-1
    if counter=0 then counter=128
     
    goto loop
    In each loop the counter value is decremented by one, and when the step value equals 0, the counter is reinizialized to 128.

    So in this case, to make a complete sine, it will take 128 loops. If you want a 1Hz sine, you have to repeat this loop exactly 128 times per second.
    Last edited by Ioannis; - 8th May 2011 at 15:33.

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