Abort 36V4 positioning operation

36V4 is used for 3-axis control with Arduino Mega 2560, I2C interface. I don’t want to move 3 axes at the same time, but I don’t know how to interrupt or stop it during operation. Can you tell me how to stop it by interrupt processing?

Hello.

I moved your post to the motor controllers/drivers and motors support section of the forum since this is a more appropriate place for it.

Can you post the program you are testing?

Also, can you clarify how you ultimately want to be able to stop the motor? For example, is there some switch connected to your microcontroller that should stop the motor when it is triggered, or do you want your motor to stop when you send some message to your Arduino through the Serial Monitor?

- Patrick

hello.
Thank you for always being so kind to us.
I was able to assign the “kill” function to the RC terminal of the 36V4 to interrupt and stop the 36V4 on 3 axes.Is it possible to stop it with Arduino’s serial communication?I don’t know how to do it. Can I have it?
Thanking you in advance.

StainingDevice_trigger.ino (13.0 KB)

It seems like you probably want to modify your waitForPosition functions to be based on two criteria: the position of the stepper motor and a manual override. Here is a simple example of how that might look:

void waitForPosition(int32_t targetPosition)
{
  bool keepRunningMotor = true;

  do
  {
    resetCommandTimeout();

    if (tic.getCurrentPosition() == targetPosition)  // Check if the motor reached the target position.
    {
      keepRunningMotor = false;  // Exit the loop if we have.  The motor should already be stopped.
    }

    if (Serial.available())  // Check if a serial message is available.
    {
      String message = Serial.readString();  // Read the message.
      if (message == "STOP"){  // If it says to stop.
        tic.setTargetVelocity(0);  // Command the motor to stop.
        keepRunningMotor = false;  // Exit the loop.
      }
    }
  } while (keepRunningMotor);
}

If that does not help you figure it out, could you try reducing your program down to the simplest complete program that still demonstrates the problem and post that? For example, start from one of our example programs for one motor and then add something that you think should add the functionality you want, but does not. Also, please provide a clear description of what you are expecting to happen, and what happens instead.

- Patrick