L298N breakout board short circuit protection

I am programming a DCC centrale for modeltrains using an L298N breakout board. And after blowing up both sides of this board I ordered a new one togather with a ACS712 current measure sensor.

The current sensor outputs 100mV/A so with a limit of say 2.5A I want to measure for 250mV with analogRead every program cycle.

I haven't measured the cycle time of void loop() yet but should be near ~1ms or less. I understand assembly and 8-bit uController structures so I avoid any complicated instructions. So I won't deviding a float by another float :smiley:

But I wonder, would this sensor and method be safe and efficient enough to prevent damage to the L298N?

I can buy 10 for 20€ on Ebay but I prefer not ever have to change the driver at all. Otherwise I go for the 43Amp motor driver with inbuilt current sense pin instead but these are more expensive

XY problem.
You are asking us how to make your solution for a problem work, but we don't get to know the problem.

So what is the current requirement of the load? What is the load?

The L298 is an ancient and inefficient technology. Get better drivers. Most modern drivers have overcurrent protection built in.

I am sorry I thought that the problem was obvious.

Problem: L298 board dies very very fast when the output is shortcircuited. Short circuits are poised to happen alot.

Requirement: the board needs to be fully protected against short circuits.

Proposed Solution: I want to use a current sense board to monitor the current of the power supply.
I monitor this current in every program cycle and disable the enable pin of the L298 when it exceeds maximum power. Program cycle is under 1ms.

Question: Is this method safe enough to prevent damage to the L298 board

Extra information: The L298 board must supply my modeltrains with power. I toggle the direction I/O to transmitt data to the trains over the track while the anble pin is '1'.The load is depending on how many model trains are running at the same time.

It may also be needed that a shortcircuit may last longer up to 50ms to prevent the uController from disabling track power with every spark.