Hello everyone,
I'm working on a camera slider. A stepper motor translate the camera, and rotates it with another stepper motor in order to track an object with its coordinate known.
The linear movement is generated with a stepper motor NEMA 17 and a A4988 driver. The rotation is generated with a 28byj-48 stepper and its dedicated driver.
The problem is that the movement is jerky because each motor move one step at the time. At each steps of the NEMA 17, I calculate the angle .
Is there a way to let the NEMA 17 running while in the same time calculate the angle and tell the other motor to move without stopping the NEMA 17 ?
Thank you , I hope I am clear enough !
Here's the function that makes the camera moves
void runandtrack(){
motorSpeed = 5;
double diff_angle = ((atan2 (dist_y_obj, dist_x_obj) - angle));
double step_rot = diff_angle * resolution_rot;
if (diff_angle >= ( (2 * PI) / stepsPerRevolution2 ))
{
angle = atan2 (dist_y_obj, dist_x_obj);
for (int i = 0; i < step_rot; i ++){
clockwise();
}
}
digitalWrite(dirPin,LOW);
digitalWrite(stepPin, HIGH);
delayMicroseconds(map(speed_x, 0, 100,4000,300));
digitalWrite(stepPin, LOW);
delayMicroseconds(map(speed_x, 0, 100,4000,300));
dist_x_obj = dist_x_obj - resolution_x;
pas_x = pas_x +1 ;
}