This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Converting 10kHz PWM into 2kHz PWM codes

Hi

Here is my pseduo-code:

// In my CAPCOM1 initalisation

CC1_T0REL=0xF830; // Generate 10kHz PWM

// Produce 50% duty cycle
Offset=(0xFFFF-CC1_T0REL)>>1;

// This will produce 50% duty cycle of 10kHz  PWM

CC1_CC2=CC1_T0REL+Offset;


Note: I use 100uS for Timer 0 Interrupt

Now I need to convert 10kHz PWM into 2kHz PWM but I am totally lost at the moment. However I tried to divide it by 5 but it doesn't work at all. I would be very very grateful to hear your suggestion or tip.

Kind regards

AJ

Parents
  • Can I ask what are controlling? You said you need to create 12 channels so are you controlling 4 motors? Or 2 and you need complementary channels (6 channels per motor)? Are you using an external three phase driver that also generates the dead-time? Can you use edge aligned PWM's or do they need to be center aligned?

    Did you say you are using an XC167? You know this has 2 CAPCOM timer units and 1 CAPCOM6 timer unit. The CAPCOM6 was specifically designed for three phase motor control.

    Ok, I see a couple of issues with the code. First you have are exceeding your SineWave array (128 entries) by NUMBER_POINT (213). You need TABLE_SIZE to be equal or less than the TABLE_SIZE. When creating the sine table you need to add an offset so the sine wave is all positive values (in your example 2500).

    Since you want to vary the duty cycle and given your other criteria then I would recommend to switch to compare mode three. Compare Mode 3 will only have one event per timer period and the when you have a compare event the signal is set and on the timer event the signal is reset. When writing a new compare value after the event it will only be valid after the next timer period. Note the PWM's would be edge aligned, is this ok?

    In the timer interrupt service routine you need to manage three different indexes (or three sine tables which represent 120 degree phase shifts).

    Are you familiar application note Ap0802211_3-Phase-Currents.pdf on the Infineon website?

Reply
  • Can I ask what are controlling? You said you need to create 12 channels so are you controlling 4 motors? Or 2 and you need complementary channels (6 channels per motor)? Are you using an external three phase driver that also generates the dead-time? Can you use edge aligned PWM's or do they need to be center aligned?

    Did you say you are using an XC167? You know this has 2 CAPCOM timer units and 1 CAPCOM6 timer unit. The CAPCOM6 was specifically designed for three phase motor control.

    Ok, I see a couple of issues with the code. First you have are exceeding your SineWave array (128 entries) by NUMBER_POINT (213). You need TABLE_SIZE to be equal or less than the TABLE_SIZE. When creating the sine table you need to add an offset so the sine wave is all positive values (in your example 2500).

    Since you want to vary the duty cycle and given your other criteria then I would recommend to switch to compare mode three. Compare Mode 3 will only have one event per timer period and the when you have a compare event the signal is set and on the timer event the signal is reset. When writing a new compare value after the event it will only be valid after the next timer period. Note the PWM's would be edge aligned, is this ok?

    In the timer interrupt service routine you need to manage three different indexes (or three sine tables which represent 120 degree phase shifts).

    Are you familiar application note Ap0802211_3-Phase-Currents.pdf on the Infineon website?

Children
No data