Go Down

Topic: Resets during loop running (Read 641 times) previous topic - next topic

Davemc89

Feb 07, 2018, 10:22 pm Last Edit: Feb 07, 2018, 10:28 pm by Davemc89
while running my code (attached) my master mega randomly resets, i'm utilizing 24 of the digital i/o's as can be seen from the code, could this be causing too much current drain and therefor the mega to reset?

My project is using one mega to remotely control a second to move 4 actuators in and out using relays as the actuator controls and to send the actuator selection signals and LED actuator position indicator feedback.

any input appreciated

PaulRB

Yes, it could be causing the resets. And be damaging the Arduino.

Have you heard of "current limiting series resistors"?

Grumpy_Mike

#2
Feb 08, 2018, 02:49 pm Last Edit: Feb 08, 2018, 02:51 pm by Grumpy_Mike
That code is truly horrendous why is this line
Code: [Select]
const int Relay1 = 52;
And many others repeated three times?
Learn about arrays and loops to reduce the length of code drastically.

Face it, the code you posted will not even compile, so it is not the code you are running.

Quote
My project is using one mega to remotely control a second
Nearly always a bad move to have two processors.


Quote
i'm utilizing 24 of the digital i/o's as can be seen from the code, could this be causing too much current drain and therefor the mega to reset?
Who knows because we have no idea about how you have wired up your project, only you know that and so far you are keeping it a secret.

Davemc89

Pretty sure the code is compiling if it's loading to the board and doing what it's supposed to do just with the random resets.

The const int's are used as that's what the guides on the arduino website say to use when designating the pin.

Do I need to use a current limiting series resistor if I'm using the internal pull up resistors?

Grumpy_Mike

#4
Feb 09, 2018, 12:01 am Last Edit: Feb 09, 2018, 12:02 am by Grumpy_Mike
Quote
Pretty sure the code is compiling if it's loading to the board and doing what it's supposed to do just with the random resets.
Your code might be but what you posted is not.

Quote
The const int's are used as that's what the guides on the arduino website say to use when designating the pin.
Sure but you can only do this once, if you do it again you get an error message.

Quote
Do I need to use a current limiting series resistor if I'm using the internal pull up resistors?
No.

Has that file got more than one program in it? If so it is not the most sensible thing to do, especially when you do not tell anyone where the breaks are.

PaulRB

Quote
Do I need to use a current limiting series resistor if I'm using the internal pull up resistors?
It depends how you are connecting the leds. Normally the built-in pull-up resistors are too high for powering LEDs.

Davemc89

Ah yeah, the LEDs each have a 220R resistor in series with them.

PaulRB

And you have 24 LEDs connected, right? Assuming they are red with a forward voltage of about 2V, each led will draw around 13~14mA. That's almost 330mA in total. The maximum that the Mega's chip can supply is 400mA. So you are already close to the limit. What else is connected? You could easily be exceeding the 400mA maximum.

Wawa

The maximum that the Mega's chip can supply is 400mA.
Yes, that's max chip current, if spread right across ports.

But there is also a max 5volt regulator current, which can be a lot lower than that 400mA. Depending on how you power a Mega.
With e.g. 12volt on the DC socket, there is a ~150mA limit you can draw from the 5volt pin before the regulator shuts down.
Leo..

Davemc89

No only 8 LEDs, 4 red 4 green, then 16 of the i/o are switch inputs, 8 are relay outputs taking the relay pins to ground on arduino compatable 5v relay modules

PaulRB

#10
Feb 09, 2018, 11:29 pm Last Edit: Feb 09, 2018, 11:30 pm by PaulRB
Ok, so 8 LEDs will be much less current, and inputs use almost no current. The relay modules will have driver transistors and should only take a few mA each (if the transistors are bjt, even less if they are fet). So this should not be the problem.

So what about power supply? How are you powering the circuit? What is connected to the relays. Give us the voltage and current requirements/capabilities for everything.

Wawa

We need to see a diagram, and pictures of the setup.
With parts values/links and supply voltage/currents.

No kickback diodes across actuators could reset the Mega.
And maybe other things you haven't considered.
Leo..

Davemc89

Sorry been a busy couple of weeks. I've changed all the pin dedication lines to arrays, seems to run a bit smoother, here's a rubbish image of the setup, the aim is that I'm going to have the two Mega's 25m apart and use the one on the left as the master and the right as the slave operating the actuators and sending the position back to the master (Just max and min not each value in between)

Just on my phone at the moment so will upload a schematic doc when I get on laptop

Go Up