Controlling 4 steppers
hi!
i have project: omniwheel 4wd car stepper motors. use library ah_easydriver controlling steppers. want control motors 3 parameters: x axis speed (xm), y axis speed (ym) , rotating speed (fi).
in code, every motor individually controlled. same speed on wheels if input more 1 parameter. advice?
i have project: omniwheel 4wd car stepper motors. use library ah_easydriver controlling steppers. want control motors 3 parameters: x axis speed (xm), y axis speed (ym) , rotating speed (fi).
code: [select]
#include <ah_easydriver.h>
#include <math.h>
// ah_easydriver(int res, int dir, int step, int ms1, int ms2, int slp);
ah_easydriver stepper1(200,2,3,4,5,6);
ah_easydriver stepper3(200,7,8,9,10,11);
ah_easydriver stepper2(200,22,23,24,25,26);
ah_easydriver stepper4(200,27,28,29,30,31);
void setup()
{
serial.begin(57600);
serial.println(stepper1.getversion());
stepper1.setmicrostepping(0); // 0 -> full stepping 1 -> 1/2 stepping 2 -> 1/4 stepping 3 -> 1/8 stepping
serial.println(stepper2.getversion());
stepper2.setmicrostepping(0);
serial.println(stepper3.getversion());
stepper3.setmicrostepping(0);
serial.println(stepper4.getversion());
stepper4.setmicrostepping(0);
}
void loop()
{
//speed calculating
float pi= 3.1416;
float xm= 15.0; //speed x smer
float ym= 0.0; //speed y smer
float fi= 0.0; //rotating
int koraki = 200; //number of steps 1 rpm
float r = 0.029; //wheel radius
float l = 0.09; //width
float d = 0.09; //length
float obseg= 2*r*pi;
float v1= (xm - ym - (l+d)*fi)/sqrt(2); //1 motor speed
float v2= (xm + ym - (l+d)*fi)/sqrt(2); //2 motor speed
float v3= (xm - ym + (l+d)*fi)/sqrt(2); //3 motor
float v4= (xm + ym + (l+d)*fi)/sqrt(2); //4 motor
float obrati1 = v1 / obseg; //obrati prvega kolesa
float obrati2 = v2 / obseg; //obrati drugega kolesa
float obrati3 = v3 / obseg; //obrati tretjega kolesa
float obrati4 = v4 / obseg; //obrati četrtega kolesa
serial.print(obrati1,4);
serial.print("\t");
serial.print(obrati2,4);
serial.print("\t");
serial.print(obrati3,4);
serial.print("\t");
serial.print(obrati4,4);
serial.print("\n");
if(xm==0.0 && ym==0.0 && fi==0.0)
{
stepper1.sleepon();
stepper2.sleepon();
stepper3.sleepon();
stepper4.sleepon();
}
else if(xm != 0.0 || ym!=0.0 ||fi!=0.0)
{
stepper1.sleepoff();
stepper2.sleepoff();
stepper3.sleepoff();
stepper4.sleepoff();
}
//motor1
if(obrati1<0)
{
stepper1.move(forward);
}
else if (obrati1>0)
{
stepper1.move(-forward);
}
stepper1.setspeedrpm(obrati1); // rpm
///motor2
if(obrati2<0)
{
stepper2.move(forward);
}
else if (obrati2>0)
{
stepper2.move(-forward);
}
stepper2.setspeedrpm(obrati2); // rpm
//motor3
if(obrati3<0)
{
stepper3.move(-forward);
}
else if (obrati3>0)
{
stepper3.move(forward);
}
stepper3.setspeedrpm(obrati3); // rpm
//motor4
if(obrati4<0)
{
stepper4.move(-forward);
}
else if (obrati4>0)
{
stepper4.move(forward);
}
stepper4.setspeedrpm(obrati4); // rpm
}
in code, every motor individually controlled. same speed on wheels if input more 1 parameter. advice?
i have not heard of ah_easydriver library. please post link documentation.
what stepper motor drivers using?
what arduino using?
...r
what stepper motor drivers using?
what arduino using?
...r
Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Controlling 4 steppers
arduino
Comments
Post a Comment