Arduino Mega temporary stops communicating over USB after power surge

hi
i am testing '4 hardware serial read and write to USB' on Arduino Due, it works fine in SURGE INVIRONMENT,

but when i use same on Arduino Mega 2560, suddenly surge produced and Arduino Mega 2560 stops communicating USB and blinking communication led stops blinking, it turned into continue glow.

and when i remove the usb cable and attached again the Board starts working again. so every time i am facing the problem.

can any one suggest me solution please, because i want to use Mega instead of Due.

Thanks In Advance.

please help me anyone , or i m wrong..?,

Help me its important for my Project for regular use of arduino.... :frowning:

I don't understand "SURGE ENVIRONMENT" :frowning:
Eventually post your code. Are you sure that you changed the board specification in the IDE, before uploading your sketch?

By "surge" do you mean an increase in voltage? Only the other day someone used that word to mean a dip in voltage.

If it is a dip then your observed results could be a result of a Due working on 3V3 where as a Mega would work on 5V and so a Due will stand a lower dip in voltage than a Mega.

A surge in amperage could cause a decrease in voltage. Maybe that's why they got confused...

thanks to all for valuable response,

but in questions more clarity is needed as follows:

  1. i loaded right sketch and in right way by changing IDE Board/Port properties, as there is no problem in
    running sketch it runs will.
  2. SURGE means suddenly increase in voltage by spark like switching solenide volve
    in other words we can call it spike in voltage.

OK so a real surge then.

This is probably causing the Arduino to hang so you must take measures to stop this from happening. The best way is to cure it at source, that is to suppress the thing causing this voltage spike. For example if it is a mains device turning on you could fit a mains filter or snubber circuit.
If you can't do that then you have to protect the power supply on the Arduino. Where is this coming from USB or external power supply?

You can put the USB cable through a ferrite ring to dampen any interference it picks up. Some USB leads have these fitted already and can be seen as a bulge in the cable.

For an external powered unit you can put the lead through a ring or add a series inductor to the cable.

For both situations you can add extra capacitors between the 5V pin and ground. A 0.1uF ceramic in parallel with a 47uF should be your starting point. Finally you could solder these extra capacitors on the board closer to the processor's power pins.

Dear Grumpy_Mike

thanks for your clear response paying proper attention to my problem.

i understood your suggestion, but it 'll take two or more than two days to apply your solution to my project,

after checking this in my project i'll return if problem persist ,

because i am sure that this solution might work ,

so thanks a lot again

ey!

I had a very similar problem with a project where I run also arduino mega. I created this post some time ago but it got no answers.

It is very difficult to recreate the circumstances that provoque the failure, and everytime the system failed was when presenting my project somewhere away from home, so I really do not know if it is related with the electricity net, but this is my suspicion.

I appreciate if you could check the post and keep me updated if you try what grumpy mike suggest.

thanks!!

sure

dear camilozk
u have to wait

thanks for trust

hi!

any news?

Resolved : i attached extra capacitors between the 5V pin and ground. A 0.1uF ceramic in parallel with a 47uF.

it is successful. Thanks to All involved experts.

A quick question, how are the values of those capacitors determined? Would it be acceptable if we use larger values for each or either of the capacitors?

how are the values of those capacitors determined?

By the frequency response of the capacitor for high frequencies, and by the charge storage requirement for low frequencies.

Would it be acceptable if we use larger values for each or either of the capacitors?

No, you need a 0.1uF ceramic capacitor. The large value is not so critical.

Much appreciated explanation GM

thank you very much lodhi_kanwar for the update and Grumpy_Mike for the solution!

I will try it out in my setup

Dear @Grumpy_Mike, @lodhi_kanwar & community

Excuse my ignorance, but I want to be sure of what I am doing before proceeding.

For your solution "add extra capacitors between the 5V pin and ground. A 0.1uF ceramic in parallel with a 47uF", this is also valid even when the arduino is receiving its power from the usb?

Also, I saw that the 47uF capacitor has polarity. I pressume that the (-) is connected to the ground?

Does the 0.1uF ceramic capacitor have polarity as well?

thanks!

Does the 0.1uF ceramic capacitor have polarity as well?

No.

and for "this is also valid even when the arduino is receiving its power from the usb?"

this is also valid even when the arduino is receiving its power from the usb?

Supply decoupling is always a good thing to have irrespective of where the power is coming form. The source of the power has little impact on this. Have a read of this:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html