Spwm signals


+ Reply to Thread
Results 1 to 4 of 4

Thread: Spwm signals

  1. #1
    Join Date
    Oct 2011
    Posts
    52

    Default Spwm signals

    hi to all I need help on how this portion of code work thanx
    sine:
    TMR1L = timerone.byte0
    TMR1H = timerone.byte1
    TeMP = sineval[STEPCOUNT]
    CCP1CON.4 = Temp.0 ' bit 0
    CCP1CON.5 = Temp.1 ' bit 1
    CCPR1L = Temp >>2 'Bit 2-7
    if stepcount = 0 then stepcount =36
    stepcount = stepcount -1

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,362

    Default Re: Spwm signals

    Hi,

    TMR1L = timerone.byte0
    TMR1H = timerone.byte1

    This loads the value stored in the variable timerone (which is a WORD) to the two individual 8-bit registers making up TMR1.

    TeMP = sineval[STEPCOUNT]
    This makes TeMP equal to the value at location STEPCOUNT in array sineval.

    CCP1CON.4 = Temp.0 ' bit 0
    CCP1CON.5 = Temp.1 ' bit 1
    CCPR1L = Temp >>2 'Bit 2-7

    This sets the duty cycles of the PWM signal generated by the CCP1 module by first taking the lower bits of Temp and copying those to CCP1CON.4 and CCP1CON.5. Then it takes the reminding 8 bits of the 10bit dutycycle value (stored in Temp) and copies those to CCPR1L.

    if stepcount = 0 then stepcount =36
    stepcount = stepcount -1

    This first checks if the index into the array is 0, if so it "resets" it to 36 in order to restart the cycle. Then it decrements it the same index by one.

    Stepcount counts from 35 to 0 and then starts over. It's used to retrieve values from the array sineval (which should contain 36 values). The retrieved value is desired dutycycle of the generated PWM.

  3. #3
    Join Date
    Oct 2011
    Posts
    52

    Default Re: Spwm signals

    thankx a lot for HenrikOlsson your help, my aim is to generate 3-phase SPWM using PIC16F877 but I started by I understanding single phase SPWM.
    I have read the Microchip appliction notes for sine wave with the 16F series chip..http://ww1.microchip.com/downloads/e...tes/00655a.pdf together with the examples given in http://www.picbasic.co.uk/forum/cont...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) which formular was used to generate a lookup table for the sine waveforms
    2)what is the purpose of this piece of code and how to get this values from example of http://www.picbasic.co.uk/forum/cont...-DT-interrupts
    TMR2 = 16
    PR2 = 129

    TMR1L = 255
    TMR1H = 254

  4. #4
    Join Date
    Oct 2011
    Posts
    52

    Default Re: Spwm signals

    thankx a lot HenrikOlsson for your help and to be honest, my aim is to generate 3-phase SPWM using PIC16F877 but I started by I understanding single phase SPWM.
    I have read the Microchip appliction notes for sine wave with the 16F series chip..http://ww1.microchip.com/downloads/e...tes/00655a.pdf together with the examples given in http://www.picbasic.co.uk/forum/cont...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)what is purpose/function of TMR1 in SPWM signals generation using PIC16f877
    2) which formular was used to generate a lookup table for the sine waveforms
    3)what is the purpose of this piece of code and how to get this values from example of http://www.picbasic.co.uk/forum/cont...-DT-interrupts
    TMR2 = 16
    PR2 = 129

    TMR1L = 255
    TMR1H = 254

Posting Permissions

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