Simple LED setup causing lots of strange problems

Hi

I have two Arduino setup on two separate computers...

computer 1) Arduino with 1 bright LED on PWM pin
computer 2) Arduino with 3 bright LED on PWM pins (only 1 ever on at a time) & an ultrasound sensor

Both Arduino after running in the gallery for a while are dying. Now, they are still listed in windows in the device manager and you can still send a serial message to it without errors, but it feels like it looses the code loaded on to it as it doesn't send back the serial message debug reply. If I reload the code back on, it works for a while and does the same thing again.

Here is a quick rough diagram of both circuits. The top circuit for computer 2 I haven't shown the ultrasound as I think the leds are the issue as both Arduino setups are failing in the same way.

We are using MOSFET IRF520, 0.25W 56ohms resistors and these superbright leds:
http://tinyurl.com/37tg66

Power dissipation: 130mW
Peak forward current: 100mA
Continuous forward current: 50mA

The Arduino code is very simple, here is the code for computer 1. It was written over a year ago, but should be ok
http://www.chrisoshea.org/storage/arduino_forum/arduino.pde

Someone suggested to change from USB powered to external power, so we now have a external regulated power supply but still have the same problem...
M-Volt 1.25A SMPS
Code: L49BR
http://www.maplin.co.uk/Search.aspx?criteria=L49BR&source=15&SD=Y

Does anyone have any good ideas?

Below are some circuit photos too.

Computer 1

Computer 2

Led

Thanks,

Do you know how much current the LED's draw from the pins they are connected to ?

Arduino pins can source 40mA max pr. pin and 200 - 300 mA max total.

Is anything getting hot ?

My only idea is to try to power the leds with the external powersupply.

just to follow up on Mikmo's question....

the Mosfet setup looks good.

Just speculation, but my guess is that cycling the power is erasing your program. This has been discussed in the forum before but no one has found a solution or the actual cause yet. Personally I think the programs get corrupted when power is removed during the boot phase, but that's just speculation. You might also look for bad code in your program that would cause the program to hang.

Power supply filtering is also very slim on the Arduino. You might try adding a 330Uf capacitor to the +5/GNd pins and seeing if the problem goes away. Switching large currents that are sourced from the 5V bus can cause noise, and noise is bad. As Mikmo suggests, you could try using an external supply too! That would avoid Mosfet switching noise getting into the logic supply.

D

PS: Mosfets have a very low on resistance (generally a few ohms), so you should be using a larger resistor in series with the LED. The one you have now will give the LED about 100MA if the mosfet on-state resistance is ignored.

I've had arduino's (actually, a Bare Bones Board)stop working after "a while"; I've assumed it had something to do with behavior of the usb/serial port when the host computer went into assorted stand-by modes. (but perhaps not?)
Does your board/program recover if you push the reset button? (mine would, without having to download the code again.) That would indicate that the program memory was ok, but the chip had somehow gone off into never-never land...

One thing that is very important to mention is that permanent installations should be programmed with an external ISP programmer because the bootloader can potentially corrupt your code if the right sequence of garbage ascii characters is fed to it at startup time.

The quality of the power supply is also very important... if next to your installation there is something else producing a lot of electrical noise there is no small capacitor that will save you but the measures have to be more drastic.

verifying the brownout fuses might also be a good thing to do.

A lot of time the conditions of the surrounding environment influence an installation more than its circuit.
We have arduino boards running for years now... without problems

massimo

Thanks for your replies everyone, will go and check it out on Thursday.

Massimo, do you think it could be related to this
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1182002219

And if so, perhaps changing to Diecimila would fix it?

Thanks

Are u using the bootloader?

Yes, the Arduino is as standard still using the bootloader.

"the bootloader can potentially corrupt your code if the right sequence of garbage ascii characters is fed to it at startup time."

What could be sent to the Arduino port on startup via the usb? From Director all I do is start the serial Xtra and open the port.

Also its worth mentioning, that the Arduino works for a while, then it seems to loose its code/dies, rather than not working at all from the beginning.

Thanks

hey Massimo

lots of people have had this corrupted code problem- maybe it should be added to the reference docs?

D

verifying the brownout fuses might also be a good thing to do.

i want to second that. if it's not the bootloader overwriting your program, it totally sounds what i was experiencing while breadboarding with the atmega and unstable power-supply. the program (or even the bootlaoder itself) would get lost sooner or later on a couple of chips. until i found out that the script i used to burn the bootloader disabled brow-out detection. since enabling it for 2,7v everything works fine just on batteries, no caps, no regulator (i can't tell if it restarts very often, but it definetly stopped forgetting programs).

kuk