I'm working on a project to make a CD jukebox with a servo-controlled arm and an Arduino Mega 2560. One of the requirements is an emergency stop that will freeze everything in place until reset.
I know about the external interrupts and how to introduce them into the program. My problem is figuring out how to have everything freeze in place when the E-stop is pressed. The idea is that if there is an emergency, we don't want to have power shut off and risk the arm falling, and we don't want anything to keep (or start) moving.
Any suggestions and/or possible places to look? Everything I've found so far is for shutting the program down, which is not what I need.
The servos are controlling the position of a robotic arm. If the servo pulses stop when the arm is extended horizontally, then gravity will pull the arm down. That's why what I need is an emergency stop, as opposed to an emergency reset or emergency power-off.
The purpose is to mimic what would happen in a larger environment, perhaps a factory. If someone was spotted walking in a no-go zone under an automated crane, and the emergency stop was pushed, we don't want the crane to lose power and fall on the person, we want it to stay where it is.
Pariah-Ink:
The purpose is to mimic what would happen in a larger environment, perhaps a factory.
Not in any factory where I worked. Your design does not "fail safe".
If someone was spotted walking in a no-go zone under an automated crane, and the emergency stop was pushed, we don't want the crane to lose power and fall on the person, we want it to stay where it is.
I could be mistaken but I believe a crane would employ a worm gear which would prevent things from accidentally falling.
This should do what you want...
void PariahInkEStop( void )
{
interrupts();
while ( true );
}
void setup( void )
{
attachInterrupt( 0, PariahInkEStop, LOW );
// Configure the Servo
}
void loop( void )
{
// Do something with the Servo
}
Bearing in mind that, because of the travel time of a servo, you've created an impossible constraint.