Pages: [1] 2   Go Down
Author Topic: Reliability? Error handling? Soft reset?  (Read 2418 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have just started to learn the Arduino Uno for a possible robot lawnmower project (yes another one!) and I was wondering how reliable the Arduino is.  I don't want the mower to take off unexpectedly due to a program 'lockup'.  Is it just as reliable as Windows (ha ha)?  Are there error handling examples anywhere such as the old Basic "On Error Resume Next"?  Can I programatically push the reset button if the program gets stuck with a detectable error?  I have only been playing with it for a few days and already it has locked up a few times and I don't know why.  Sometimes the serial port doesn't work and the Tools/Serial Port menu item gets grayed out.  I close and reload Arduino.exe and then COM port seems to work again.  Don't know why.  I'm using Win XP.  Thanks.
« Last Edit: August 25, 2012, 08:02:31 pm by warren631 » Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4095
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduinos are very reliable. I'm sure that at least 99.44% of program "lock ups" and other issues are caused by code. Haven't tried it myself, but it sounds like the best way to programmatically push the reset button is to configure the watchdog timer to cause a reset and then set it for some fairly short time interval, and wait for it to expire. After the reset, the first thing the code must do is to reconfigure the watchdog so a reset loop doesn't occur.

As for the IDE issues, the only time I've had what may be similar problems is when I had bad code flooding the serial monitor with more than it could enjoy.

If it were me, I'd get very familiar with the watchdog (see the ATmega328P datasheet) or even consider a separate external watchdog, which has its advantages. Sounds like you may have already searched the forum, but you'll find lots of cautionary discussion on such projects for the reasons you mention. Bottom line for any such project, the code has to be exceedingly solid. If it's relying on the watchdog, then more work is needed. Of course it's a great idea to have the watchdog active even if the code hasn't needed it yet...

(Reminds me of a joke: There are two kinds of boaters, those that have launched their boat without the drain plugs in, and those who haven't done it yet...)
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

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

Is it just as reliable as Windows (ha ha)?  

More reliable. smiley-wink

However nothing saves a processor from programming errors. Maybe post your code.
Logged

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

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

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

Interesting question!

I tried googling "Arduino MTBF", didn't find very much, except reference to the lives of the LED's. Maybe it means that very few Arduino's are failing yet? I hope so.

Arduinos first came to life around 2005, so if the oldest of them have been running 24/7/365, they'll now have clocked up about 50,000 hours.

If we set the programming problems aside, what comes next? I don't know, but would be guessing at the following being the major causes for failure:

   > Environmental conditions - too hot, too cold, moisture, vibration, mechanical damage, contact corosion, strong magnetic fields etc.
   > Unregulated power supply - spikes, variations outside what's recommended.
   > Problems caused by peripherals - spikes from any input devices, shorts or spikes on output devices.

To ensure a long lifetime, address these, and you're probably well down the road.

Ian (human - MTBF of 500,000 hrs  smiley-lol )
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4095
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ian (human - MTBF of 500,000 hrs  smiley-lol )

LOL!  smiley-lol
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 130
Posts: 8622
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
"On Error Resume Next"
There is no built-in error trapping like that with Arduino, you can of course implement your own system.

That said I never use C++, maybe try/catch is implemented although I've never seen it mentioned here.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 654
Posts: 50931
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
maybe try/catch is implemented although I've never seen it mentioned here.
Because try/catch is not implement. Exception handling requires a fair amount of memory for a fairly large stack. The Arduino doesn't have enough memory.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino is as reliable as the program you write for it.

Unlike a computer there is no operating system between your program and the hardware.  In an environment like a PC you are not programming the PC, you are programming the operating system.  The operating system then translates your code's function calls into actual hardware access via the use of device drivers and such.  These extra layers of complexity all add extra layers of unreliability to the system.  If any one layer has a fault, it will affect all the layers above it, and the more layers you have the more chance there is of something breaking.

As I say, with an Arduino (and any other "bare metal" microcontroller) you don't have any of these layers.  There is just your code, a few pre-written libraries, and the chip.  If anything goes wrong, then it is either a hardware fault (rare), something wrong with one of the pre-written libraries (not common), or something you have written wrong in your program (very very common).

Most hardware faults are actually caused by incorrect interfacing to external devices, such as connecting devices that draw too much current, or forgetting to add snubbing circuits to inductive loads, etc., so at the end of the day they are as much user error as a fault in the program.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

IDF/SO
Offline Offline
Edison Member
*
Karma: 41
Posts: 2312
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For the reliability have a look at :
http://www.smartprj.com/catalog/index.php?main_page=warranties&zenid=ou9ictuiuos5a0kuahjm96lth1

Smart project is the Italian manufacturer arduino boards.

Notice especialy :
1.5 UNAUTHORIZED USE.
smartprojects products are not authorized for use in safety-critical applications where a failure of the smartprojects product would reasonably be expected to cause severe personal injury or death"
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your input guys.  I don't want to fool around with the internal watchdog timer since I might screw up the firmware and damage my Uno.  I think I will use an external watchdog time delay relay controlled by an Arduino output which is pulsed every loop of the program.  If it doesn't get pulsed then it times out and removes power to the mower.

Reading other posts it seems best to stay away from using serial in the Arduino if you want reliability.  Here is my very simple sketch that locks up randomly if I un-rem the serial statements (its just a minor rev to the knob example to make the servo cycle by itself). It has run 24 hours now without a lockup since I removed the serial statements (maybe I don't need a watchdog after all):
Code:
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
 
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin
int x = 0;

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
 // Serial.begin(9600);
  delay(5000);                           // waits for the servo to get there

}
void loop()
{
 
  val = x * 511;
  
//  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 20, 160);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value

  x = x + 1;

  if (x >2)
 {
     x = 0;
 }
 //  Serial.println(val);

   delay(1000);                           // waits for the servo to get there
}
« Last Edit: August 26, 2012, 12:44:34 pm by warren631 » Logged

Earth (I think)
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've used the AVR watchdog with no problems whatsoever. It's a good idea if a program lock-up could cause some sort of problem (in my case, disabling my security system). I've never had any problems with Serial.print(), but if it uses Strings (idk if it does) that could cause some problems, as Strings may leak memory. It's generally a good idea to use char arrays instead. I've had my Arduino running all night with no problems, but it might have reset itself via watchdog when I was asleep at the other end of the house.
Logged


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

That watchdog is supposed to save you, not cause problems. There is no reason the watchdog would screw up the firmware or damage the Uno.

I don't see why, on the face of it, the serial prints in your sketch would lock up the processor. Maybe it's a hardware thing. You haven't posted many details.
Logged

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

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

Offline Offline
Full Member
***
Karma: 1
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I un-rem'ed the serial statements again because I want to know what is going on in the program and it locked up again like before.  I then set the transmit and receive buffers for the COM port on my PC to minimum.  That seemed to do it - it works without locking up now.  The port is set to 9600,8,N,1 with no row control.  Is that correct?  Shouldn't I use parity?  Wouldn't parity be more reliable?

Anyway, so it seems to work now with the serial statements in the program enabled.  So I powered down and plugged in a sensor shield from WWW.GE-TH.COM (had to bend the pins a little to make it fit), plugged in my servo, and powered up.  It now runs for about 60 seconds then freezes.  I reset and it runs again for 60 seconds.  I didn't change the program.  Only one servo is plugged in - nothing else.  I'm using the 9V power supply because I thought maybe I was loading down my Acer USB port.  I then removed the sensor board and tried the program again and it works just fine.  But I want to use the sensor shield in my project.  Bad sensor shield?  I removed the two jumpers in the shield but it still froze after 60 seconds with the shield.  

This is frustrating.  Any suggestions?

When I download I sometimes get this message:
Binary sketch size: 4,562 bytes (of a 32,256 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x00

Sometimes I get this message:
avrdude: ser_send(): write error: sorry no info avail

Sometimes it takes a long time to download.

Is it anything to do with trying to download while the program is running and talking on the serial port at the same time?  How do I stop the program until I have fully downloaded and then re-start it?  Sometimes when I try to download it says "COM port already in use" - of course it is, the program that is running in the UNO is using it!  Is there any way to stop the program and clear memory before downloading a new program?

Also: the on-board LED at pin 13 is always on.  My program does not do anything with this LED.  Maybe a previous program left it on.

Thanks, Warren.
« Last Edit: August 27, 2012, 09:22:25 pm by warren631 » Logged

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are saying your code doesn't work without saying what the code is.

"COM port already in use" means a program on your PC is using the COM port, not that that arduino is.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 654
Posts: 50931
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So I powered down and plugged in a sensor shield from WWW.GE-TH.COM
I refuse to guess which sensor shield that might be.

Quote
had to bend the pins a little to make it fit
Should have sent it back, instead.

Logged

Pages: [1] 2   Go Up
Jump to: