Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: extreme.aly on December 14, 2013, 04:22:33 AM

Title: L298 protection..
Post by: extreme.aly on December 14, 2013, 04:22:33 AM
Hello everyone
I'm making a self-balancing robot using Arduino Nano V3, knock-off from ebay, and L298D to control my Pololu's 29:1 geared motors (http://www.pololu.com/product/1443/ (http://www.pololu.com/product/1443/)) that has a stall current of 5A, and free running 300mA at 12V.

Recently, I screwup the battery that I had (12V, 1.8AH), by charging it the wrong way, so I decided to use a wall adapter to power up the robot (because I was too curious to test it).

I was in the stage of fine tuning my PID values before my battery died. Then I connected my wall adapter to the robot.
I was shocked to see my robot balancing on power from wall adapter on the same values. But that happiness lasted for only 20secs.
Since it was balancing, I decided to give robot a little push to make sure its working fine. But I don't know why, after two swings, the robot stopped responding to the accelerometer, and the motors were 'on' in their full speed (the motor directions were not responding).

Then I pulled out the wall adapter and plugged it in again, and voilaa, my Arduino died too :P (Now when I connect that Arduino Nano to my computer, it detects the FT232R IC, but it can't burn any program.. And the ATMega328 gets very hot whenever I plugged it into any 5V, even from USB. So i'm guessing that ATMega328 died)

So, after a wonderful story :P my question is, What could be the issue that my Arduino died? Can someone help me do the forensics, so that I be sure that it doesn't happen next time? :P

One more thing. I borrowed another Arduino Nano V3 (exactly the same) from a friend, burned the same code, and power it up from USB (not from wall adapter :P). And the motors are working just fine (obviously, i'm not getting that speed and torque, I have to pick the robot up in the air to see the motors moving)

So from this, I realised that only Arduino died, not the motor controller.
P.S. I'm not using opto-isolators.

Here is the power scheme that I'm using:

1. Wall Adapter / Battery --> Fullwave rectifier (reverse polarity protection)

From rectifier, it divides into two groups:
-- Rectifier --> L298D, for Motors
-- Rectifier --> Arduino Nano VIN (it supports upto 20V as input voltage and outputs 5V from VCC pin)

From Arduino's VCC, I powered up the following:
-- L298D's VCC
-- Bluetooth
-- Accelerometer/Gyro

All had a common ground (ground from rectifier).
Title: Re: L298 protection..
Post by: waltr on December 14, 2013, 09:52:55 AM
Are there diodes on the L298 outputs to ground and V+ to clamp the motor's back EMF?
Title: Re: L298 protection..
Post by: jwatte on December 14, 2013, 10:59:32 AM
Typical MOSFET based H bridges use the body diodes of the MOSFETs for those clamping purposes.

There are many things that could go wrong. The first thing would be electrical short circuits somewhere. If your robot is moving, are all the electronics held firmly in place? Is there sufficient clearance everywhere so that no two cables or circuit boards or plates or connectors will bang into each other?

The second thing would be back EMI. The clamping diodes (whatever form) are there to shunt the back power to the power source, to protect the H-bridge. However, the power source does not have infinitely low source impedance, and thus the power shunted backwards will go to other places, such as the input regulator on the Arduino Nano. You say it's rated for 20V, which is weird, because the most common regulators either top out at 30-35V (normal linear,) or they top out at 16V or below (LDOs of various kinds.) It's totally possible the max voltage for the regulator was actually 16V, and the back EMI drove input voltage higher than that, and fried the regulator.

The third thing would be the response of your power supply. If it is an unregulated supply (transformer, full bridge rectifier, capacitors) then the response will be pretty predictable when you put load on it; more load means more ripple because the capacitors run out and lower voltage because of losses in the transformer. However, if it's a regulated power supply, then it will try to compensate for changes in load, and many switching power supplies may over-compensate. Again, this may lead to a dangerous swing in voltage, which may temporarily overvolt some input and fry it.

When I use motors and power supplies, I always put a high-capacity battery in the loop to serve as source impedance matcher. You also have to match the voltage to the chemistry of the battery. A 4S LiPo will not be happy about seeing 16.8V all the time, but if you slightly discharge it and float it at 15.8V, it can sit there all year and not take much damage.

In general, when dealing with higher-power motors, these things happen. When you buy parts, buy two or three of each, because you'll probably need them. I've burned a 18V/25A Pololu motor controller trying to drive those same motors (two in parallel); presumably because of overvolting when stalling and trying to reverse direction (at which point the temporary voltage can be 2x the source voltage.)
The L298D is nowhere near beefy enough to actually drive those motors should they go near stall.