步进电机 TB6560 程序求教
本帖最后由 Roger_Gao 于 2013-9-27 09:46 编辑求助各位大神
我用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++;
}
}
} 编译时报错了! beiyefeifei 发表于 2013-12-26 19:13 static/image/common/back.gif
编译时报错了!
你需要把 大连好人 写的Easystepper库放在你的arduino文件中 呕 谢谢提示 Gao@@@ void loop()
{
stepper1.rotate(600,-1600);
delay(3000);
stepper1.rotate(600,1600);
delay(3000);
}
可实现反复正8圈反8圈不断循环,如果要一次性过,直接放在VOID SETUP()内
赞赞,刚好解决我的问题。 表示看不懂啊,继续学习 你能把弄好的EasyStepper库发出来吗?? 楼主
页:
[1]