Go Down

Topic: Problems with Arduino running for a long time (Months). (Read 1 time) previous topic - next topic

captainhooyah

Does anyone know of any problems that might arise from an Arduino running for months or years without being turned off or reset?  

I had one freeze up on me and it could be that my program is borderline too big for the memory, or that software serial is taxing the UNO with all the additional code running... even though others with the identical programming and setup are fine.

I just made an auto reset for the device that throws a relay and interrupts power every 24 hours, but, I was just curious if people in the forum are aware of problems that could occur with an Arduino running non-stop for extended periods of time.

How junior varsity is my solution? Would interrupting the power to the Arduino for a second and reapplying power have any adverse effects on the Arduino over time?


retrolefty

A properly programmed and wired up arduino project should have no problem running continuously, nor should power down/up prevent reliable continuous operation. A problem is this area could be either your programming or with your wiring/external components. Further help requires posting your code and schematic drawing.

I have a 7x7x7 LED cube running on my desk for at least a couple of years with no problem except an occasional house power failure or I unplug it in error, but it always starts back up reliable when power is returned.

Lefty

Nick Gammon

I have my RFID security system system running 24/7. It only froze once, and that was after a power brownout. It has been going, other than that, for two years. I didn't specifically have code for detecting brownouts (I'm not sure what the brownout fuse was set to). And, possibly, the problem was with the RFID reader module and not the Arduino itself.

The nature of life here is that mains power fails from time to time, so it is hard to say for sure how long it would run without those failures. Certainly it usually recovers (like I said, except that one time).

It probably wouldn't be too hard to make a watchdog circuit out of a 555 timer or similar. The idea would be that if you don't bring a digital line low (or high) from time to time the timer resets the processor. Of course, the processor might fail in such a way that the watchdog thought things were OK.

I suppose if I was really worried I would have a second processor there, simply designed to listen for a fairly complex sequence (eg. from the serial port) and if it didn't get it every minute, reset the main processor.

But then, if a brownout can knock out the main processor, it might knock out the monitoring processor too. Maybe the monitoring processor needs to run off batteries. :)
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

fungus


Does anyone know of any problems that might arise from an Arduino running for months or years without being turned off or reset? 


There's no reason for it.


others with the identical programming and setup are fine.


In that case, suspect the power supply.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Docedison

I've been an tecnician/engineer all my working life... and what you are describing is a defective component or a bad solder joint and if a close visual inspection doesn't turn up a bad solder joint my recommendation would be to replace the board. Static electrical damage to the processor can be extremely difficult to find but the failure symptoms are identical. This was really common when CMOS IC's were first used commercially and still is If CMOS IC's aren't handled properly.
Putting a crutch on the board (power down reset circuit) is fine If you think it's your code.... Im my experience code failures are regular and repeatable.. when the failure conditions are met the code fails to operate as expected. Much better to replace the processor or the whole board.

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

SirNickity

Two ideas:

First, don't use mechanical means for a reset.  There's a watchdog timer built in to the MCU.  Use it.  :)

Second, if you suspect hardware, write the simplest possible sketch that provides some outside signal that it's still going, and run it continuously.  If that never freezes, your problem is software.  Narrow your problem domain.

Paul__B

Many of us have computers - PCs - running for years without failure - on Linux needless to say.  Now they are way more complex than an Arduino.

Tom Carpenter

This might seem like a daft question, but are you using millis()? That resets overflows after a month or so of continuous running.
~Tom~

joshuabardwell

Depending on what you are doing, I believe that it's possible to fragment the Arduino's memory to the point that it hangs because of failure to allocate. More on that topic: http://learn.adafruit.com/memories-of-an-arduino/optimizing-sram

captainhooyah


Thanks everyone. 

The use of millis has to be my problem now that I think of it, I just think I'm lucky that the others aren't having the same problem.

Code: [Select]

if (millis() - currentMillis) >= interval)
{
execute code
currentMillis = millis()
}



If current millis was reset right before the millis reached their maximum and reset to zero, it sounds like I will have to wait another month or two before the if statement is satisfied.

Dangit! That's a little embarrassing... Looks like I'll need to use a different timer method for something that stays on for extended periods of time.  For now my mechanical reset will take care of the problem while I look into a watchdog timer, and other options.

Thanks again guys, and if you have a link to anything you think I should read up on, I'm always grateful for advice.

joshuabardwell

I believe that you can change the timer divisor to increase the amount of real-time before millis rolls over. The millis() function will no longer correctly count milliseconds, but this can be compensated for in software--e.g. by creating your own myMillis() function, which returns system millis() divided by the appropriate factor to cancel out your change to the system timer.

The default prescaler for timer0 (used for millis and delay functions) is 64, but it can be increased to 1024. This will increase by 16x the length of time until millis rolls over. If you need to use millis() for absolute time measurements, just divide the value you need by 16 to get back to true milliseconds--e.g. to delay 1 second, instead of calling delay(1000), you call delay(62) because 1000 / 16 = 62.

Another thing you can do is increase the max size of the time counter by adding your own rollover register. In other words:

Code: [Select]

const unsigned long maxUnsignedLong = 0 - 1; // should roll backwards and set to the max possible value
const unsigned long rolloverWindow = maxUnsignedLong / 20; // 5%
boolean didRollover = false;
unsigned long millisRolloverRegister = 0;

void setup {
}

void loop() {
  currentMillis = millis()

  // Rollover is impending! Increase rollover register.
  if ((currentMillis > maxUnsignedLong - rolloverWindow) && !didRollover) {
    millisRolloverRegister++;
    didRollover = true;
  }

  // Rollover has occurred. Clear the rollover flag to prepare for next rollover.
  if (didRollover && currentMillis < rolloverWindow)
    didRollover = false;
}

joshuabardwell

You should bear in mind that my code example above is incomplete. For example, it will update the rollover register before the rollover has actually occurred, so if you were to try to determine elapsed time during that window, you would be off by one rollover time-length. You could maybe do something like setting a flag when the rollover was impending and then only updating the rollover register after the update has occurred. This would have the same problem, but the other direction. So these are issues you would have to work out, but you get the idea.

Nick Gammon


The use of millis has to be my problem now that I think of it, I just think I'm lucky that the others aren't having the same problem.
...
If current millis was reset right before the millis reached their maximum and reset to zero, it sounds like I will have to wait another month or two before the if statement is satisfied.


Why?

http://www.gammon.com.au/millis

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon


I believe that you can change the timer divisor to increase the amount of real-time before millis rolls over.


millis() rollover is not an issue. See my link above.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up