code裡面使用AccelStepper這個library
使用方式非常簡單
宣告
#include AccelStepper.h
#include MultiStepper.h
指定DM542的 Pul, Dir, Ena 腳位
AccelStepper stepperX (1,2,3); // name of stepper motor (1 = driver, pin 2 = step, pin 3 = direction)
AccelStepper stepperY (1,4,5); // name of stepper motor (1 = driver, pin 4 = step, pin 5 = direction)
AccelStepper stepperZ (1,6,7); // name of stepper motor (1 = driver, pin 6 = step, pin 7 = direction)
MultiStepper steppers;
// 將三顆馬達加入
steppers.addStepper(stepperX);
steppers.addStepper(stepperY);
steppers.addStepper(stepperZ);
給定馬達移動距離
//----multi motor
positions[0]=gc.RotatorAngle[0];
positions[1]=gc.RotatorAngle[1];
positions[2]=gc.RotatorAngle[2];
steppers.moveTo(positions);
steppers.runSpeedToPosition();
如此便能同時動作!!
沒有留言:
張貼留言