Hello I`am new here and i have a problem with AccelStepper library,
my problem is when i want to rotate my two stepping motor on diffrent angle for example 90 degrees
they are rotating but they are not get the perfect 90 degree, the same is with another angles they are not perfect and where is the problem ? Anyone know the way to controll two stepping motors where they are independent in speed and the rotate, move and stop for example one is rotating for 40cm and in the same time the second one for 20 cm my screw. I dont have idea how to do that ...
Arduino UNO
AMIS-30543 30V 3A SPI
stepping motor : JK57HS56
My code :
#include <SPI.h>
#include <AMIS30543.h>
#include <AccelStepper.h>
const uint8_t amisDirPin = 2;
const uint8_t amisStepPin = 3;
const uint8_t amisSlaveSelect = 4;
const uint8_t amisDirPin1 = 5;
const uint8_t amisStepPin1 = 6;
const uint8_t amisSlaveSelect1 = 7;
int stps = 0;
int stps1 = 0;
AMIS30543 stepper;
AMIS30543 stepper1;
AccelStepper accelStepper(AccelStepper::DRIVER, amisStepPin, amisDirPin);
AccelStepper accelStepper1(AccelStepper::DRIVER, amisStepPin1, amisDirPin1);
void setup()
{
SPI.begin();
stepper.init(amisSlaveSelect);
delay(1);
stepper.resetSettings();
stepper.setCurrentMilliamps(500);
stepper.setStepMode(16);
accelStepper.setMaxSpeed(2000.0);
accelStepper.setAcceleration(500.0);
stepper.enableDriver();
stepper.init(amisSlaveSelect1);
delay(1);
stepper1.resetSettings();
stepper1.setCurrentMilliamps(500);
stepper1.setStepMode(16);
accelStepper1.setMaxSpeed(2000.0);
accelStepper1.setAcceleration(500.0);
stepper1.enableDriver();
}
void rot(){
accelStepper1.moveTo(stps1);
accelStepper.moveTo(stps);
}
void calc (int angRot, int angRot2) {
int stp;
int stp1;
stp = ((200*16)*angRot)/360;
stps = stp;
stp1 = ((200*16)*angRot2)/360;
stps1 = stp1;
}
void loop()
{
calc(90,270);
rot();
accelStepper.run();
accelStepper1.run();
}