Hi there!
I'm building a system that uses three stepper motors to drive different timing belts and pulleys. I want to be able to control the three directions with my keyboard to test out the system (ie. Up/Down: 'W'/'Z' and Left/Right: 'A'/'D', etc.)
I've managed to get everything working using the AccelStepper library (the normal stepper library was too jerky), but the steppers are either too slow, or too jerky whenever I change the pulses/rev settings on the drivers.
I am using Nema Stepper motors (23HS33-4008D) with Microstep Drivers (ST6600), and am using Tera Term for continuous serial input. The relevant code for one of the steppers is below.
Is there a way to smoothen out the motion of the motors in this way? The system has a cutting application so needs to be relatively accurate, hence the high number of pulses.
Thank you for any help!!
#include <AccelStepper.h>
AccelStepper stepper1(AccelStepper::DRIVER, 8, 9); //Pulse 9; direction 8
int val; //serial input value
int pos_motor1 = 0; //initial position of stepper motor
int motor1_steps = 500; //steps per input
void setup()
{
Serial.begin(9600);
stepper1.setMaxSpeed(1000);
stepper1.setAcceleration(100);
}
void loop()
{
if (Serial.available()) // if serial value is available
{
val = Serial.read();
if (val == 'w' || val == 'W')
{
pos_motor1 += motor1_steps; //increase motor position by motor1_steps
stepper1.moveTo(pos_motor1); //move to pos_motor1 position
stepper1.run(); //run motor
}
else if (val == 'z' || val == 'Z')
{
pos_motor1 -= motor1_steps;
stepper1.moveTo(pos_motor1);
stepper1.run();
}
}
}