Motor resetting microcontroller problem - Page 1
Forum section: electronics / beginners

author: mribble
author_rank: Regular Contributor
timestamp: November 23, 2012, 10:42:51 am
content: I know there are a bunch of threads on this topic, but they typically say look at a scope or add more caps to reduced noise/brownout. I have done both of those and am still having issues so this isn't too much of a duplicate thread.I'm using a atmega328 with the arduino bootloader on a custom circuit board I designed (see circuit below). I don't have issues when the motor is starting. The most predictable way I can force a restart is by putting the motor under heavy load for about 30 seconds and then the microcontroller will start resetting. I have checked the motor and the motor driver (which is heatsinked) and neither is getting hot.I have also looked at the reset pin and the 5V signal going into the micro and neither has a big change when the reset happens. I've set triggers at 4.5V and 5.5V and those don't trigger. Is there something else I should be looking for with the scope or can a noisy signal with less voltage change than 0.5V cause a problem? I think this proves it's not a brownout or that there is a lot of noise, correct? I'm using a 3A wall wart to power the system and it's possible the motor exceeds that 3A, but if that were the issue I'd expect to see a voltage drop on the 5V rail when the reset happens, right? I'm happy to capture and share scope traces if people think that will help, but so far I've not seen anything interesting (by interesting I mean things I think could cause a reset).Below is a circuit I'm using. The power filter portion is in the upper left. I have 100uF before and after the 5V linear regulator plus some smaller caps. I also have 100uF over by the motor. I have tried adding another 100uF cap after the linear regulator and it didn't seem to have an impact.A huge thanks for whatever help you can provide!

author: PA0PBZ
author_rank: Super Contributor
timestamp: November 23, 2012, 11:21:01 am
content: Can you post the board layout?

author: Psi
author_rank: Super Contributor
timestamp: November 23, 2012, 11:32:48 am
content: Try some really basic code that only runs the motor without doing anything else, then load the motor and see if it causes a reset.That will tell you if the problem is software or hardware related.

author: mribble
author_rank: Regular Contributor
timestamp: November 23, 2012, 11:41:06 am
content: Psi, thanks for the suggestion on software, but I'm much better with software than hardware. I've already done some experiments and am quite sure the problem is not with software. I'll also point out this circuit only drives a single motor.PA0PBZ, below is an image of the board. I'm also post a link to a zip with the eagle files in case someone would rather look at those.http://www.glacialwanderer.com/_blog/blog2012/Nov/ElectroEelWheel_v23.zip

author: PA0PBZ
author_rank: Super Contributor
timestamp: November 23, 2012, 12:11:45 pm
content: Hi,Yeah, sort of what I expected to see with the problems you have... Your ground is all over the place.Start by soldering some real wires from pin 1 and 15 of the L298 to the power jack ground (which seems to be marked + by the way).See if that makes any difference.

author: Psi
author_rank: Super Contributor
timestamp: November 23, 2012, 12:33:45 pm
content: Quote from: mribble on November 23, 2012, 11:41:06 amno probI only mentioned it because there are a couple of gotchas with software that can cause resets and its easy to spends hours trying to find a hardware fault.-Noise on interrupt pins causing massive continuous interrupt handlers to fire and blocking watchdog.-Bad pointer code causing the execution pointer to jump outside the code.-Missing watchdog resets on custom branches.But from the pcb layout yeah, i agree with mribble, its probably a ground routing issue.

author: McMonster
author_rank: Frequent Contributor
timestamp: November 23, 2012, 01:13:29 pm
content: Didn't you reverse the polarity of capacitors on AREF and RESET pins by accident? Specifically the one between DTR and RESET pin don't make much sense to me (but it might just be a clever trick I haven't seen before).

author: mribble
author_rank: Regular Contributor
timestamp: November 23, 2012, 01:51:28 pm
content: PAOPBZ, I added that jumper wire and it seems to have fixed it! I'll test it more later today, but so far so good. Thank so much for making an easy to try suggestion like that. I can now add the jumper wire to the few test boards I have made and in the future if I make more I'll clean up the ground signals. I realize the reason I probably wasn't seeing the issue on my scope is because I wasn't probing the problem area of ground (I had assumed that ground was ground...).McMonster, the polarities are fine. The point of that cap by DTR is to provide a quick reset pulse when programming via an ftdi cable when the transmit signal line is active. There are a lot of projects that use this trick including Arduino boards, but it originated long before Arduino and I'm not sure who came up with it first. That would be an interesting bit of history if anyone happens to know it.If anyone is interested where this board will eventually show up, it's for a new version of this electric spinning wheel (the kind that makes yarn).http://www.electriceelwheel.comThanks everyone!