|
发表于 2013-4-23 23:27:36
|
显示全部楼层
找出问题了
if (times < 2)
{
stepper1.run();
if (stepper1.isDone())
{
// go back
stepper1.rotate(400.0,stepps/2);
Serial.println("Iner1"+times);
}
stepper2.run();
if (stepper2.isDone())
{
// go back
stepper2.rotate(50.0,-stepps/2);
times++;
Serial.println("Iner2"+times);
}
if(times==2)
{
stepps=0;
times=0;
}
看黑体代码部分,函数 .run是走一小步的意思, 每次step1走一小步,然后判断走完没有,然后step2再走一小步,然后再判断step2走完没有.
如果step1走完, 就继续走stepps/2步(对time和step2都没有影响), 只有等step2走完,time才加1.
只有time加到2, 才跳出函数,大家同时不走了.
所以导致的结果是,无论step1速度是多少,要走多少步,可是两个马达运行的时间都是以step2的设置为主
现在你知道应该怎么改你的程序了吧
|
|