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.

TMDSCNCD280039C: Example to generate 2 complimentary PWM output with dead time

Part Number: TMDSCNCD280039C
Other Parts Discussed in Thread: C2000WARE, TMDSHSECDOCK

I am looking for example to generate 2 PWM output using the 280039C device with a user defined dead time, switching frequency and dead time. I already tried the module 7 example "control peripherals lab", which lets me view the epwm one channel output of a specified frequency and duty cycle using the Graph tool in CCS, and also check output on scope. Now I want to enhance that to 2 channel complementary PWM output and with a dead time. 

  • Hi Shashank,

    You can checkout the epwm_ex8_deadband example available in C2000Ware driverlib section located at C2000Ware_XX/driverlib/f28003x/examples/c28x/epwm folder.

    Hope this helps.

    Thanks,

    Aditya

  • Hi Aditya,

    In the example when I check the GPIO10 and GPIO11 on a scope,

    Issue#1:
    I am not getting a complimentary output with dead time. Below is the waveforms captured on scope. Pins on daughter card TMDSHSECDOCK  connected to scope are pin 61 and pin 63. 

    Btw, I changed the EPWM_TIMER_TBPRD  from 2000UL to  2250UL (seems like 600us time period). As GPIO11 pin on daughter card is different than other GPIO pins used, is that a problem? 

    Ques 1: Also, I believe with 3000UL, time period was 800us. What is the exact relation of EPWM_TIMER_TBPRD with time period? 

    Ques2: In order to change the dead time, what parameters should I vary? What does 200 and 400 in below code translate to in usec? Is there an easier way to set the dead time as a variable input? 
    // Set the RED and FED values
    //
    EPWM_setFallingEdgeDelayCount(base, 200);
    EPWM_setRisingEdgeDelayCount(base, 400);
    //

    Ques3: Is my understanding correct that to change the duty cycle, I need to modify the below two lines of code? (currently set at 25%). Is there an easier way to give duty cycle input as a variable input in the code?
    EPWM_setCounterCompareValue(base, EPWM_COUNTER_COMPARE_A, EPWM_TIMER_TBPRD/4);
    EPWM_setCounterCompareValue(base, EPWM_COUNTER_COMPARE_B, 3*EPWM_TIMER_TBPRD/4); 

  • Shashank,

    In the example when I check the GPIO10 and GPIO11 on a scope,

    The GPIO10, 11 correspond to EPWM6 for which the deadband is disabled, please refer to example description for the details about the different features showcased using different EPWM modules.

    In your case, you can check the output for EPWM4 which demonstrates Active High Complimentary mode of operation.

    Ques 1: Also, I believe with 3000UL, time period was 800us. What is the exact relation of EPWM_TIMER_TBPRD with time period? 

    TBPRD is a period register which is used as a divider to generate desired PWM frequency. There is a detailed explanation on how to calculate the PWM frequency and period in the reference manual of the device.

    What does 200 and 400 in below code translate to in usec?

    200, 400 will be in accordance with the PWM clocking frequency. For eg. The clocking frequency is 10kHz, then 200 will translate to 20usec.

    You can directly relate it with the TBPRD register as well to know what 200 and 400 will translate to in your case.

    Is my understanding correct that to change the duty cycle, I need to modify the below two lines of code?

    That's correct. The counter compare registers are used to calculate the duty cycle. You can either define a variable here in place of the duty defined and play with the variable in other part of the code as desired.

    One similar example of variable duty is showcased in the updown_aq example available in the same folder which I mentioned in my earlier reply.


    Thanks,

    Aditya

  • Aditya,

    Thanks for your response. However, I am bit confused here. 

    The GPIO10, 11 correspond to EPWM6 for which the deadband is disabled, please refer to example description for the details about the different features showcased using different EPWM modules.

    In your case, you can check the output for EPWM4 which demonstrates Active High Complimentary mode of operation.

    I found the below description which says EPWM6 is for switch A and B output: EPWM1 is with deadband disabled. Please clarify which is correct. I thought from the description below, I need to use GPIO10 EPWM6A and GPIO11 EPWM6B. 
    Example location is:"epwm_ex8_deadband.c" under location C:\ti\c2000\C2000Ware_4_00_00_00\driverlib\f28003x\examples\epwm

    //! This example configures ePWM1 through ePWM6 as follows
    //! - ePWM1 with Deadband disabled (Reference)
    //! - ePWM2 with Deadband Active High
    //! - ePWM3 with Deadband Active Low
    //! - ePWM4 with Deadband Active High Complimentary
    //! - ePWM5 with Deadband Active Low Complimentary
    //! - ePWM6 with Deadband Output Swap (switch A and B outputs)
    //!
    //!
    //! \b External \b Connections \n
    //! - GPIO0 EPWM1A
    //! - GPIO1 EPWM1B
    //! - GPIO2 EPWM2A
    //! - GPIO3 EPWM2B
    //! - GPIO4 EPWM3A
    //! - GPIO5 EPWM3B
    //! - GPIO6 EPWM4A
    //! - GPIO7 EPWM4B
    //! - GPIO8 EPWM5A
    //! - GPIO9 EPWM5B
    //! - GPIO10 EPWM6A
    //! - GPIO11 EPWM6B

    reference manual of the device

    Can you point me reference manual where I can read calculation of PWM frrequency? 

    For eg. The clocking frequency is 10kHz, then 200 will translate to 20usec.

    does it mean that dead time is 20usec and 40usec? Can you explain the below lines in bit more detail 

    EPWM_setFallingEdgeDelayCount(base, 200);
    EPWM_setRisingEdgeDelayCount(base, 400);

    If I have say 20kHz PWM frequency, and want a dead time of 200ns, what value shall I use?

  • Shashank,

    I found the below description which says EPWM6 is for switch A and B output: EPWM1 is with deadband disabled. Please clarify which is correct. I thought from the description below, I need to use GPIO10 EPWM6A and GPIO11 EPWM6B. 

    EPWM6 demonstrates the capability to swap the outputs of A and B. It is possible to insert the dead time even while swapping outputs but in this case, the deadband is not enabled in the example. You can check in the part of code listed below where the rising edge and falling edge delay is disabled.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    void setupEPWMOutputSwap(uint32_t base)
    {
    //
    // Disable RED
    //
    EPWM_setDeadBandDelayMode(base, EPWM_DB_RED, false);
    //
    // Disable FED
    //
    EPWM_setDeadBandDelayMode(base, EPWM_DB_FED, false);
    //
    // Switch Output A with Output B
    //
    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_A, true);
    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_B, true);
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    For EPWM frequency calculations, you can refer to "20.4.3 Calculating PWM Period and Frequency" in the reference manual.

    Deadband calculations are also discussed in the deadband module of the EPWM chapter in the reference manual.

    Thanks,

    Aditya