Roger_Gao 发表于 2013-9-27 09:45:00

【求助】步进电机 TB6560 程序求修改

本帖最后由 Roger_Gao 于 2013-9-27 09:47 编辑

求助各位大神
我用arduino+TB6560驱动器控制步进电机,现在遇到了问题(步进电机是每转200步)
我的预期结果:步进电机正转八圈,停三秒,反转八圈;
实际执行成果:步进电机正转四圈,停三秒,正转四圈,再反转八圈;(暂停的位置不知道出现了什么问题)
下面是我的程序,使用的是大连好人编写好的EasyStepper库函数,请教各位大神们
#include <EasyStepper.h>

#define STEP_PIN 34
#define DIR_PIN 35
#define EN_PIN 36

#define DIR_PIN_INVERTED true
#define EN_PIN_INVERTED true

int stepps1=-800;
int stepps2=800;
int times1=0;
int times2=0;

void setup()
{
Serial.begin(9600);
stepper1.debugMode(false);
stepper1.startup();
}

void loop()
{
while(times1<2)
{
   stepper1.run();
   if(stepper1.isDone)
   {
   stepper1.rotate(600,stepps1);
   times1++;
    }
}

delay(3000);

while((times1>1)&&(times2<3))
{
    stepper1.run();
    if(stepper1.isDone)
   {
   stepper1.rotate(600,stepps2);
   times2++;
    }
}
}
页: [1]
查看完整版本: 【求助】步进电机 TB6560 程序求修改