Go Down

Topic: Fried my Atmega328 using L298 to drive step motor ... what to blame? (Read 2882 times) previous topic - next topic

jc000

Hi.  This morning I seem to have fried the atmega chip on my Duemilanove, and so I'd like to figure out the problem so I don't do it again.  The Deumilanove is working now because I replaced the Atmega328 chip with a replacement that I had (coincidentally) just ordered.

I am driving a step motor using an L298 circuit built as a shield.  I have used this design in other projects, and it's worked fine.  (In fact, this exact design feeds my cat every 12 hours :D)  But this is the first time I have run a motor for long durations (over an hour) at a 20% duty cycle.  The driver chip does not heat up too much at 20%, although it did at 25%, so I dialed it down.

This is also the first time I am using a particular motor I just picked up.  The motor is not marked in any way, so I am driving it with 12V but frankly I have no idea how much to use on it.

The schematic is attached.

Does anyone have ideas what could have caused this?

CrossRoads

Usually fried atmega is due to excessive current draw on a pin for too long.
What's the load like from the L298?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Magician


How your protection diod's connected, looks like all 4 to ground?
There is a pics from data sheet:


jc000

Thanks...  Yeah, I was trying to replicate that drawing.  So in the datasheet schematic, D1 connects pin 13 to +Vs, D3 connects pin 14 to +Vs.  In my circuit, D1 connects pin 13 to +12V, and D4 connects pin 14 to +12V.  So my D1/D4 should be doing the job of D1/D3 in the datasheet schematic.  (Note that there are 8 diodes in all, so perhaps the right-most part of the drawing was cut-off for you.)

CrossRoads, thanks for that tip, I'll have to figure that out.  My little meter doesn't read current, and my big meter is to large for this circuit.  Guess I need to upgrade.

jc000

Ok, I managed to measure current FROM the L298, and it came it an 210mA.  Current TO the L298 will be the tricky bit.

Magician

Oooops....
Have not noticed small slider at the bottom of picture. -):

There are two switches, is it possible that
at some time when it open there is LOW on digital pins?


cr0sh

I'm curious - are you really using 1n4004 rectifiers as your diodes? You're supposed to use "fast-recovery" diodes with trr < 200ns (unless you were just doing on-off switching of a DC motor, without PWM), according to the L298 datasheet - generally these would need to be Shottky diodes; this might be a cause of your overheating at the larger duty-cycle, though I'm not sure if this would cause blown pins on the Arduino...
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

jc000

Yep, really am using 1N4004's.  When putting this together, I couldn't quite grasp the complexity of the diodes available.  Trr is rarely listed on diode data sheets.  So I used what it seems like other circuits posted on the Internet were using.  From reading around, it looked like about 80% of the time, people were like "Anything is fine, 1N4004's are fine", and then the other 20% gave non-specific warnings that something better should be used.  Never could I find a part# that should be used instead.  So anyway, now I ordered some 1N5822's to try, but even that does not list trr on the data sheet!  I am relying on the "Extremely fast switching" in the marketing section of the datasheet.  Do you think 1N5822's will be sufficient??

Also buying an Aavid 566010B03400G heat sink.  It seems that heat is normal and expected for the L298, but since I'm leaving this thing on all day now, and not real savvy about thermal engineering, I'm trying to play it safe by keeping the chip cool to the touch.

Magician, there is definitely LOW on Arduino pins 11 & 12 when the switches are open.  R1 & R2 are there to pull the pins low.  This is before I learned about pull-up resistors on the chip itself, so future revs of this will have the switches simply connect GND to the pin.  But these Arduino pins are not part of the L298 circuit, they're just there so I have some control over the operation of the sketch.

Magician


Sorry, if my question looks foggy.
Murphy's laws:

    If anything can go wrong, it will

I mean, if digital pin could be input or output, at some point in time
it could become output with LOW and if switch engage.....
what happened? Unlimited current flow will fry your chip.
I'm sure you verify code, and it perfect. Pin is input forever.
But millions of factor you just not aware of, example:
- when boards start up (before definition pin=input), what status of the pin?
- power ripple;
- compiler/bootloader/memory error;
- hardware bug (and atmel wouldn't say about it);
- ESD.

By the way , your cat is walking static generator!!!

So, in order to play safe, and not worry about all this factors,
put 100-500 Ohm resistors on each wire that coming to input ports of your board
from elsewhere. If you add up  zener diods  >5.5V, between input and ground
it will make chips bulletproof in ESD case.

In may opinion, it's still not clear that L298 is guilty.


jc000

Thanks, Magician.  Okay, that makes sense.  I also am not at all certain the L298 is to blame.  if I posted it on the general board, they'd be like, "Well what were you DOING with the Arduino?  And post it there..."  ESD problems seems like a pretty good stab at an explanation, especially given that I was handling the Arduino+shield unit quite a bit the first day.  I have been running the same system using the replacement Atmega since I posted the original, and the replacement chip is not fried.  Perhaps this will be a good lesson in bullet-proofing, as you say.  And zener diodes.  I've seen those, I'll have to learn about them.

Btw, the cat feeder is working flawlessly. :D  The enclosed circuits are separated from the cat by about 3 feet of cable, although I suppose the motor and wires are exposed, so she could static those things up good if she was motivated.  I have some writing and picture-taking to do, and then I'll post that one on the gallery.

cr0sh


Yep, really am using 1N4004's.  When putting this together, I couldn't quite grasp the complexity of the diodes available.  Trr is rarely listed on diode data sheets.  So I used what it seems like other circuits posted on the Internet were using.  From reading around, it looked like about 80% of the time, people were like "Anything is fine, 1N4004's are fine", and then the other 20% gave non-specific warnings that something better should be used.  Never could I find a part# that should be used instead.  So anyway, now I ordered some 1N5822's to try, but even that does not list trr on the data sheet!  I am relying on the "Extremely fast switching" in the marketing section of the datasheet.  Do you think 1N5822's will be sufficient??


Based on what I could find (which wasn't much) the 1N5822 should work well and be the kind of diode needed if you're doing PWM. I ran into the same issue you did, I ended up doing some research and found some 1N4935 fast-recovery diodes (at Electronic Goldmine) that should work great. I think maybe the reason trr isn't listed much on datasheets is that perhaps it's a "given" that shottky diodes will always be in the 10s of nanosecond range or less today...? I dunno...

Also buying an Aavid 566010B03400G heat sink.  It seems that heat is normal and expected for the L298, but since I'm leaving this thing on all day now, and not real savvy about thermal engineering, I'm trying to play it safe by keeping the chip cool to the touch.


Yeah - you need a heatsink of some sort; I am curious as to how you found the one you did? For a while I was looking for Multiwatt15 heatsinks, until I found some that would work at a local electronics junkyard (Apache Reclamation here in Phoenix, AZ) - I could find only certain things listed online for such heatsinks, but no pictures to see that they would actually work. Really, you could probably get away with a piece of bent and drilled aluminum stock. Remember to add heatsink grease, whatever your use!
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

jc000


I am curious as to how you found the one you did? For a while I was looking for Multiwatt15 heatsinks, until I found some that would work at a local electronics junkyard (Apache Reclamation here in Phoenix, AZ) - I could find only certain things listed online for such heatsinks, but no pictures to see that they would actually work. Really, you could probably get away with a piece of bent and drilled aluminum stock. Remember to add heatsink grease, whatever your use!


Well, this one was pretty easy.  I try to buy everything from Mouser.com, to simplify my purchasing.  When I searched Mouser for Multiwatt heatsinks, thinks is the the only one that came up!

Thanks for the tip on the grease, I will do that.  I'm pretty sure that's available at the local electronics store.

Go Up