Preventing DC motor stalling/overheating using L298N

I am controlling a micro slot car track with a L298N and an Arduino Mega, this works fine at the higher speeds, if the speed is set too low (I think im right in saying the PWM is set low?) then the car doesn't have enough torque to move and just stalls, shooting the current to around 1A! they use around 200ma normally! This is killing the motors (I assume things are melting internally and shorting?).

My current solution has been to set the minimum speed to be over what they typically stall at in the code, but I would like a less hard coded solution.

I had seen a few different ideas:

  • Use a current limiter
  • Use a motor controller that limits current instead of voltage
  • Measure the current and apply logic in the IC

I'm not really an electrical engineer so a dev board with this functionality would be preferred but I am also able to transfer a schematic to a perfboard!

What would be the most logical approach?

Are you using a "naked" L298 or one on a breakout board? There is provision for a current sense resistor in the device itself but that may not be brought out on a BoB. You could potentially sense the current and provide limiting through the processor - though I'm not sure how since you can only control PWM duty cycle. With a bit more circuitry you could also reduce the supply voltage to the L298 beyond a certain current.

This is easy to do. That breakout board has the current sense lines wire to ground. You can disconnect them with a sharp knife. Than you can solder a shunt resistor of 0.1R between the current sense pins and ground. With an analog pin you can measure the voltage and calculate the current. With some efforts your software can figure out that it is stalling.

I can also think of an encoder (attached to the wheels) or an accelerometer to detect whether the car is moving or not.

What also helps is to lower the frequency to somewhere between 50Hz and 100Hz. This gives better behaviour @ low dutcy cycles. And it won't make that annoying high pitch tone of 490Hz you usually hear with analogWrite.

And also with programming you can fix alot as well. You can increase the mininum dutycycle to the lowest effective speed. So you will skip the lowest dutycycles. And than you can program a brief kickstart. For a real short period of time you can use a higher dutycycle which is mininum speed + a little bit more. To get the car moving from a standstill.

With the above 2 methods, you can propably even live without feedback. However, more measures are always better. Current sense, accelerometer/encoder feedback and the mentioned software solutions.. all at once.

Kind regards,

Bas

How did You measure that 1 Amp current?

Yeah I did see that the current sensing pin is pulled to ground on the breakout board, I think you might be right that adding a shunt resistor and measuring the current may be the best way to ensure the motor doesn't go pop.

Unfortunately adding anything to the motor/car itself is not possible as it is a standard microscalextric car and is tiny!

Lots of useful information thank you!

My bench power supply has a current display, so granted that is for the full circuit, but the smoke leaving the car was also a good indicator... :rofl:

I am using the breakout board, I am not opposed to trying to use a naked L298, but that is not quite within my skillset just yet. But as @bask185 mentioned, the L298 does have a current sensing pin pulled to ground that i can disconnect and attach to a shunt resistor to measure the current.

The limiting the power supply current is also another good suggestion but I am actually using two motors (I never mentioned this in the question to be fair!) so I wouldnt be able to limit each cars current just the total current, so in this case that doesn't quite fit. But if I was using one motor that would probably be ideal.

There is a quick fix. You could also apply the shunt resistor between the GND connection of the L298 and the system ground. With higher current, the voltage on the GND will raise and is measureable.

The current also means that the internal mosfets would see a smaller Vgs but I think that is neglectable for you. I did this trick once with a different H bridge and it worked.

Do take note that you will be measuring the sum of both channels at the same time. So make sure the shunt can handle the power. Otherwise it will not be the motors where the smoke will come from.

Bas

I think my best bet is to attach a shunt resistor to each current sensing pin, I can see the L298 has one per channel. That way I can ensure that I dont experience any magic smoke!

All electronics run on magic smoke. If the smoke escapes, it is the end of the line for that chip :smiley:

Not in an L298! Defiantly bipolar...

O than it propably matter even less

A simple two transistor current limiter in series will help to disipate the repetitive stall current energy. Easy to implement abd effective.

image

(I used this on a similar problem for a client, there were over a million retro-fitted in the client's machnes).

If you want to stay with an L298 motor driver...
An Arduino motor shield Rev3 has the sense resistors and connections to the analogue pins.
Leo..

I am using a L298N motor shield, not an arduino motor shield, but I am using the shield as a reference for current sensing.

I am a little confused as to why in the schematic for the motor shield the sense pin comes before the resistor, from my, granted little, knowledge of measuring current with shunt resistors, don't you typically measure voltage drop across a resistor? With this schematic is it before the resistor? So the voltage wouldn't have dropped yet.

I think I might be overcomplicating this and the reasoning is quite simple, but I can't seem to put a finger on it!

Measure a voltage drop across a resistor.... That's exatly what's done there. The current passing R1, or R2, generates a voltage at the sense pin.

Opening a new thread for the same project is against forum rules.

L298 ground current ( = motor current) flows through those 0.15 ohm shunt resistors (one for each motor). An opamp amplifies that to a usable voltage for two analogue inputs.

There bound to be clones of that shield. Consult their datasheet if they use the same circuitry.
Leo..

Apologies, I understood it was related but thought it was more of a different/sepcific question that could be its own question. Noted for the future :+1:

So I understand the use of those shunt resistors, but correct me if im wrong, current flows from the postive to negative, so surely taking the voltage before it flows over the resistor to the negative, won't have any voltage drop?

I guess my question is, why has the voltage dropped before the current goes over that shunt resistor.

Threads merged.

1 Like