This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F28069 sinusoidal PWM generation

Other Parts Discussed in Thread: CONTROLSUITE

Hi All

Does any body know how to create Sinusoidal PWM for with 50Hz referennce and 10khz carrier waveform, using F28069 experimental kit , please help in this regard

Thanks and regards

Naveenkumar

  • Hi Naveenkumar,

    Naveenkumar Marati said:
    Does any body know how to create Sinusoidal PWM for with 50Hz referennce and 10khz carrier waveform, using F28069 experimental kit , please help in this regard

    Have you already gone through the SGEN library?

    C:\ti\controlSUITE\libs\dsp\SGEN\v101

    You can read the doc present here: C:\ti\controlSUITE\libs\dsp\SGEN\v101\doc

    Regards,

    Gautam

  • Hi Gautam,

    I have read  but I have to generate a Sinusoidal PWM pulse with 50Hz ref and 10khz carrier signal.

  • Naveenkumar Marati said:

    I have read  but I have to generate a Sinusoidal PWM pulse with 50Hz ref and 10khz carrier signal.

    Ahhh... this link should be helpful then:

    http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/253748.aspx

    Regards,

    Gautam

  • Hi Naveen,

    Was the link useful? I was confused as you verified your query instead of an answer :)

    Regards,

    Gautam

  • Oh I confused Gautam,

    Actually I took some examples and I have modified for SPWM here I am providing the code 

    #include "F2806x_Device.h"
    #include "IQmathLib.h"
    #pragma DATA_SECTION(sine_table,"IQmathTables");
    _iq30 sine_table[512];

    // external function prototypes
    extern void InitSysCtrl(void);
    extern void InitPieVectTable(void);
    extern void InitPieCtrl(void);

    // Prototype statements for functions found within this file.
    void Gpio_Select(void);
    void Setup_ePWM1(void);
    interrupt void ePWM1_compare_isr(void);

    //###########################################################################
    // main code
    //###########################################################################
    void main(void)
    {
    InitSysCtrl(); // Basic Core Init from DSP2806x_SysCtrl.c


    EALLOW;
    SysCtrlRegs.WDCR= 0x00AF; // Re-enable the watchdog
    EDIS; // 0x00AF to NOT disable the Watchdog, Prescaler = 64

    DINT; // Disable all interrupts

    Gpio_Select(); // GPIO34 as output (LED) & EPWM1A

    Setup_ePWM1(); // init of ePWM1A

    InitPieCtrl(); // basic setup of PIE table; from DSP2833x_PieCtrl.c

    InitPieVectTable(); // default ISR's in PIE

    EALLOW;
    PieVectTable.EPWM1_INT = &ePWM1_compare_isr;
    EDIS;

    PieCtrlRegs.PIEIER3.bit.INTx1 = 1; // ePWM1 Interrupt

    IER |=1;

    EINT;
    ERTM;

    while(1)
    {
    EALLOW;
    SysCtrlRegs.WDKEY = 0x55; // service WD #1
    EDIS;
    }
    }

    void Gpio_Select(void)
    {
    EALLOW;
    GpioCtrlRegs.GPAMUX1.all = 0; // GPIO15 ... GPIO0 = General Puropse I/O
    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // ePWM1A active
    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // ePWM1B active
    GpioCtrlRegs.GPAMUX2.all = 0; // GPIO31 ... GPIO16 = General Purpose I/O
    GpioCtrlRegs.GPBMUX1.all = 0; // GPIO38 ... GPIO32 = General Purpose I/O
    GpioCtrlRegs.GPADIR.all = 0;
    GpioCtrlRegs.GPBDIR.all = 0; // GPIO38-32 as inputs
    GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // GPIO34 as output (LED LD2 at 28027stick)
    EDIS;
    }

    void Setup_ePWM1(void)
    {
    EPwm1Regs.TBCTL.all = 0; // default status
    EPwm1Regs.TBCTL.bit.CLKDIV = 0; // CLKDIV = 1
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0; // HSPCLKDIV = 1
    EPwm1Regs.TBCTL.bit.CTRMODE = 2; // up - down mode

    EPwm1Regs.AQCTLA.all = 0x0060; // set ePWM1A on CMPA up
    EPwm1Regs.AQCTLB.all = 0x0090; // clear ePWM1A on CMPA down

    EPwm1Regs.TBPRD = 90; // 500KHz - PWM signal
    // TBPRD = fcpu / (2*fPWM * CLKDIV * HSPCLKDIV)
    // TPPRD = 60 MHz / (2 * 1KHz * 1 * 1) = 60
    EPwm1Regs.CMPA.half.CMPA = EPwm1Regs.TBPRD / 2; // 50% duty cycle first
    EPwm1Regs.CMPB = EPwm1Regs.TBPRD / 2;

    EPwm1Regs.DBRED = 200; // 10 microseconds delay
    EPwm1Regs.DBFED = 200; // for rising and falling edge
    EPwm1Regs.DBCTL.bit.OUT_MODE = 3; // ePWM1A = RED
    EPwm1Regs.DBCTL.bit.POLSEL = 2; // S3=1 inverted signal at ePWM1B
    EPwm1Regs.DBCTL.bit.IN_MODE = 0; // ePWM1A = source for RED & FED

    EPwm1Regs.ETSEL.all = 0;
    EPwm1Regs.ETSEL.bit.INTEN = 1; // interrupt enable for ePWM1
    EPwm1Regs.ETSEL.bit.INTSEL = 5; // interrupt on CMPA down match
    EPwm1Regs.ETPS.bit.INTPRD = 1; // interrupt on first event
    }

    interrupt void ePWM1_compare_isr(void)
    // ISR runs every 2000 ns (PWM-frequency = 500 KHz)
    // and is triggered by ePWM1 compare event
    // run - time of ISR is 630 ns
    {
    static unsigned int up_down=1;
    // Service watchdog every interrupt
    EALLOW;
    SysCtrlRegs.WDKEY = 0xAA; // Service watchdog #2
    EDIS;
    if(up_down)
    {
    if(EPwm1Regs.CMPA.half.CMPA < EPwm1Regs.TBPRD)
    EPwm1Regs.CMPA.half.CMPA = EPwm1Regs.TBPRD - _IQsat(_IQ30mpy((sine_table[up_down]+_IQ30(0.9999))/2,EPwm1Regs.TBPRD),EPwm1Regs.TBPRD,0);
    up_down +=1; // use next element out of lookup table
    if(up_down >511) up_down = 0;

    }
    else
    {

    if(EPwm1Regs.CMPA.half.CMPA > 0)
    EPwm1Regs.CMPA.half.CMPA = EPwm1Regs.TBPRD - _IQsat(_IQ30mpy((sine_table[up_down]+_IQ30(0.9999))/2,EPwm1Regs.TBPRD),EPwm1Regs.TBPRD,180);

    up_down --; // use next element out of lookup table
    if (up_down >511) up_down = 1;
    }
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;


    EPwm1Regs.ETCLR.bit.INT = 1; // Clear ePWM1 Interrupt flag

    // Acknowledge this interrupt to receive more interrupts from group 3
    PieCtrlRegs.PIEACK.all = 1;
    }
    //===========================================================================
    // End of SourceCode.
    //===========================================================================

    But this for 500kHz and 976Hz whenI applied to Haif bridge inverter I am not getting proper output at LC filter please could you help me in this  

  • Naveenkumar Marati said:
    But this for 500kHz and 976Hz whenI applied to Haif bridge inverter I am not getting proper output at LC filter please could you help me in this  

    Do the calculations and edit the TBPRD value; as simple as that!

    Regards,

    Gautam

  • I have calculated the value and TBPRD is 2250 for 10khz but when I gate puelse to Inverter the output volatge has to vary with input but it is not varying accordingly.