极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11595|回复: 0

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

[复制链接]
发表于 2013-9-27 09:45:00 | 显示全部楼层 |阅读模式
本帖最后由 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++;
    }
  }
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-8 20:58 , Processed in 0.034565 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表