3 Phase Pwm Inverter

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

3 Phase Pwm Inverter

2,864 次查看
ruimausinho
Contributor II

Hello,

As the title indicates i'm trying to implement a program to control a gate driver using PWM signals. This ones should have follow characteristics for work correctly:   180 degrees shifted, sine wave working specific at 50HZ , and PWM frequency upper than 12kHZ.

 

All of the tasks i already fixed, except the problem that i can't guarantee the sine wave with 50HZ, and i don´t have any idea how to do, after trying a lot of manipulations with the pwm registers.

 

There is any way to do with controlling the timers, like respecting the time for "load" the 256 values to a pwm register? Following the thinking of F=50HZ, so T= 20 ms ? But in this case, the timer that i'm using (and the only one that i'm allowed in PWM MOTOR CONTROL BEAN) it´s PWM_TIMER , and that one i can´t choice the pulse width neither know how that is preset.

 

Anyone can help me or give me some suggest in this problem?

I'm getting really unmotivated at this moment, too much time stranded in this point. Any help or suggest is welcome.

 

Part of the code:

 

const unsigned short int PHASE[256] = {

128,131,134,137,140,143,146,149,

152,155,158,162,165,167,170,173,

176,179,182,185,188,190,193,196,

198,201,203,206,208,211,213,215,

218,220,222,224,226,228,230,232,

234,235,237,238,240,241,243,244,

245,246,248,249,250,250,251,252,

253,253,254,254,254,255,255,255,

255,255,255,255,254,254,254,253,

253,252,251,250,250,249,248,246,

245,244,243,241,240,238,237,235,

234,232,230,228,226,224,222,220,

218,215,213,211,208,206,203,201,

198,196,193,190,188,185,182,179,

176,173,170,167,165,162,158,155,

152,149,146,143,140,137,134,131,

128,124,121,118,115,112,109,106,

103,100,97,93,90,88,85,82,

79,76,73,70,67,65,62,59,

57,54,52,49,47,44,42,40,

37,35,33,31,29,27,25,23,

21,20,18,17,15,14,12,11,

10,9,7,6,5,5,4,3,

2,2,1,1,1,0,0,0,

0,0,0,0,1,1,1,2,

2,3,4,5,5,6,7,9,

10,11,12,14,15,17,18,20,

21,23,25,27,29,31,33,35,

37,40,42,44,47,49,52,54,

57,59,62,65,67,70,73,76,

79,82,85,88,90,93,97,100,

103,106,109,112,115,118,121,124

};

 

                       /*  hardware topology */

    PWM_VAL0 = 0x0000; /* Minimum duty cycle for pair PWM1:2 */

    PWM_VAL2 = 0x0000; /* Minimum duty cycle for pair PWM3:4 */

    PWM_VAL4 = 0x0000; /* Minimum duty cycle for pair PWM5:6 */

 

PWMC1_Load();    /* Load new PWM values */
PWMC1_EnableEvent();      // enable eventsPWMC1_Enable();           // enable PWMMC

 

 

 

 

//PWMC1_OutputPadEnable();

 

// Set modulus (PWM period)

    PWM_CMOD = PWM_MODULO;

   

    // Set counter values (PWM duty cycle)

//pwm_change_duty(v0,v1,v2);
PWM_VAL0 = PHASE[TableIndex];

    //PWM_VAL1 = PHASE_A[TableIndex];

    PWM_VAL2 = PHASE[(TableIndex+85)];

    //PWM_VAL3 = PHASE_B[TableIndex];

    PWM_VAL4 = PHASE[(TableIndex+170)];

    //PWM_VAL5 = PHASE_C[TableIndex];

    PWM_CTRL |= PWM_CTRL_LDOK;

PWMC1_Load();    /* Load new PWM values */

    TableIndex++;           /* Update Table Index*/

   

    if (TableIndex == 256)

    {

        TableIndex = 0;     /* Reset Table Index */

    }

       

   PWMC1_EnableEvent();      // enable eventsPWMC1_Enable();           // enable PWMMC

 

PWMC1_OutputPadEnable();
标签 (1)
5 回复数

2,568 次查看
ankur_kala
NXP Employee
NXP Employee

Hi Rui,

A better approach would be to fix the PWM frequency and then calculate the step values of the array. For example for a 50Hz sine wave with a 20KHz PWM, we would need 400 step array. or If you want to keep the PWM frequency at 12KHz, the number of steps should be 240. Do keep some margin for dead time insertion also.

In your code I also see that you have taken care for situation when TableIndex == 256, but there can be other cases, for example a value of 100 for TableIndex would mean that PWM_VAL4 would be taking data from memory location which goes outside the boundaries of the array defined. So the saturation needs to be checked for TableIndex+85 and also TableIndex+170.

Hope this helps.

Regards,

Ankur

0 项奖励
回复

2,568 次查看
RadekS
NXP Employee
NXP Employee

Hi Rui,

Could you please specify your MCU family?

Unfortunately some of register names are not familiar for me.

Yes, you will probably need additionally any timer for update PWM duty cycle.

I suppose that you have some RC filer connected at output PWM pin and result capacitor is charged/discharged by PWM signal.

Yes, 50Hz present 20ms period. According your table, I suppose that you have to update duty cycle 256 times during this 20ms period. So, duty cycle has to be updated every 78.125us (12800Hz). Of course, PWM frequency has to be respectively higher than this update rate.

As timer you could use for example PIT timer. For example: If Bus clock is 40MHz, time-out period has to be 3125 = (40MHz/12800Hz).

Additionally I am not sure with your TableIndex code.

For example line “PWM_VAL4 = PHASE[(TableIndex+170)];” suppose adding 170 to the table index and line “if (TableIndex == 256)  {TableIndex = 0;    /* Reset Table Index */}” resets table index back to 0.

However your PHASE table has just 256 values. So, it depends how you defined TableIndex variable.

If TableIndex is 8bit number (unsigned char), set TableIndex to 0 is useless. If size of TableIndex is higher than 8 bit, you read values out of table (255+170=425)…

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,568 次查看
ruimausinho
Contributor II

Hello,

First of all thank you RadekS for your interest in my topic (and also the problem that not allow me to sleep :smileygrin:) . I'm using the MC56F8006 , and i'm having a bit of difficult in using some of registers too, it's the first experience that i have with this kind of MCU.

Yes, i set up a Chebyshev Low-Pass filter, i saw in some tutorials, but at this moment i'm not sure if it's the most indicate one. And i'm using that between the PWM output signals and the gate driver.

Okay, following that logic, i'm making a new version of code, with 3 separated LOOK-UP tables, each one with 64  numbers, and i could find a combination that make a good shifting of 120 degrees.  So in this case i need to update the duty cycle 64 times during 20 ms (64/0.02 = 3200 HZ) ? And how i can have 2 different frequencies, when i just can choose the frequency of PWM? (i'm having a lot of doubts here).

Abou Timer's, the PWM Motor Control define a proper timer, PWM_Timer, and this one i can´t making any modifications, neither how long time turns off, or reload.

If you can help me in this questions, i really appreciate that.

Mt best regards,

Rui

0 项奖励
回复

2,568 次查看
RadekS
NXP Employee
NXP Employee

Hi Rui,

thank you for more details.

Now is clear why some of registers names were not familiar for me.

Your question is related to different product group – DPS microcontrollers.

My answer was based rather on knowledge of PWM modules at S12(X) devices. There is high probability that PWM module at your MCU provide higher flexibility than simple PWM module at S12 devices.

I am moving your question to responsible Community space.

Best Regards

RadekS

2,568 次查看
johnlwinters
NXP Employee
NXP Employee

This group is for DSC.

The MC56F8006 device is a DSC.

So, this is the correct group.