-
Notifications
You must be signed in to change notification settings - Fork 228
/
MultiAxis.ino
64 lines (55 loc) · 1.71 KB
/
MultiAxis.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Multi-motor control (experimental)
*
* Move two or three motors at the same time.
* This module is still work in progress and may not work well or at all.
*
* Copyright (C)2017 Laurentiu Badea
*
* This file may be redistributed under the terms of the MIT license.
* A copy of this license has been included with this distribution in the file LICENSE.
*/
#include <Arduino.h>
#include "BasicStepperDriver.h"
#include "MultiDriver.h"
#include "SyncDriver.h"
// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
#define MOTOR_STEPS 200
// Target RPM for X axis motor
#define MOTOR_X_RPM 30
// Target RPM for Y axis motor
#define MOTOR_Y_RPM 90
// X motor
#define DIR_X 8
#define STEP_X 9
// Y motor
#define DIR_Y 6
#define STEP_Y 7
// If microstepping is set externally, make sure this matches the selected mode
// 1=full step, 2=half step etc.
#define MICROSTEPS 32
// 2-wire basic config, microstepping is hardwired on the driver
// Other drivers can be mixed and matched but must be configured individually
BasicStepperDriver stepperX(MOTOR_STEPS, DIR_X, STEP_X);
BasicStepperDriver stepperY(MOTOR_STEPS, DIR_Y, STEP_Y);
// Pick one of the two controllers below
// each motor moves independently, trajectory is a hockey stick
// MultiDriver controller(stepperX, stepperY);
// OR
// synchronized move, trajectory is a straight line
SyncDriver controller(stepperX, stepperY);
void setup() {
/*
* Set target motors RPM.
*/
stepperX.begin(MOTOR_X_RPM, MICROSTEPS);
stepperY.begin(MOTOR_Y_RPM, MICROSTEPS);
}
void loop() {
controller.rotate(90*5, 60*15);
delay(1000);
controller.rotate(-90*5, -30*15);
delay(1000);
controller.rotate(0, -30*15);
delay(30000);
}