Pages: [1]   Go Down
Author Topic: Problems with Arduino running for a long time (Months).  (Read 1223 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19340
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley
Logged

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5744
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 48
Posts: 2935
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

--> 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

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Two ideas:

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

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.
Logged

NSW Australia
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3716
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1730
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

~Tom~

Offline Offline
God Member
*****
Karma: 17
Posts: 522
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 
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:
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.
Logged

Offline Offline
God Member
*****
Karma: 17
Posts: 522
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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;
}
Logged

Offline Offline
God Member
*****
Karma: 17
Posts: 522
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19340
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19340
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Pages: [1]   Go Up
Jump to: