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.

Short Circuit Protection

Other Parts Discussed in Thread: DRV8301

I am running lab 5b for the F2802x FOC chip. I have modified the system to include external on/off switch and a short circuit protection circuit. The short circuit protection circuit makes the GPIO pin 17 low for about 30 ms. Whenever this happens I want the motor to shut down so I added the following code to the 5b code:

// My variables

bool gOnOff;

bool gSckt

#define JED_GPIO_SW1 GPIO_Number_7 // External on off switch

#degine JED_GPIO_SW# GPIO_Number_17 // Short Circuit protection

for (;;)

{

//My Code

gOnOff = HAL_readGpio(halHandle, JED_GPIO_SW1); // On off switch

gSckt = HAL_readGpio(halHandle, JED_GPIO_SW3); // Short CIrcuit

if (gOnOff == true)

{

gMotorvars.Flag_Run_Identify = false;

gMotorvars.Flag_enableSys = false;

}

if (gOnOff == flase && gSckt == false)

{

HAL_disablePwm(halHandle);

gMotorvars.Flag_Run_Identify = false;

gMotorvars.Flag_enableSys = false;

}

if (gOnOff == false && gSckt == true)

{

gMotorvars.Flag_Run_Identify = true;

gMotorvars.Flag_enableSys = true;

}

// End of my code

In this code the on off part seems to be working fine, but the short circuit protection is not working. I suspect that the system gets disabled for the duration that the pin is low and comes back up as soon as the pin becomes high, which I don't want. How can I rectify this issue?

  • I don't understand...why are you not just using the Trip Zone feature of GPIO17 as is done in the project for the DRV8301 EVM?

    // SPI-SOMI or FAULTn
    GPIO_setMode(obj->gpioHandle,GPIO_Number_17,GPIO_17_Mode_TZ3_NOT);

    HAL_setupFaults


    also, you have a typo
    #degine
  • Chris, thanks for the help :-)

    I just started working with microcontrollers, so I simply did not know about the trip feature. What I was trying to do was, in the lab5b.c file, I wanted to trap the process in a small infinite loop where the two flags will be disabled. But obviously it did not work. I will try the method you suggested. 

    Also the typo was because I had to type the code into the sandbox here, I don't have access to internet on my work computer.

  • Chris,

    This may be another stupid question, but can you point me to where I can get more info about the trip zone feature? I also read somewhere that the HAL can support heating and I2t protections, but now I cannot find it among all the PDFs that I got.

    If you can please let me know, that would be awesome.
  • Chris,
    Based on spruge9 and some of the previous discussions on the forum I have done the following modifications to the code:

    in hal.c
    void HAL_setupFaults(HAL_Handle handle)
    {
    HAL_Obj *obj = (HAL_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_CycleByCycle_TZ2_NOT);

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


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

    // What do we want the OST/CBC events to do?
    // TZA events can force EPWMxA
    // TZB events can force EPWMxB

    PWM_setTripZoneState_TZA(obj->pwmHandle[cnt],PWM_TripZoneState_EPWM_Low);
    PWM_setTripZoneState_TZB(obj->pwmHandle[cnt],PWM_TripZoneState_EPWM_Low);
    }
    ...
    ...
    GPIO_setPullUp(myGpio, GPIO_Number_17, GPIO_PullUp_Enable);
    GPIO_setQualification(myGpio, GPIO_Number_17, GPIO_Qual_ASync);
    GPIO_setMode(myGpio, GPIO_Number_17, GPIO_17_Mode_TZ3_NOT);

    But it is still not working. What am I missing here?