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.

LAUNCHXL-F28377S: Zero Current Switching with Trip-Zone Unit

Part Number: LAUNCHXL-F28377S

Hello TI community.

My goal is to implement Zero-Current-Switching for a MOSFET device.

If a comparator detects that the current through the switch has fallen below a threshold, the switch has to open.

Additionally I want to ignore the comparator for a certain time afterwards so that the current can rise again in the next switching period. In other words, I want to open the switch only from the moment the comparator perks up until the end of the period.

To program the Launchpad that should realize this mechanic I am using the TI Support Package for Simulink. To make the first tests as easy as possible I used no external signals and let the board generate two synchronized PWMs instead. The power supply is done over USB.

One PWM (PWM2A) is intended as a static switching signal that periodically closes the switch for a long enough time. The other (PWM3A) models the comparator signal that decides when to open it again.

If the comparator signal goes high, the PWM2A should be clamped to low (green curve on the right of the image below).

This clamping action can be done by the Trip-Zone Unit when feeding the comparator signal to a TZ pin (sidenote: the signal has to be inverted because TZ is active-low). But that does not satisfy the additional goal of ignoring the falling edge of the signal.

Fittingly I discovered that I could use a Blanking Window when triggering the Trip-Zone Unit via a Digital Compare event. The selected options in the GUI of the Hardware Support Package for Simulink can be seen in the image below. The selection for "Digital compare output A event 2" is basically the same as using TZ1 alone because TZ2 is "don't care". The filter should prevent any action for the first 200 cycles of the period. Only after that can events be generated.

These events are used by the trip-zone module on a "cycle-per-cycle" basis to force the PWM2A output to Low.

The problem is that PWM2A remains unchanged by PWM3A.

I checked that I used the correct pins on the launchpad for the PWM outputs. The pins used for TZ1/2 I defined in the Configuration Parameter Dialog.

ePWM3A is of course connected to TZ1.

Any help is appreciated. Thanks in advance for answers.

  • Make sure the input signal set to link to TZ1 in input X-BAR.
  • The connection of the input pin to TZ1 seems to be determined by register INPUT1SELECT. It is a sub-register of INPUT_XBAR_REGS which is described in chapter 7.3.2 of the microcontroller's Reference Manual (document SPRUHX5D – August 2014 – Revised December 2016).

    After conversion of my simulink blocks to code it should show a GPIO number assigned to the register INPUT1SELECT.
    But I can't find an assignment. Does this mean that no connection is made between the input signal and TZ Unit?
  • I didn't use the simulink to get code. Maybe you can use the TI's example projects directly in CCS.
  • Hi,

    It looks like we are not configuring the INPUT1SELECT register when TZ signals are routed via DC module. We have taken note of this shortcoming. As a workaround, the system initialize block can be used and the GPIO pin assignment can be made to the INPUT1SELECT that corresponds to ePWM3A, "InputXbarRegs.INPUT1SELECT = xx"; The system initialize block can be found under Simulink coder -> Custom Code -> system initialize.

    Regards,
    Venkatesh Chilapur
  • Thank you for your suggestion. I will test it on Monday.

  • Belated update: The "system initialize block" does its job and allows me easy assignment of
    registers (Hint to others who might read this: Don't forget EALLOW). Despite that I still don't
    observe the desired function. That means that Venkatesh Chilapur did indeed help me but
    I might have the wrong understanding of how to configure and connect the modules of the
    microcontroller.

    After checking every single register for the Pins, Action Qualifier Module, Trip Zone Unit and
    so on that I could find I added some more code. I tried to write down EVERY instruction that
    I need. The following is my current code.

    EALLOW;
    GpioCtrlRegs.GPAQSEL2.bit.GPIO21 = 3; /*Asynchronous input*/
    GpioCtrlRegs.GPBQSEL1.bit.GPIO42 = 3; /*Asynchronous input*/
    InputXbarRegs.INPUT1SELECT = 21; /*GPIO for Input1 = TZ1*/
    InputXbarRegs.INPUT2SELECT = 42; /*GPIO for Input2 = TZ2*/

    EPwm2Regs.TZSEL.bit.DCAEVT2 = 1; /*DCAEVT2 is CBC trip source*/
    EPwm2Regs.TZCLR.bit.CBCPULSE = 0; /*PWM-counter = 0 clears CBC latch*/
    EPwm2Regs.TZDCSEL.bit.DCAEVT2 = 2; /*DCAEVT2: DCAH(TZ1) = high, DCAL(TZ2) = don't care*/
    EPwm2Regs.TZCTL.bit.DCAEVT2 = 2; /*DCAEVT2 forces EPWMxA low*/

    EPwm2Regs.TZCTL2.bit.ETZE = 0; /*Deactivate 2nd TZCTL*/
    EPwm2Regs.DCTRIPSEL.bit.DCALCOMPSEL= 1; /*TZ2 is DCAL Input*/
    EPwm2Regs.DCTRIPSEL.bit.DCAHCOMPSEL= 0; /*TZ1 is DCAH Input*/
    EPwm2Regs.DCACTL.bit.EVT2SRCSEL = 1; /*DCAEVT2 source is DCEVTFILT*/
    EPwm2Regs.DCFCTL.bit.PULSESEL = 1; /*Blanking Window alignes to TBCTR=0*/
    EPwm2Regs.DCFCTL.bit.BLANKE = 1; /*enable Blanking Window*/
    EPwm2Regs.DCFCTL.bit.SRCSEL = 1; /*DCAEVT2 is filter source*/
    EPwm2Regs.DCFWINDOW = 500; /*Window Length in CLK cycles*/
    EDIS;


    In addition to my question of how the signals from TZ1 to DC- and Trip-Module should be
    connected I also would like to know:
    - Does the signal T2 play into the trip-zone action or is it independent? (see the first figure
    in the Reference Manual's Trip-Zone chapter)
    - Why is there the option EPwm2Regs. TZCTL.TZA when .DCAEVT2 and others can be
    configured separately?
    - What does EPwm2Regs.DCACTL.bit.EVT2FRCSYNCSEL do?

    Again thank you for every help.
  • Hi,

    We could see the same behavior. The DC event would not trip the output signal ePWM2A. Is there by any chance an TI example is available around DC block and using it to trip the output. Please note, the Trip operation works fine when just working from the Trip Zone alone. An example from TI would help us better understand the missing link in our configurations.

    Regards,

    Venkatesh C

  • Hi Manuel,

    To start, let's remove the lines enabling the blanking window to make sure this isn't the cause of the missed event. Looking over the configuration nothing stands out to me as incorrect, so let's see if we can generate a DC trip without the blanking for debug purposes as that portion of the module is a bit more advanced.

    A few questions:
    - You said you tested this with a TZ and it worked. How did you invert the signal since TZ events are active low? I just wanted to make sure you removed the line which inverted it since your DC event is configured to active high.
    - Which GPIO are you using to simulate the comparator? 42 or 21? It looks like you are configured to trip when GPIO21 is high. Just confirming that is what you intended.

    A couple of answers to other questions:
    - TZCTL has an option for both TZA and DCEVT2 because these are separate events. Any configured trip zone (DC or not) will perform the action specified in TZA. This is a higher priority event than the DCEVT2. A DCEVT could change the state of the PWM without tripping it.
    - T2 does not have any relation to what you are trying to do. This signal is for if you were switching your PWMs based on comparators (but not tripping). This is for a peak current mode control type application. You may be able to use it for yours but the setup would be different.

    Regards,
    Kris
  • Hi Kris,

    thanks for those answers at the end of your post. It seems that got me on the right track.
    I already suspected the use of TZA as you described but was still confused by the choice
    of TZA or DCAEVT in the TZCTL register. The knowledge about the independence of T2 also
    helped. This seems to have helped a lot, because I have now found the solution.

    The tripping via TZ-input alone worked as already mentioned by Venkatesh. I took note of
    the low-active behaviour and simply inverted the PWM that simulates the comparator signal.
    The lines for the filter setup had been removed. For the trip input I used GPIO21 as you
    said. The comparator signal is output by EPWMA3 and connected to GPIO21 via wire.

    After I confirmed that I experimented with the event-parameters until I got the
    right combo. I did not need parameter EPwm2Regs.TZCTL.bit.DCAEVT2 and found out that
    EPwm2Regs.TZSEL.bit.CBC1 is used only for "direct" tripping (without DC-module).
    The finished code is below.

    EALLOW;

    InputXbarRegs.INPUT1SELECT = 21; //Input1=TZ1=GPIO21
    GpioCtrlRegs.GPAQSEL2.bit.GPIO21 = 3; //Asynchronous input

    EPwm2Regs.DCTRIPSEL.bit.DCAHCOMPSEL= 0; //DCAH Input is TZ1
    EPwm2Regs.TZDCSEL.bit.DCAEVT2 = 2; //DCAEVT2: DCAH=HIGH & DCAL=X
    EPwm2Regs.TZSEL.bit.DCAEVT2 = 1; //DCAEVT2 is CBC trip source
    EPwm2Regs.TZCTL.bit.TZA = 2; //Event forces EPWM2A low

    EPwm2Regs.DCACTL.bit.EVT2FRCSYNCSEL = 1; //Event signal takes async path
    EPwm2Regs.DCACTL.bit.EVT2SRCSEL = 1; //Filter active
    EPwm2Regs.DCFCTL.bit.PULSESEL = 1; //Blanking referenced to TBCTR=0
    EPwm2Regs.DCFCTL.bit.BLANKE = 1; //Enable Blanking Window
    EPwm2Regs.DCFCTL.bit.SRCSEL = 1; //Feed DCAEVT2 into filter
    EPwm2Regs.DCFWINDOW = 650; //Window Length in CLK cycles
    //Make sure the window ends before the period; or else the first part
    //of the next period seems to be "overwritten". Make sure Window Length
    //is fitting for every period length you use!

    EPwm2Regs.DCFOFFSET = 200; //Window Offset in CLK cycles
    EPwm2Regs.DCFCTL.bit.BLANKINV = 1; //Invert window
    //Inverting the window makes events effective only during Window Length,
    //starting at the Offset

    EDIS;

    My application works now and I already tested it with a real switch and Comparator.

    Regards,

    Manuel