Stop all actions if radio failed
CJ Cassarino last edited by
Anyway to stop the Arduino from doing anything when the radio fails? I am using an actuator and the problem is if radio fails whatever command was sent to the actuator will continue. This is a problem as I have set a value for it to stop, if it doesn't stop it will break my window or the actuator. But when the radio fails it stops running the code, is there a way to stop the Arduino or just send a stop command to my relay when the radio fails?
Doing what you want requires to predict what will fail - which is extremely hard. Does the radio fail because of a software bug? If so, if it was possible to predict the bug and handle that case, it would be easier to fix the bug. Does the radio fail because the power supply is insufficient? if so, the Arduino might be running outside the specifications as well. And when something is run outside the specifications, the result is, well, unspecified...
Sure, NASA does a pretty good job, but their electronics costs millions and their software development costs more.
However, there are some things that can be done.
- Make sure you have selected actuators that behave the "right way" when unpowered. For a water valve, this means normally closed (if the failsafe thing to do is to stop the flow) or normally open (if the safe thing is to keep the flow going). For your motor the safe thing is probably to stop the motor, which will happen automatically if power is lost so this case isn't as applicable to your situation.
- have pull-ups or pull-downs on the io pins, so the actuator returns to the "correct" state if the Arduino stops driving its outputs
- In setup(), make sure you initialize all output to safe values in case the Arduino is reset for whatever reason.
- use the watchdog functionality of the Arduino. The internet has lots of resources on how to do this. A good start might be http://playground.arduino.cc/Main/ArduinoReset
- External watchdogs might be a solution as well - something that resets the Arduino if it doesn't receive a pulse every second or something like that
For your specific case, I would look at power problems. Are you using a reliable power source? Do you have the recommended decoupling capacitors in place? If you get rid of the root problem, you might not need to add any additional safety features.
You could also create a hardware solution that automatically stops the relay when the actuator hits an endpoint.