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.

28035 EPWM使用Digital Compare Submodule设置封锁PWM输出

DSP28035 控制永磁同步电机做过流或短路保护,ADC模块的comparator模块的三个比较器的正向输入端,分别采样电机UVW三相电流,负向输入端使用内部的DAC,当出现过流时,三个比较器的的输出低电平触发EPWM封锁PWM输出。

现在问题是,当U相过流或短路时,COMP1OUT输出低电平,只能封锁UEPWM1AEPWM1B输出低电平。

                        V相过流或短路时,COMP2OUT输出低电平,只能封锁VEPWM2AEPWM2B输出低电平。

                        W相过流或短路时,COMP3OUT输出低电平,只能封锁WEPWM3AEPWM3B输出低电平。

我现在想当其中任何一相过流时,使6PWM都输出低电平,怎么操作。

EPWM部分程序设置如下:

// Init PWM Digital Compare Control Register for EPWM1-EPWM3
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP3OUT;       // DCAH = Comparator 3 output
EPwm1Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAH_LOW;                         // DCAEVT1 = DCAH low(will become active as Comparator output goes low)
EPwm1Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT1;                               // DCAEVT1 = DCAEVT1 (not filtered)
EPwm1Regs.DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;       // Take async path

EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = DC_COMP3OUT;      // DCBH = Comparator 3 output
EPwm1Regs.TZDCSEL.bit.DCBEVT1 = TZ_DCBH_LOW;                       // DCBEVT1 = DCBH low(will become active as Comparator output goes low)
EPwm1Regs.DCBCTL.bit.EVT1SRCSEL = DC_EVT2;                             // DCBEVT1 = DCBEVT1 (not filtered)
EPwm1Regs.DCBCTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;     // Take async path

// Init PWM Digital Compare Control Register for EPWM1-EPWM3
EPwm2Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP1OUT;     // DCAH = Comparator 1 output
EPwm2Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAH_LOW;                       // DCAEVT1 = DCAH low(will become active as Comparator output goes low)
EPwm2Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT1;                             // DCAEVT1 = DCAEVT1 (not filtered)
EPwm2Regs.DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;     // Take async path

EPwm2Regs.DCTRIPSEL.bit.DCBHCOMPSEL = DC_COMP1OUT;     // DCBH = Comparator 1 output
EPwm2Regs.TZDCSEL.bit.DCBEVT1 = TZ_DCBH_LOW;                      // DCBEVT1 = DCBH low(will become active as Comparator output goes low)
EPwm2Regs.DCBCTL.bit.EVT1SRCSEL = DC_EVT2;                            // DCBEVT1 = DCBEVT1 (not filtered)
EPwm2Regs.DCBCTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;    // Take async path

// Init PWM Digital Compare Control Register for EPWM1-EPWM3
EPwm3Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP2OUT;    // DCAH = Comparator 2 output
EPwm3Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAH_LOW;                     // DCAEVT1 = DCAH low(will become active as Comparator output goes low)
EPwm3Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT1;                           // DCAEVT1 = DCAEVT1 (not filtered)
EPwm3Regs.DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;   // Take async path

EPwm3Regs.DCTRIPSEL.bit.DCBHCOMPSEL = DC_COMP2OUT;   // DCBH = Comparator 2 output
EPwm3Regs.TZDCSEL.bit.DCBEVT1 = TZ_DCBH_LOW;                    // DCBEVT1 = DCBH low(will become active as Comparator output goes low)
EPwm3Regs.DCBCTL.bit.EVT1SRCSEL = DC_EVT2;                          // DCBEVT1 = DCBEVT1 (not filtered)
EPwm3Regs.DCBCTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;  // Take async path


// Init Trip Zone Select Register
// Enable DCAEVT1 and DCBEVT1 are one shot trip sources
// Note: DCxEVT1 events can be defined as one-shot.
// DCxEVT2 events can be defined as cycle-by-cycle.
EPwm1Regs.TZSEL.bit.DCAEVT1 = 1;
EPwm1Regs.TZSEL.bit.DCBEVT1 = 1;

EPwm2Regs.TZSEL.bit.DCAEVT1 = 1;
EPwm2Regs.TZSEL.bit.DCBEVT1 = 1;

EPwm3Regs.TZSEL.bit.DCAEVT1 = 1;
EPwm3Regs.TZSEL.bit.DCBEVT1 = 1;

// What do we want the DCAEVT1 and DCBEVT1 events to do?
// DCAEVTx events can force EPWMxA
// DCBEVTx events can force EPWMxB
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // EPWM1A will go low
EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO; // EPWM1B will go low

EPwm2Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // EPWM2A will go low
EPwm2Regs.TZCTL.bit.TZB = TZ_FORCE_LO; // EPWM2B will go low

EPwm3Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // EPWM3A will go low
EPwm3Regs.TZCTL.bit.TZB = TZ_FORCE_LO; // EPWM3B will go low

  • yanhui,

     PWMx模块只要配置TZSEL > DCAEVT1 = 1,  并配置 DC模块利用COMPxOUT 产生DCAEVT1就可以产生TZ信号。通过配置TZCTL > TZA, TZCTL > TZB就可以拉低PWM输出。

    假如可以只使用一个COMP1OUT作为这3个PWM模块的过流保护信号的话,就可以同时拉低这些PWM信号。可以使用一个总电阻的方式用来做过流保护。如下图,Isum为每路电流的总和,可以用来监控各相电流。

    下面是相应的程序,仅做理解。

     

     for(cnt=0;cnt<3;cnt++)     {

    // setup the Digital comparator DCTRIPSEL Register      

    //DCAH = Comparator 1 output,DCAL = TZ1      

    PWM_setDigitalCompareInput(obj->pwmHandle[cnt],PWM_DigitalCompare_A_High,PWM_DigitalCompare_InputSel_COMP1OUT);       PWM_setDigitalCompareInput(obj->pwmHandle[cnt],PWM_DigitalCompare_A_Low,PWM_DigitalCompare_InputSel_TZ1);

     // setup Digital comparator TZDCSEL Register      

    // DCAEVT1 on DCAH High (will become active as Comparator1 output goes High), DCAL = don't care      

    PWM_setTripZoneDCEventSelect_DCAEVT1(obj->pwmHandle[cnt],PWM_TripZoneDCEventSel_DCxHH_DCxLX); // 配置DCAEVT1的产生

     }

     

     

    void DRV_setupFaults(DRV_Handle handle)

    {  

    DRV_Obj *obj = (DRV_Obj *)handle;   uint_least8_t cnt;

     for(cnt=0;cnt<3;cnt++)    

     {      

    PWM_enableTripZoneSrc(obj->pwmHandle[cnt],PWM_TripZoneSrc_CycleByCycle_TZ6_NOT);

    PWM_enableTripZoneSrc(obj->pwmHandle[cnt],PWM_TripZoneSrc_OneShot_TZ1_NOT);

    PWM_enableTripZoneSrc(obj->pwmHandle[cnt],PWM_TripZoneSrc_OneShot_CmpA); // 配置TZSEL > DCAEVT1

     

    PWM_setTripZoneState_TZA(obj->pwmHandle[cnt],PWM_TripZoneState_EPWM_Low);     // 配置TZCTL > TZA  

    PWM_setTripZoneState_TZB(obj->pwmHandle[cnt],PWM_TripZoneState_EPWM_Low);     // 配置TZCTL > TZB  

    PWM_setTripZoneState_DCAEVT1(obj->pwmHandle[cnt],PWM_TripZoneState_DoNothing);      

    PWM_clearOneShotTrip(obj->pwmHandle[cnt]);    

     }

      return;

    } // end of DRV_setupFaults() function

     

     Eric