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.
I don't understand "SURGE ENVIRONMENT"
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.
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.
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.
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?
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?
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