Dear All,
I hope this email finds you well. My name is Elan, and I am currently working on a project involving a 3-axis robotic arm controlled by stepper motors. I am using the STM32 microcontroller along with Keil Studio Cloud for programming, and I am leveraging the AccelStepper library to control the stepper motors.
I have encountered a couple of issues that I hope you can assist me with. Below are the details of my implementation:
Issue 1: Movement Control
I am using the following function to move the X-axis stepper motor:
void X_stepper_Move(int move, int acc) {
X_Stepper_Relay = 1;
Y_Stepper_Relay = 1;
Z_Stepper_Relay = 1;
printf("\n\n Robotic Arm XY Stepper");
X_Stepper.enableOutputs();
wait_ms(10);
X_Stepper.setAcceleration(acc);
wait_ms(10);
X_Stepper.moveTo(move);
wait_ms(10);
while(X_Stepper.distanceToGo() != 0) {
X_Stepper.run();
}
X_Stepper.stop();
}
This function generally works well, but I would like to ensure that I am using the library optimally, especially regarding the X_Stepper.run() function within the while loop. Are there any best practices or potential improvements you would suggest for this implementation?
Issue 2: Limit Switch Behavior
I also implemented a limit switch function to ensure the stepper motor stops at the desired position:
void X_stepper_Limit() {
X_Stepper_Relay = 1;
wait_ms(10);
Y_Stepper_Relay = 1;
wait_ms(10);
Z_Stepper_Relay = 1;
wait_ms(100);
printf("\n\n Robotic Arm X Stepper Limit");
X_Stepper_Limit.mode(PullDown);
wait_ms(100);
X_Stepper.setMaxSpeed(maxSpeed);
wait_ms(10);
X_Stepper.setAcceleration(1000);
X_Stepper.move(200000);
wait_ms(10);
while (X_Stepper_Limit == 0) {
X_Stepper.run();
}
wait_ms(100);
X_Stepper.setCurrentPosition(0);
wait_ms(100);
X_Stepper.stop();
printf("\n\n Robotic Arm X Stepper Limit Done ");
}
However, I am experiencing an issue where the motor sometimes exits the while loop prematurely, even when the limit switch hasn't been triggered. This results in the stepper motor not moving to the intended limit. Could you provide any insight or advice on how to address this issue?
I would greatly appreciate any guidance or recommendations you can provide to help me improve the reliability and performance of the stepper motor control in my project.
Thank you for your time and for creating such a useful library. I look forward to your response.
Best regards,
Elan.
Dear Mr. Jim,
Thank you again for your previous response, it was very helpful!
I have one more question I was hoping you could assist me with. I am using the DM542 driver to run the stepper motors in my project, and I am curious about how the AccelStepper library can be effectively utilized in conjunction with this driver. Could you provide some guidance on how to integrate the library with the DM542?
Additionally, I would like to know if the DM542 is a suitable driver for use with the AccelStepper library, or if you would recommend a different driver that might be more compatible or efficient for my application.
I would greatly appreciate your advice on this matter. Thank you once again for your help!
Best regards,
Elan
--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/accelstepper/d3175d05-270c-4c53-b612-af8eece192d4n%40googlegroups.com.
Dear Mr. Jim,
Thank you once again for your assistance so far!
I have another question regarding the usage of the AccelStepper library in my project. I am using a DM542 driver along with a 4-wire stepper motor. In the library, I noticed that 4 pins are assigned from the microcontroller for controlling the stepper motor.
Could you clarify whether these 4 pins are meant to be connected directly to the motor as inputs, or are they intended as inputs to the DM542 driver? If they are driver inputs, could you please explain how to properly handle the connection and functionality of these pins from the microcontroller to the driver?
Your guidance on this matter would be greatly appreciated, as it will help me ensure that I am wiring and configuring everything correctly.
Thank you in advance for your help!
Best regards,
Elan.
--