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.

PWM - two pulses in one period

Other Parts Discussed in Thread: EK-TM4C1294XL, CONTROLSUITE

Hello, I need to generate two different pulses in one period on one PWM channel, code is:

PWM_setPeriod(myPwm1, 600);
PWM_setCmpA(myPwm1, 300);
PWM_setCmpB(myPwm1, 580);
PWM_setActionQual_Zero_PwmA(myPwm1, PWM_ActionQual_Set);
PWM_setActionQual_CntUp_CmpA_PwmA(myPwm1,PWM_ActionQual_Clear);
PWM_setActionQual_Period_PwmA(myPwm1, PWM_ActionQual_Set);
PWM_setActionQual_CntDown_CmpA_PwmA(myPwm1, PWM_ActionQual_Clear);

 

this is what it should display, but if I use for PWMB the CmpB:

PWM_setActionQual_Period_PwmB(myPwm1, PWM_ActionQual_Set);
PWM_setActionQual_CntDown_CmpB_PwmB(myPwm1, PWM_ActionQual_Clear);

This is what i get, the PWMB (channel 1) is 0 and 1 at the same time ?! And it is in two quarters of period and it should be only in one.

Can someone tell me, whats wrong? Or Is the microcontroller even capable of switching on-off two times in one period?

  • Hi Petr,

    Petr Spanel said:
    Can someone tell me, whats wrong? Or Is the microcontroller even capable of switching on-off two times in one period?

    First of all which controller are you using? Also, try using the trigger function of the oscilloscope to eliminate 1&0 together at the same instant.

    Regards,

    Gautam

  • Hello, thanks for reply,

    I have C2000 F28027 launchpad.

    now I think, I am the dumbest human in the world :). I didn't notice, that trigger is on second channel, now it works fine.

    So my second question is, can the launchpad use more than two comparators for one PWM channel?

    Or can I set different comparators for PWMA and PWMB? How?

    I need to generate complicated signal for driving full bridge converter. Every transistor needs to be driven by four signals in one period. It means 16 signals. Is the F28027 capable of that? Or I should buy something with more PWM channels (like TMDSDOCK28346-168) or can you recomend me something cheaper? I was looking for EK-TM4C1294XL, but it has the same number of PWM channels like F28027.

    Thank you, Petr

  • Petr Spanel said:
    now I think, I am the dumbest human in the world :).

    Nah nah... that happens :)

    Petr Spanel said:

    So my second question is, can the launchpad use more than two comparators for one PWM channel?

    Or can I set different comparators for PWMA and PWMB? How?

    What do you mean by 2 comparators for one pwm channel? Can you be more specific?

    Petr Spanel said:
    Every transistor needs to be driven by four signals in one period. It means 16 signals.

    So you need 16 pwm channels simultaneously, right?

    Regards,

    Gautam

  • Gautam Iyer said:
    What do you mean by 2 comparators for one pwm channel? Can you be more specific?

    I mean for example something like this:

    PWM_setCmpA(myPwm1A, 300);
    PWM_setCmpB(myPwm1A, 580);
    PWM_setCmpA(myPwm1B, 280);
    PWM_setCmpB(myPwm1B, 20);

    or

    PWM_setCmpA(myPwm1, 300);
    PWM_setCmpB(myPwm1, 580);
    PWM_setCmpC(myPwm1, 280);
    PWM_setCmpD(myPwm1, 20);

    
    

    Gautam Iyer said:
    So you need 16 pwm channels simultaneously, right?

    Yes, thats rigth, but if I will be able to generate two pulses in PWM1A channel, so 8 channels would be enough, but for this, I need more comparators.

    I found this stick TMDX28069USB, it should work, but PWM5-8 are not connected so I will need to solder wires directly to MCU.

  • Petr Spanel said:
    PWM_setCmpA(myPwm1A, 300);
    PWM_setCmpB(myPwm1A, 580);
    PWM_setCmpA(myPwm1B, 280);
    PWM_setCmpB(myPwm1B, 20);

    or

    PWM_setCmpA(myPwm1, 300);
    PWM_setCmpB(myPwm1, 580);
    PWM_setCmpC(myPwm1, 280);
    PWM_setCmpD(myPwm1, 20);

    Ok, first of all CMPA is linked with PWMxA & CMPB with PWMxB. These values are specifically for altering the duty.

    Petr Spanel said:
    Yes, thats rigth, but if I will be able to generate two pulses in PWM1A channel, so 8 channels would be enough, but for this, I need more comparators.

    Sorry, you'll be able to generate only one pulse (with specified frequency & alterable duty) with one channel say ePWM1A.

    So in this case you need 16-different channels.

    Regards,

    Gautam

  • Gautam lyer said:
    Ok, first of all CMPA is linked with PWMxA & CMPB with PWMxB. These values are specifically for altering the duty.

    I think thats not all true, for example:

    PWM_setActionQual_CntUp_CmpA_PwmA(myPwm1, PWM_ActionQual_Set);
    PWM_setActionQual_CntDown_CmpB_PwmA(myPwm1, PWM_ActionQual_Clear);

    This code sets 1 when going above CmpA and sets 0 going under CmpB on PWM1A.

    And

    Gautam lyer said:
    Sorry, you'll be able to generate only one pulse (with specified frequency & alterable duty) with one channel say ePWM1A.

    thats also not true, the code, I wrote above:

    PWM_setActionQual_Zero_PwmA(myPwm1, PWM_ActionQual_Set);
    PWM_setActionQual_CntUp_CmpA_PwmA(myPwm1, PWM_ActionQual_Clear);
    PWM_setActionQual_Period_PwmA(myPwm1, PWM_ActionQual_Set);
    PWM_setActionQual_CntDown_CmpB_PwmA(myPwm1, PWM_ActionQual_Clear);

    sets 1 and 0 (generates two pulses) two times in one period, but I need other comparator values to set PWMB differently. That was my question, if I can set different comparator values for A and B channel.

  • Petr, sorry if I'm not able to understand/follow what you're trying to convey. Also, I'm not familiar with the above coding structure. I personally prefer the traditional coding structure as in:

    C:\ti\controlSUITE\device_support\f2802x\v129\DSP2802x_examples_ccsv4\epwm_up_aq

    Petr Spanel said:

    Ok, first of all CMPA is linked with PWMxA & CMPB with PWMxB. These values are specifically for altering the duty.

    I think thats not all true, for example:

    PWM_setActionQual_CntUp_CmpA_PwmA(myPwm1, PWM_ActionQual_Set);
    PWM_setActionQual_CntDown_CmpB_PwmA(myPwm1, PWM_ActionQual_Clear);

    [/quote]

    You're right. That's how I characterize them and am sorry that I generalized them.

    Petr Spanel said:

    Sorry, you'll be able to generate only one pulse (with specified frequency & alterable duty) with one channel say ePWM1A.

    thats also not true, the code, I wrote above:

    PWM_setActionQual_Zero_PwmA(myPwm1, PWM_ActionQual_Set);
    PWM_setActionQual_CntUp_CmpA_PwmA(myPwm1, PWM_ActionQual_Clear);
    PWM_setActionQual_Period_PwmA(myPwm1, PWM_ActionQual_Set);
    PWM_setActionQual_CntDown_CmpB_PwmA(myPwm1, PWM_ActionQual_Clear);

    [/quote]

    Here I didn't understand what you mean by 2 pulses in one period but would like to check this out once I'm at work tomorrow.

    Petr Spanel said:
    That was my question, if I can set different comparator values for A and B channel.

    As I use CMPA & CMPB individually for respective channels, I was able to. But in your case I'm not at all sure of :)

    I'll loop in a TI expert here to shed some light.

    Goodluck & Regards,

    Gautam