sinusoidal PWM


Closed Thread
Results 1 to 40 of 84

Thread: sinusoidal PWM

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Ahh, OK, should've thought about that.
    So, here it is - remove the .txt extenstion and open with Excel or compatible.

    /Henrik.
    Attached Files Attached Files

  2. #2
    Join Date
    Oct 2011
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Quote Originally Posted by HenrikOlsson View Post
    Ahh, OK, should've thought about that.
    So, here it is - remove the .txt extenstion and open with Excel or compatible.

    /Henrik.
    thankx HenrikOlsson when I download your Excel fileI didn't able to open it please can you help me how to take it so I can open it. thankx

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Hello sangaboy,
    1) Download the file then rename it SIN-table.xls (or whatever ending with .xls) then open it with EXCEL 2003 - or compatible software. I just tried that here and it works fine. If you don't have Excel 2003 perhaps you can find a free viewer or converter online.

    2) The first code snippet you posted is a setup section of DT-Ints which are a set of files making interrupts with PBP a whole lot easier. The second code snippet sets up TMR1 to operate in a specific way and then preloads it with 65534 (which seems a bit strange) but that's what you get when you just copy code. You really need to start a bit further back here. Before taking on a project a like a 3-phase inverter you need to understand the basics of PIC and PBP - at least. How the timers work, how interrupts work and so on.


    Read up on the DT-Ints routines, there are several threads on this forum. Read up on how TMR1 operates, there's a lot of info in the datasheet and a bit of searching here will give a lot, I mean a LOT, of usefull information and examples. Start small otherwise you'll never learn how it works.

    If you get stuck ask specific questions regarding the particular task at hand and tell us what the actual problem is and what you've tried, post the code and so on.

    I really don't want to sound like a smart-ass but if you can't figure out the formula to create a SIN-lookup table then designing and programming a 3-phase inverter drive is going to quite a challange.

  4. #4
    Join Date
    Oct 2011
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Hii! to all
    I read DT-Ints routines from ttp://darreltaylor.com/DT_INTS-14/order.html here are some problems I faced any one can help me.
    (1)the difference between PBP AND ASM interrupt handler is not clear to me.
    (2) what the effects of ResetFlag on this code definition.

    INT_LIST macro ; IntSource, Label, Type, ResetFlag?

    Thankx

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Hi,

    1) Internally PBP works with a bunch of system variables in RAM. These are used to store intermediate results when doinf calculations and comparisons, loop counters etc etc. When you define the type of handler as PBP in the interrupt declaration DT-Ints saves all the PBP system variables on entry of the interrupt service routine and restores them on exit. This allows the code the in interrupt handler to be written in PBP just like any normal PBP program and execute without destroying the content of the system variables for the code that was executing when the intterupt occurs. When the execution returns from the interrupt handler the system variables looks exactly as they did when the interrupt occured and the "normal" program can continue to execute.

    If you define the type of handler as ASM DT-Ints does not save and restore the PBP system variables. This means that if you have code in the interrupt handler which happens to use any system variables it's very likely that you'll run into trouble. So, type PBP write the handler in PBP. Type ASM, write the handler in ASM.

    The difference is that it takes time for the system to save and restor all the PBP system variables (and the take up space i RAM). No you should not declare the type as ASM and still write the handler in PBP if you don't konw and understand exactly what's happening and what system variables your code uses.


    2) When an interrupt occurs the hardware in the PIC sets the interrupt flag for the particular interrupt. The ResetFlag option tells the interrupt system if IT should reset the flag after it's handled the interrupt or if it should leave it alone. Generally you set this to YES but for USART interrupt, for example, the flag is automatically cleared by the hardware when the RCReg is read so there's no need for the code to clear it as well.

  6. #6
    Join Date
    Oct 2011
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Thankx HenrikOlsson
    for your help .

  7. #7
    Join Date
    Oct 2011
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Hi HenrikOlsson
    I now I understand to gerate sine lookup table using excel sheet , thi is after working on the sheet you upload to me, The sheet contain the formular
    (SIN(Ai*PI()/180)+1)/2 from what I know the portion (Ai*PI())/180)change degrees into radians. but there to thing I need to understand so that I can generate my 32 steps sine look up table for 3 SPWM.
    (1) why (sine results+1)
    (2) why (sine results+1) is diveded by the factor of 2
    (3) why the (sine results+1)/2 are multiplied by 255 to get the scale value.

    THANKX

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: sinusoidal PWM

    Hi,
    Yes, convert from degrees which is the number in column A to radians which is what Excel wants.

    1) The SIN of an angle of 0-360° varies from -1 to +1 since we're going to use the values to set a PWM dutycycle we can't have negative numbers, we can't have a dutycycle of LESS than 0. So we add 1 to get a value ranging from 0 to 2 instead of +/-1.

    2) Then we divide that by 2 to get the value ranging from 0 to 1 to make the next step more logical...

    3) Again, since we're going to use the final value to set the dutycycle produced by the PWM generator we can't have the value ranging from 0 to 1, we need to scale the value up to match the number of bits of resolution we have in the PWM generator. If it's 8 bits multiply by 255 to get a value ranging from 0 to 255 (0 is 0% dutycycle, 255 is 100% dutycycle). If you have 9 bits resolution multiply by 512 and so on.

    /Henrik.

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