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.

CCS/TMS320F28027F: SINE WAVE look up table

Other Parts Discussed in Thread: TMS320F28335

Tool/software: Code Composer Studio

HELLO EVERYONE,

I WAS WORKING ON F28027 FOR THE GENERATION OF A SINE WAVE USING PWM ,I HAVE SUCCESSFULLY CONFIGURED THE PWM BUT NOW I WANT TO GENERATE A SINE WAVE OF 50 HZ ,SO CAN ANYONE PLEASE HELP TO DO SO AND LOOK CAN ANYBODY PLEASE TELL HOW TO INCULDE THE SINE TABLE IN THE CODE AS I DIDN'T FIND ANY DOCUMENTATION FOR THAT,THIS WILL BE REALLY REALLY A GREAT HELP .

THANKS 

RAHUL GOEL

  • Rahul,

    I can think of 3 steps to getting a Look Up Table (LUT) into memory.

    1. Define the LUT as an array using a Pragma
      1. You need to determine the number of elements in your LUT by taking your desired sine wave frequency and dividing that by your control loop frequency.
      2. #pragma DATA_SECTION(QuadratureTable,"QuadratureTableSection")
        
        // quadrature look-up table: contains 5 quadrants of sinusoid data points
        int QuadratureTable[QUAD_TABLE_LENGTH] = {
        		0x0000,			// [0]  0
        		0x18F8,	        // [1]  11.25
        		.
        		.
        		.
        		0x7D89 	        // [n] 78.75
        		};

    2. Place that Pragma into memory using your .cmd file
      1. SECTIONS            /* program sections allocation */
        {
                        QuadratureTableSection              : > DRAML1,                       PAGE = 1                              /* sine wave look-up table */
        ...
        

    3. Extern and use the array in your main.c
      1. extern int QuadratureTable[x]; 

    Finally use the array to adjust the CMPx values of the PWM.

    Please note that the above is only an approximation of the code you will need, I do not expect it to build. You should be able to look up the exact syntax.

    Regards,
    Cody

  • THANKS CODY, FOR THE REPLY,

    Can you please help to find the value in giving the formula to find the look up table values and also SHOULD WE ADD A FLOATING POINT NUMBER OR ANY OTHER CONVERTED FORM OF NUMBER IN LUT(LOOK UP TABLE).

    REGARDS 

    RAHUL GOEL

  • Rahul,

    You will have to work out the syntax to generate the sine table entries.  It is straightforward using Excel, for example, but there are no examples I can point you towards from TI so you will have to work through the details yourself.

    If I were doing it, I would use the decimal to hex conversion in Excel to generate entries between 0 and 0xFFFF.  That way you can scale each value according to the PWM period in your code and write it to the PWM compare register.  This device is fixed-point, so will not be efficient when handling floating point data - I recommend you only have fixed point values in the table.

    Regards,

    Richard

  • Hello Rahul,

    Hope you are doing well

    I have just started with TMS320F28335, so I have some basic questions if you can answer it will helpful for me.

    1) how to set up the system clock as I am using external clock)

    2)how to set up the system memory

    3)how to confirm the computation

    4)how to generate a simple PWM

    Looking forward to you

  • Muhammad,

    Your questions seem unrelated to those earlier in this thread so I'm going to close this one.

    You may find useful information in the hands-on workshop for the device you mention, here:

    https://training.ti.com/c2000-f2833x-microcontroller-workshop

    If you still need more support, please open a new question on the forum so the right experts can be assigned to it.  Thanks.

    Regards,

    Richard