L298P Fast Braking

Hello,

I have an L298P shield on my Arduino Uno which I've been using to control a DC motor w/ an encoder.

I'm able to control the DC Motor by writing to the PWM and DIR pins provided on the shield. However, I'd like to be able to fast brake by shorting the MTRA + and - pins. Is there a way to do this on the L298P?

Website with pinout (I'm using pins 10 and 12 for PWM/ENA): https://electropeak.com/learn/interfacing-l298p-h-bridge-motor-driver-shield-with-arduino/

Code showing how I currently control the motor:

// speed: [-1, 1]
void setMotorSpeed(double speed) {
  if (speed > 0) digitalWrite(PIN_MTR_DIR, HIGH);
  else digitalWrite(PIN_MTR_DIR, LOW);
  analogWrite(PIN_MTR_PWM, (int) abs(speed * 255.0));
}

Thank you

Give a PWM zero.
Changing direction and giving PWM is impossible to control. Running backwards, stop or not, is not predictable.

What reference do you have for this?

I think applying "HIGH HIGH" to one set of motor pins on the L298N is a "brake" function, but I have seen warnings (can not find it now) about its use, and possibly harming the motor.

I was wondering if there was a simple way to apply opposing torque on a motor to make it stop and found that on an L298N, you could apply HIGH and HIGH to both IN1 and IN2 to do so.

On my L298P, I tested this by applying my 12V line to both of the MTRA pins and it worked. I just wanted a simpler way to do that through the shield.

I didn't see anything about this harming the motor, though.

Most, if not all motor drivers have such a brake function. Check the data sheets for the details. The L298 is ancient and extremely inefficient, so consider using a modern MOSFET motor driver.

Never mind, figured out how to do this with a bit of wiring shenanigans.

Thank you guys! <3