Arduino running for more than 2 years, Will it hang?

Interesting idea a 555 in astable mode then checking the Arduino's response and if nothing happens reset it, you could use an AND gate or NAND to trigger off reset...

@cjdelphi, So, didn't get your vote. Another arduion, or a 555? I vote for the watchdog software code. No and gate, nand gate, xor gate, or such needed either way.

What are the common reasons for the program to stop working? I would guess that brownout would be near the top of the list. The watchdog code will not take care of brownout will it? I believe that a 555 would be able to take care of that.

[quote author=Jack Christensen link=topic=180311.msg1337162#msg1337162 date=1375292220]

fungus: But... better to use the built-in watchdog. That's what it's for.

(PS: Anybody know it the latest bootloaders still crash on a watchdog reset? It's a bit of a problem...)

Not sure about the bootloader, but if there's any question, I'd probably use the watchdog and eliminate the bootloader. I might just do that anyway even if there wasn't a question. [/quote]

Hi! Sorry, I dont quite understand your post. To use the watchdog, do i need to program it with the six pin connector or I just can use the arduino IDE for setting the watch dog.

Thank you! Luis

I found in another website that there are external IC circuits WDT that can be purhcased instead of making your own circuit with a 555 timer. Has anybody here done the same? I found a couple of those but I have no idea how to program them. Maybe somebody could make a tutorial out of it? I am sure it would be very useful! Thanks, Luis

jackwp: What are the common reasons for the program to stop working? I would guess that brownout would be near the top of the list. The watchdog code will not take care of brownout will it? I believe that a 555 would be able to take care of that.

Guess what? AVR chips have brownout circuitry, too.

LuisArduino: [quote author=Jack Christensen link=topic=180311.msg1337162#msg1337162 date=1375292220]

fungus: But... better to use the built-in watchdog. That's what it's for.

(PS: Anybody know it the latest bootloaders still crash on a watchdog reset? It's a bit of a problem...)

Not sure about the bootloader, but if there's any question, I'd probably use the watchdog and eliminate the bootloader. I might just do that anyway even if there wasn't a question.

Hi! Sorry, I dont quite understand your post. To use the watchdog, do i need to program it with the six pin connector or I just can use the arduino IDE for setting the watch dog. [/quote]

The watchdog doesn't work with the bootloader (bugs in the bootloader!). You have to eliminate the bootloader and that means programming via. the six pin connector.

fungus:
The watchdog doesn’t work with the bootloader (bugs in the bootloader!). You have to eliminate the bootloader and that means programming via. the six pin connector.

I always thought this was just a problem with older bootloaders.
Apart from the suggested use of watchdog timer and brownout protection another potential problem with long running projects is dried out electrolytic capacitors. Probably 30-50% of the stuff I have to fix is due to dry caps.

Hi Fungus,

Sorry for the silly questions…
So, what you are saying is even if I include in the start of the arduino sketch:

#include <avr/awd/h>
wdt_enable(WDTO_2S);

it wouldnt work the watch dog timer?

thank you again,

Luis

LuisArduino:
Hi Fungus,

Sorry for the silly questions…
So, what you are saying is even if I include in the start of the arduino sketch:

#include <avr/awd/h>
wdt_enable(WDTO_2S);

it wouldnt work the watch dog timer?

It will work…once. The bootloader doesn’t know how to respond to a watchdog reset and will crash. You need to get rid of the bootloader.

Question... if "hung" it's not going to respond to an interrupt is it?...

use the 555 in monostable/one shot mode.

So the 555 fires off, you read the high signal (digitalRead();), and then you send a pin High/Low to reset the 555 chip, firing again in X amount of minutes, let's have the ON time around 10 seconds before it dies, maybe 30 seconds.... that on time could be sent to a transistor to charge a capacitor (because of how long the signal was high) and if the cap charges to a level to indicate the Arduino has NOT responded to your knock knock (eg, sending signal high but not sending the 555 back to reset) the transistor fires off having it pull in the ground rail to the Arduino's reset pin, at the same time, discharging it's own capacitor and prepairing to fire off again in another 30 minutes.

you could use a couple of npn's and a pnp with the 555 to do the job, the one thing you could rely on is the fact no matter what happens the 555 (if done correctly) will only fail when the capacitor or power supply fails, due to the little heat generated there's really little that could go wrong, software on the otherhand can still fail...

how about a 555 wired to fire ever 10 seconds ?

If the 555 gets a reset signal, it starts its 10 second count over.

The arduino sends a signal faster than 10 seconds to the reset pin of the 555 (such as from pin 13 ever second).

If the power is off for a while, as soon as it comes back on, the 555 will start, sending a reset to the arduion in 10 seconds.

The latest Optiboot and stk500v2 included in IDE 1.0.5 does correctly disable the WDT during bootup. I’ve tested it with an Uno R3 and Mega2560 R3.

You can try this test code (I got it from somewhere in this forum). With the latest bootloaders it should enter a reset after about 6 loops. If the bootloader does not correctly disable the WDT then it will get stuck in the bootloader after the first iteration.
(WARNING: if you do have an old bootloader you will have trouble uploading sketches again. A quick fix will be to keep the reset button pressed while you insert the USB and don’t release it until you try uploading another sketch (like Blink).)

#include <avr/wdt.h>

byte LED = 13;
boolean LEDon = true;
int i = 0;

void setup ()
{
  Serial.begin (9600);
  pinMode (LED, OUTPUT);
  
  Serial.println ("Restarted.");
  wdt_enable (WDTO_2S);  // reset after one second, if no "pat the dog" received
 }  // end of setup

void loop ()
{
  Serial.println ("Entered loop ...");
  //wdt_reset ();  // give me another second to do stuff (pat the dog)
  while (true)    // oops, went into a loop
  {
    wdt_reset ();  // give me another second to do stuff (pat the dog)
    Serial.println("Inside loop ...");
    LEDon = !LEDon;
    digitalWrite (LED, LEDon); 
    delay(1000);
    if (i++ > 4) {
      delay(2000);
    }
  }
}  // end of loop

If your bootloader correctly supports WDT then it should keep repeating this output on Serial Monitor.

Restarted.
Entered loop ...
Inside loop ...
Inside loop ...
Inside loop ...
Inside loop ...
Inside loop ...
Inside loop ...
Restarted.
Entered loop ...
Inside loop ...
Inside loop ...
Inside loop ...
Inside loop ...
Inside loop ...
Inside loop ...

Hi, Thank you for this code. How do I know if my arduino has the right bootloader? Thanks, Luis

If you run for 2 years, there is a chance you will have power interruptions, causing a brownout problem. The watchdog software will not help a lockup caused by brownout. The cpu is able to restart after a brownout, but the code in the bootloader normally disables that ability.

jackwp: If you run for 2 years, there is a chance you will have power interruptions, causing a brownout problem. The watchdog software will not help a lockup caused by brownout. The cpu is able to restart after a brownout, but the code in the bootloader normally disables that ability.

Hi Jackwp, Thanks for your message. So what are you saying is that even with the right bootloader, still the arduino can hang in 2 years? But with an external reset, it should be fine, right?

Thanks, Luis

Yes.

jackwp: how about a 555 wired to fire ever 10 seconds ?

If the 555 gets a reset signal, it starts its 10 second count over.

The arduino sends a signal faster than 10 seconds to the reset pin of the 555 (such as from pin 13 ever second).

If the power is off for a while, as soon as it comes back on, the 555 will start, sending a reset to the arduion in 10 seconds.

I think a potential problem with this is that if the MCU hangs at a point when it is holding the 555 reset low, the whole arrangement is defeated.

I am not that sharp on the 555, but I think there is no need to hold the reset low, just send a pulse (maybe 1ms), to reset it. I could be wrong. Any 555 experts on here?

jackwp: If you run for 2 years, there is a chance you will have power interruptions, causing a brownout problem. The watchdog software will not help a lockup caused by brownout. The cpu is able to restart after a brownout, but the code in the bootloader normally disables that ability.

Yes, the bootloader will disable the WDT so that it can it's self run, but as soon as the sketch starts it should re-enable the WDT. So I am not following what you are saying. Am I missing something?