How to properly use enable pin on TB9051FTG?

Hello I am having an issue with the braking on the TB9051FTG where the motor will not stop right away after I trigger it to stop(this is when I override the en pin by shorting it to VCC). The solution I found is to control the enable pin to cut off power to motor when it needs to brake. This solution works but I noticed the motor driver stops working after a couple cycles of turning enable pin from LOW to HIGH(vice verse).Below is the code to control motor direction and braking. Can you help me fix this issue where the motor driver stops working after some cycles of changing motor direction/braking?

Hardware: Pololu - TB9051FTG Single Brushed DC Motor Driver Carrier

void setMotor(int dir2) {
    if (dir2 == 1) {
      analogWrite(en, 0);
      analogWrite(en, 255);
      analogWrite(pwm1, 0);
      analogWrite(pwm2, 255);
    }
    else if (dir2 == -1) {
      analogWrite(en, 0);
      analogWrite(en, 255);
      analogWrite(pwm1, 255);
      analogWrite(pwm2, 0);
    }
    else {
      analogWrite(en, 0);
      analogWrite(en, 255);
      analogWrite(pwm1, 0);
      analogWrite(pwm2, 0);
    }
  }

Pulling both PWM lines on the TB9051FTG low puts the driver in brake (slow decay) mode and pulling the EN line low puts the driver in coast (fast decay) mode, which is consistent with the stopping behavior you are seeing.

When you say the motor driver stops working, do you mean permanently or just for some time? Commanding a motor to change from full speed to a dead stop (or the other way around) can cause large voltage or current spikes that could damage the motor driver. Could you post a link to the specifications of your motor?

-Claire

Motor Specifications:
Model: 5840WG-555PM-72-EN 24V
Gear ratio : 1/72
No Load Current: < 650 mA
No Load Speed : 210 RPM
Rated Torque : 70 Kg.cm
Rated Speed : 125 RPM
Rated Current : < 9 A
Stall Current : < 26 A
Stall Torque : 70 Kg.cm

The motor stops working just for some time, I have to reset by unplugging the battery or resetting ECU. I have the OCC pin shorted to VCC to ignore current spikes. What is the best way to program to do a fast decay without large voltage or current spikes?

It seems like there could be mistakes in the motor specs you posted since the rated torque and stall torque listed are the same, but if not, that motor is way overpowered for the TB9051FTG. I am surprised you have not had more issues or permanently damaged a driver. One of our high-power motor drivers like the G2 24v13 or G2 24v21 would probably be more appropriate.

-Claire