Trying to make an E-Stop to freeze the program.

Hello world,

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.

Thanks in advance.

  • Mike

If the arm had a simple lock that only opened when power went to it then loss of power would work?

Or if the arm is moved by a direct stepper it would at least be slowed by loss of power, I dunno if it would just stop using a geared stepper.

Otherwise run with a state machine and have one state detect and apply emergency stop, go into a loop until power-down or a release is triggered.

Everything I've found so far is for shutting the program down, which is not what I need.

Why not? Program stops. Servo pulses stop. Servo does what? Stops? Keeps moving? Moves to a "home" position?

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.

Thank you all for your help. It'll be a bit before I can actually test this because the hardware is in another city at the moment.

(As for the lack of a proper fail-safe, it's all right, it'll conform perfectly to Starfleet engineering standards when done.)