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.

Stopping PWM outputs, using deadband and complementary function but PWM-outputs should be forced low

Hi there,

I have a question concerning the epwm:

Have configured an epwm block with deadband, active high and complementary mode as well as output mode of deadband for both, input from pwma for both the behauviour is absolutely what I expect it to be. As soon as I want to stop the outputs of the PWM block driving the pins, something like a disable pwm-outputs, I change the ActionQualifier to Force-Low for the next event. That makes my PWM-A output going low but as I choose the complementary mode the PWM-B outptu will go high immediately.

Anyone any idea how to solve this situation best way? I want both PWM-outptus to go low with the next event. I don't want to use the trip-zone modules here as they do force the outputs low immediately and not at the next counter-zero event.

  • The deadband module generates your complementary outputs based only on the PWMA events, so you can't just work with the AQ module (which comes before deadband) to do the job.

    I usually set a software trip zone to disable my PWMs quickly. You may also reconfigure the pins as GPIOs, or configure your deadband module differently.

     

  • There should different ways to achieve your operating mode - you can consider the following suggestion -

    How about using CMPA to manage PWM1 and CMPB to manage PWM2 and you create deadband in software. PWM1 will be set when CMPA equals to TB counter and PWM2 will be cleared when CMPB equals to counter - this way complimentary output can be ontained. Now, the corresponding compare registers can be utilized to turn-off PWM outputs at next event. To turm off PWM1 load CMPA = Period and to turn off PWM2 load CMPB = zero assuming counter is operating in up/down mode.

     

  • Creating deadband in software as Arefeen Mohammed suggests does not seem to be a good idea. Deadband should be provided by hardware/cpu to avoid overlapping pulses in any case.

    The way SJU suggests (software trip zone) looks good to stop PWM. What about re-enabling PWM?

    When stopping PWM via one-shot trip, clearing it reenables both PWM outputs immediately and WITHOUT DEADBAND!

    So it seems as if you need a combination of one-shot and cycle-by-cycle trips to stop and reenable PWM (at the next timer underflow, with deadband)!?

    Or does someone have a better/different idea?

    @TI staff: On the 2812, you have a PWM output enable register (FCMPOE) for this purpose that is not present on the piccolo anymore. So how can we get the same behaviour on the Piccolo? Is the trip zone the proposed method to start/stop PWM?

  • Hi Marco!

    I assume you are no using all of the available trip zone (TZ) signals. From my experience using one of the available TZ signal results for enable/disable function yields the cleanest code. Thou you have the option of modifying AQ and DB registers simultaneosly something like the following code does.

     

    Regards, Mitja

    void SVM_disable(void)
    {
        EPwm1Regs.AQSFRC.bit.RLDCSF = 3;
        EPwm1Regs.AQSFRC.bit.ACTSFA = 1;
        EPwm1Regs.AQSFRC.bit.ACTSFB = 1;
        EPwm1Regs.AQSFRC.bit.OTSFA = 1;
        EPwm1Regs.AQSFRC.bit.OTSFB = 1;
        EPwm1Regs.AQCSFRC.bit.CSFA = 1;
        EPwm1Regs.AQCSFRC.bit.CSFB = 1;
        EPwm1Regs.DBCTL.bit.OUT_MODE = 0;

        EPwm2Regs.AQSFRC.bit.RLDCSF = 3;
        EPwm2Regs.AQSFRC.bit.ACTSFA = 1;
        EPwm2Regs.AQSFRC.bit.ACTSFB = 1;
        EPwm2Regs.AQSFRC.bit.OTSFA = 1;
        EPwm2Regs.AQSFRC.bit.OTSFB = 1;
        EPwm2Regs.AQCSFRC.bit.CSFA = 1;
        EPwm2Regs.AQCSFRC.bit.CSFB = 1;
        EPwm2Regs.DBCTL.bit.OUT_MODE = 0;

        EPwm3Regs.AQSFRC.bit.RLDCSF = 3;
        EPwm3Regs.AQSFRC.bit.ACTSFA = 1;
        EPwm3Regs.AQSFRC.bit.ACTSFB = 1;
        EPwm3Regs.AQSFRC.bit.OTSFA = 1;
        EPwm3Regs.AQSFRC.bit.OTSFB = 1;
        EPwm3Regs.AQCSFRC.bit.CSFA = 1;
        EPwm3Regs.AQCSFRC.bit.CSFB = 1;
        EPwm3Regs.DBCTL.bit.OUT_MODE = 0;

        enable = 0;
    }

    void SVM_enable(void)
    {
        EPwm1Regs.AQSFRC.bit.RLDCSF = 0;
        EPwm1Regs.AQSFRC.bit.ACTSFA = 0;
        EPwm1Regs.AQSFRC.bit.ACTSFB = 0;
        EPwm1Regs.AQSFRC.bit.OTSFA = 0;
        EPwm1Regs.AQSFRC.bit.OTSFB = 0;
        EPwm1Regs.AQCSFRC.bit.CSFA = 0;
        EPwm1Regs.AQCSFRC.bit.CSFB = 1;
        EPwm1Regs.DBCTL.bit.OUT_MODE = 3;

        EPwm2Regs.AQSFRC.bit.RLDCSF = 0;
        EPwm2Regs.AQSFRC.bit.ACTSFA = 0;
        EPwm2Regs.AQSFRC.bit.ACTSFB = 0;
        EPwm2Regs.AQSFRC.bit.OTSFA = 0;
        EPwm2Regs.AQSFRC.bit.OTSFB = 0;
        EPwm2Regs.AQCSFRC.bit.CSFA = 0;
        EPwm2Regs.AQCSFRC.bit.CSFB = 1;
        EPwm2Regs.DBCTL.bit.OUT_MODE = 3;

        EPwm3Regs.AQSFRC.bit.RLDCSF = 0;
        EPwm3Regs.AQSFRC.bit.ACTSFA = 0;
        EPwm3Regs.AQSFRC.bit.ACTSFB = 0;
        EPwm3Regs.AQSFRC.bit.OTSFA = 0;
        EPwm3Regs.AQSFRC.bit.OTSFB = 0;
        EPwm3Regs.AQCSFRC.bit.CSFA = 0;
        EPwm3Regs.AQCSFRC.bit.CSFB = 1;
        EPwm3Regs.DBCTL.bit.OUT_MODE = 3;

        enable = 1;
    }

  • Agree - in general it is safer to have a hardware based deadband but it is not true that deadband generated by software specially in 28xxx devices will create issues. There are applications where independent control of PWM outputs (not tied as complimentary) require some sort of software implemented deadband. Also, in this case the requirement is following  - "I want both PWM-outptus to go low with the next event. I don't want to use the trip-zone modules here as they do force the outputs low immediately and not at the next counter-zero event" .

    If I understand the requirement correctly - application dosn't want to turn-off PWM outputs immediately instead wants to turn-off at next event after receiving the turn-off signal. Considering this , loading compare registers such that we get no PWM output is one way to meet the requirement. Also, compare based solution will ensure proper PWM outputs with deadband after restarting the outputs. I am sure there are other ways to implement this and am looking forward to learn other options.

  • I have been using the Trip Zone module and find that it is possible to enable and disable the PWM on a cycle by cycle basis, that is the PWM will be re-enabled when there is nothing triggering the trip zone.

    However, I noticed, when my complementary PWM signals are re-enabled, the PWM pulse starts from where it was terminated. So for example, if i have a PWM signal with 50% duty cycle, and the tripzone signal gets triggered when the duty cycle is still at 25%, when it is re-enabled, it will start counting from where it terminated, that is from 25 to 50, which gives me a shorter first pulse upon re-enabling the PWM. I am actually trying to eliminate this effect but still looking for answers. So if anyone has any suggestions or ideas, please shed some light.

    Thank you

  • >>However, I noticed, when my complementary PWM signals are re-enabled, the PWM pulse starts from where it was terminated. So for example, if i have a PWM signal with >>50% duty cycle, and the tripzone signal gets triggered when the duty cycle is still at 25%, when it is re-enabled, it will start counting from where it terminated, that is from 25 to >>50, which gives me a shorter first pulse upon re-enabling the PWM


    I think i misunderstood the PWM waveforms i was observing. After looking closer, the PWM wasn't starting from where it last counted to. It was starting at half the pulse which does make sense. However, i am still wondering if its possible to start at a full pulse as i would be starting off at high frequencies anyways.

     

    Thank you

  • If I understood your problem right, i think you just need to set TBCTR to zero before you disable the Tripzone to start your PWM pulses again.

  • I tried that. All it did was start my PWM pulse as soon as the trip zone signal was not asserted (rather than starting it when TBCTR reaches 0). I am not too worried about how long it takes for the PWM signal to come back on(within a reasonable amount of time of course). What I am really after is the first pulse of the PWM signal after the trip zone signal is de-asserted.

    The first pulse of the PWM is half of the actual duty the cycle. According to our hardware guys, its probably by design to avoid in rush currents. However, i'd like to know if there's a way for us to control that first pulse width anyways?

     

    Thank you

  • We had a similar problem in the past and solved it with an hardware driver-stage with output enable.So you can enable your signals only when you know that they are ok.

  • I am writing the driver APIs for pwm module. I want to implement a stop function which when called should stop the output of a particular channel. The channel should get re-enabled  on start function. The whole idea is I would like to have independent control over the channels. I cannot use the "Trip-Zone Force Register" in this case since since  de-asserting would reenable both the channels to their previous state. For eg. If  both the channels have to be stopped simultaneously but should be reenabled at  different times then Trip Zone Force cannot be used.

    Other way is to disable the deadband and use the action and compare modules to output zero and then restore the state (dead band as well) on start.  But I dont think it is a good way to do . Anyone have better idea? Please give your suggestions.

    Regards,

    N.sugumar 

  • Hi!

    I'm facing the same problem. The first pulse seems to ruin all the benefits of the trip zone. Did you find a way to make the width of this pulse 0 or other known value?

    Many thanks,

    Monica

  • Excuse me if I misunderstood this rather long thread, but it seems the original problem is about trying to set both outputs of a complementary output to low at the next "pulse"

    How about setting your deadband larger than your period?

    When you want to re-enable, set the deadbands back to what they were supposed to be.