Arduino Mega Resets Randomly During Operation

Hi, @askchemicals
As pointed out in the last three posts, you connect your 5V supply to the 5V pin of the Mega.
Vin is the input to the onboard 5V regualtor, it is a linear regulator and needs more that 7V input to provide a 5V regulated output.
It is safe to connect 5V power to the 5V pin.

Tom... :smiley: :+1: :coffee: :australia:

@askchemicals So, have you tested this?

All,

Thank you very much for your responses, I am just getting back to work now and will test this ASAP. I will get that 5v supply tested and hooked up to the 5v pin. I had not thought whatsoever that the vin pin would have been dropping it but that makes a lot of sense. As for the diode on the solenoid, they do not have them, could you explain/post a diagram of how to implement them onto those please? Do they just go in series with the gnd circuit off of them? I will update you all as soon as I get a minute to test everything.

Thanks again!

Hi,
This may help, the diode is in parallel with the solenoid coil, note the polarity of the diode.

Tom.. :smiley: :+1: :coffee: :australia:

That's perfect, thank you!

I tested it with the 5v power supply on the 5v pin rather than the vin pin and the problem seems a lot better. It still does it but it seems far more stable. I tested the power draw on the power supply and it is not hitting 3a like you said it might require so I am going to use my bench power supply to power it and see if it makes any difference. I have a few 12v to 5v buck converters laying around that would supply 20a, do you think one of these would work better?

Could another solution be to use 12v on the vin port and connect grounds between the 5v and 12v power supply?

Although theoretically you can put 12v on vin, in practice the 7805 overheats with 7v across it. Use 5v on the +5 pin. As I said originally anything with a coil needs anti kickback diodes mounted as close as possible to prevent inductive kicks on the power & gnd leads. Multiple solenoids will cause glitches on the 12v line as well. a couple of hundred mF near the coil power lines may help reduce spikes. Scope your power feeds during switching events.

Tom and to all who have helped,

Thank you everyone! I have learned a lot on this forum. I appreciate everyone's help with this issue. My final solution that ended up working was to put the diodes on the solenoid coils. As soon as I did this, it fixed the issue completely.

Thanks again!