Arduino forgets sketches after a few minutes? (Power supply?)

Hey guys,

So, ive taken a dive into the Arduino to create a simply stepper motor apparatus. Its going well, but thanks to the "read before posting" i think i found a problem i was going to ask about, but now i have to ask about the soloution.

Im using an arduino Mega 1280 to drive a pololu A4983 step driver. Im powering everything with this beefy little thing

http://docs.google.com/viewer?a=v&q=cache:rzmUk-E2ZKYJ:www.meanwell.com/search/s-150/s-150-spec.pdf+S-150-9&hl=en&gl=us&pid=bl&srcid=ADGEESi6WADSHGflruiVLPsZbpy8nGKNLVn6G0e0P-O7VYEGwBmTcyHxUQTBhaLbhksHKtbIAZkjWWzu0pTWE0OvlO8V0-dT5fhTQze1dwQyEo5gGXnud5dyMfujof3LN44XIGaL6Hyd&sig=AHIEtbRci8jLlPuzii_N4wONzndaBsdrnA

Considaring my stepper motor is a Nema, drawing 1.2A, and i will be adding another down the line, this thing is serving me well...except for the mentioned "dirty power" in the FAQ.

The problem i have is i'll wire everything up, upload my sketch to the arduino, and it will work amazingly. For about a minute or two...then the motor begins the all too familliar squeel and seizes. Rebooting the arduino makes it work for a few seconds, but then back to the original problem. Seems the only soloution is unplugging the arduino from my setup, hooking up the USB and simply reuploading the sketch brings it all back to life.

I read on here that dirty power can cause the arduino to lose its sketch. So how can i go about fixing that? It is at a solid 9V, would i simply use a wallwart to power the arduino? I was using the VCC/GND pins the arduino wired to this PSU.

Reason i ask this is, ive read NEVER power up the arduino when the pololu driver is without power, as you'll blow the arduino. But, if you hookup usb, you get power, soo...

The other issue i'll have is, sometimes the stepper driver starts in the wrong direction, and will usually come back and go through the sketch, which is basically, step 1666 times one direction, pause 6 seconds, step back 1666.

Im sure some "dirt" comes from powering it all up and down, which makes me beleive i should hookup a relay or switch? The motor itself i'm sure destroys my DC signal, so i assume some beefy caps would correct this?

Lastly, i made such a rookie mistake and blew up my arduino last night. You guessed it. Crossed VCC and ground POOF! That one cap smoked. I have to asses damage today to make sure my pololu is still working. Anyway i can install a diode to prevent this on the next arduino?

Thanks in advance guys!

A couple of observations: Its the noise coming from the motors that can be the issue, and one way to minimise this is run power separately from the power supply to both circuits, using thick wire for the motor controller supply.
Adding more decoupling at the Arduino can help. That PSU should be strong enough to cope with the load at least :wink:

The running for two minutes or so without problems strongly suggests the motor controller is overheating, leading to misbehaviour - the little Pololu board really needs forced air cooling if used at high current I think - check the temperature (careful not to burn your fingers) of the Pololu controller after a minute or so, if its too hot to touch for any length of time consider a fan.

If you want to be able to separately power the two circuits add 2k2 resistors in series with the logic connections between them, this will provide current-limiting if a logic line is driven high into a powered-down destination - hopefully this is enough to avoid damaging the input protection resistors as well as the output drivers. The downside is that switching speed is slightly compromised. Alternatively arrange for the arduino to sample the supply rail of the motor controller and only drive outputs if its powered up.

Mark,

Thanks for the reply man. I'll give these suggestions a shot when my new board comes in.

Ive tried ruling out it being a heat issue, as yea, i thought thats what it was right off the bat. For one, pololu says you can push 1A without a heatsink. I run this thing between .9-1.2A, as torque isn't really required for what i'm doing (sweeping a laser beam).

In efforts to rule out heat, I grabbed a RAM chip heatsink and glued it to the pololu. It does heat up, but not too bad to the touch. Also, I placed a fan right next to it and gone as far as timing the moment of shutdown to see if it varies based on heat.

Now you would think IF its heat, that after the initial shutdown, if i waited long enough it would work again, but, not such the case. Doesnt matter if i wait 30 seconds or 30 minutes, i'm stuck with a moot project, unless i simply reupload the code.

The other 2 reasons i think i've ruled it out is, ive seen this thing on a meter go into shutdown, and the current would climb REALLY high, then stop at 0. When it stops now it holds precisely at 1.2A, just stops moving. Also, if i hook this thing up without an arduino, just manually wire all the logic to 5V and GND as needed, it will run indefinitely.

There are 2 9V outs on this beefy psu, im thinking this time around i'll run the arduino by itself off of one rail, still with the decoupling caps as you suggested, and see if i can come up with another 5V supply for the chip other than the arduino, so that the arduino is simply providing nothing more than logic, as right now i was running the arduino powering 5V to the pololu.

Thanks again mark!

Hmmm. Odd. just checking you're not taking motor power through the Arduino regulator?

Nope, motor power comes from that beefy supply. The a4983 5V comes from arduinos regulated 5v out. I was running the arduino in paralell to the motor for the 9v supply. Pretty much set one side of my breadboard to 9v/Gnd and ran everything off of that. Would it help if i drew up a diagram?

This A4983?

Yes, lets see what else you have connected.

alright guys, just a note, the left side of the PCB is the 5V from the arduino, and the right side is the 9V from my source, and yes it is the a4983 as you linked to. Heatsinked and fanned.

Also, note the decoupling caps on the stepper (kinda hard to see in illustration) and the resistor shown is a 100k Pulldown, as MS1 does not have an internal one, so floating it isnt good.

My only guess here is a rookie mistake in the power? Still my new arduino hasn't arrived :frowning: Expedited shipping my arse!

A schematic would help, that physical wiring diagram is not much help.
It sounds like the flash image is being corrupted. Is your code trying to write to flash? If not then you need supply decoupling on the 5v at the supply input to your driver. The interference from the motor must be triggering a reset and the boot loader thinking it has data wipes the flash. You can test this theory by doing a memory dump of the hung system and comparing it with a freshly loaded one.

Totally agree there Mike, those fritzing pictures are the worst.
Doesn't that program do schematics?

yea it does...sorta, except the wiring on the schematics is point to pint,i mean it runs diagonal lines everywhere and makes no sense!

You should be able to tidy those up.

Ill see if i can clean up the schematics version. Anyways, got the new arduino. Did alittle rewiring. For starters, cannibalized the adaptor plug from a dead adaptor to be 9V center positive and ran that to my big 9V supply directly.

Next i salved a 5V regulator from a computer monitor, cant remmeber the part number, but it supplys a constant 5V from my 9V supply. i now use this to power the logic on the a4983. '

Basically now what i have setup is, the arduino is powered direct from the 9V source, as is the pololu board. The only wires comming off the arduino are pins 2-4 to simply control hi/low on the stepper.

Guess what?

SAME PROBLEM!

This arduino for some reason seems to have a good 5 second delay on boot before the sketch is loaded. So upon boot, you can hear the motor humming, but not turning. Once the sketch engages, it shuts off. First time it worked fine...for about 30 seconds, then seemed to shut off again.

Grrrr..!! Man my whole project has been delayed terribly because of this behavior! I should be running control buttons and an LCD by now!

I appreciate the help guys

So same solution, post a schematic and we can see what you have.

Alright guys, as requested, the schematic. Forgive its terrible points, im completely new to Fritring. I'll update the drawing to include the new 5V regulator.

Im going to see if i can atleast get an Arduino and A4983 model in Multisim, i could atleast make an intelligent schematic of what i have there.

Quite standard so far apart from connecting Vin to +5V, don't do that.

Right, thats actually not connected...couldnt get Fritzring to delete that wire. Sounds simple and stupid, but trying to click it, resulted in it highlighting the arduino.

Thanks

Well guys, im happy to report, my problem is solved.

I feel like such a n00b for what the cause was. I hope this helps someone else.

SIMPLE! Wrong pins! Yup. Was hooked up to Analog 2-4, when i was calling digital 2-4. Moved the 3 wires across the board and everything works beautifully. Man what a dumb mistake, but hey, i learned from it and cleaned up my project in the process. So, thanks again for everyones help!