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.

Sinusoidal pwm using Picolo F28069 control stick

Other Parts Discussed in Thread: CONTROLSUITE

Hello everyone,

I am a beginner in using microcontrollers, and I have been given a task to perform sinusoidal PWM using Picolo f28069.
Can anyone kindly give me directions, as to how i can do that.
it will be of great help

i have run few example programs on the stick and they are running just fine.

  • There are multiple ways of doing it. Without going into too much mathematics, Instantaneous Pulse Width is Proportional to Amplitude. So for Sinusoidal PWM, u can create a table in matlab, and then normalize it to min/max of the pulse widths that u want to create. U can also do it in xls. U will have to first decide the modulation frequency, that will determine the number of points in the table. E.g if u want to modulate 50 Hz and u choose a carrier of 1Khz, u will need 1000 points in the table.

    to convert the pulse width table into a pin that produces the pwm waveform there are multiple ways. The simplest yet but inaccurate way is that u run a timer and on every interrupt toggle a gpio pin, load pulse width value in that timer and return. Take care of mark and space. 

    Share your experience then I will be able to guide u further

  • Thank you very very much.

    I'll surely try it out and let you know.

  • only 20 points in the table with

    >50 Hz and u choose a carrier of 1Khz

    50Hz = 20ms, 1KHz period is 1ms, so 20 points

    More points (higher fs) give smoother waveform


  • Yes very right and much appreciated, there would be 20 points in given example

  • This application note may also be helpful:

    http://www.ti.com/lit/an/spraa88a/spraa88a.pdf

  • I have attached an example from my workshop - classes.  This F28069 - solution is based on the ROM IQ-Math lookup-Table for sin.

     

    28069_Lab2_2.pdf
  • Thank you everyone for your replies,
    but the problem is i need to compare a sine wave and a triangular wave to generate PWM using Piccolo control stick 28069. is it possible, and if yes then how.

    kindly help me out...

  • Yes its quite possible, there are multiple ways of doing it, as I wrote earlier, u can create a table of pulse widths and load that to a timer or use them with epwm registers to create pwm. The table can be created in Matlab. However u will have to select your preference first. Also see if u want to have a 2 level pwm or 3 level.

    Here is a quick link that I could find to help u, initially.

    http://www.wpi.edu/Pubs/E-project/Available/E-project-042711-190851/unrestricted/PWM_Techniques_final.pdf

  • Is it possible that i can sense a sine wave and a triangle wave from a function generator and then generate PWM, instead of making a look up table?

  • Yes u can do that. Remember to dc shift both the signals of signal generator. Normally the Signal Generator outputs are ac coupled and thus go positive and negative. U will have to dc shift both signals with a common dc value so that non of the signals go negative. The following application note helps u as how to use the c2000 comparator block to compare two signals.

    http://www.ti.com/lit/ug/spruge5f/spruge5f.pdf

  • Hi Bormann,

                 

    I have modified an tutorial program for developing Sinusoidal PWM with variable pulse width complementary signal at ePWM1B, here carrier wave is 10KHz and Sine wave of 50hz, the PWM pulse I have to apply as inverter gate pulses so that it should generate a 50hz sine and its magnitude will vary as I vary my dc voltage but, I am not getting sine wave with 50hz as output, please let me know the chages which has to be done, help in this regard, here I am providing program

    #include "F2806x_Device.h"
    #include "IQmathLib.h"

    extern void InitSysCtrl(void);
    extern void InitPieVectTable(void);
    extern void InitPieCtrl(void);
    interrupt void ePWM1_compare_isr(void);
    #pragma DATA_SECTION(sine_table,"IQmathTables");
    _iq30 sine_table[512];
    void main(void)
    {
    InitSysCtrl();
    InitPieCtrl(); // basic setup of PIE table
    InitPieVectTable(); // copy default ISR’s into PIE

    EALLOW;
    PieVectTable.EPWM1_INT = &ePWM1_compare_isr;
    SysCtrlRegs.WDCR = 0x00AF;

    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // ePWM1A
    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1;
    GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // enable pull-up
    GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0;
    EDIS;

    EPwm1Regs.TBCTL.all = 0; // default values
    EPwm1Regs.TBCTL.bit.CLKDIV = 0; // CLKDIV = 1;
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = 1; // HSPCLKDIV = 2
    EPwm1Regs.TBCTL.bit.CTRMODE = 2; // up-down mode

    EPwm1Regs.AQCTLA.all = 0x0006; // ZRO=set; PRD=clear
    EPwm1Regs.AQCTLB.all = 0x0090;

    EPwm1Regs.TBPRD = 2250; // 10 kHz PWM frequency

    EPwm1Regs.CMPA.half.CMPA = 1125; // initial duty 50 %
    EPwm1Regs.DBRED = 750; // 10 microseconds delay
    EPwm1Regs.DBFED = 750; // 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.AQCTLA.all = 0x0060;
    // CMPA up = set; CMPA down = clear
    EPwm1Regs.ETSEL.all = 0;
    EPwm1Regs.ETSEL.bit.INTEN = 1; // enable ePWM1 int
    EPwm1Regs.ETSEL.bit.INTSEL = 5; // CMPA down match
    EPwm1Regs.ETPS.bit.INTPRD = 1; // 1st event
    PieCtrlRegs.PIEIER3.bit.INTx1 = 1; // ePWM1
    IER |= 4; // enable INT3
    EINT; // global int enable
    while(1)
    {
    EALLOW;
    SysCtrlRegs.WDKEY = 0x55; // service key #1
    SysCtrlRegs.WDKEY = 0xAA; // service key #2
    EDIS;
    }
    }
    interrupt void ePWM1_compare_isr(void)
    {
    static unsigned int index = 1;

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

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

    if(index)
    {
    if(EPwm1Regs.CMPA.half.CMPA < EPwm1Regs.TBPRD) EPwm1Regs.CMPA.half.CMPA++;
    else index = 0;
    }
    else
    {
    if(EPwm1Regs.CMPA.half.CMPA > 0) EPwm1Regs.CMPA.half.CMPA--;
    else index = 1;
    }

    EPwm1Regs.ETCLR.bit.INT = 1; // clear ePWM1 interrupt flag
    PieCtrlRegs.PIEACK.all = 4; // ACK for PIE group 3 int
    }

    Thanks in advance

    Naveenkumar M

  • Sir NaveenKumar , can you please help me provide your program ccs or .c file for my project (sine wave pulse width modulation ). Based for c2000 j28027 piccollo. I would be very thankful to you.
  • You can refer SGEN library present here: C:\ti\controlSUITE\libs\dsp\SGEN\v101
  • Hello sir. Even i am a beginner and have the same task to perform on an F28035. Can you please post some tutorial links on how to complete the task, or the code if possible.

  • You can refer to any of the inverter examples (SolarExplorer etc.) in controlSuite development kits folder.

  • Hi,If anyone can provide a code for this to be done on the microcontroller, i'd be grateful. I'm not able to find anything relevant on the internet.