测试完整版本
parent
737b3ce532
commit
4182e4fba7
|
@ -19,15 +19,15 @@
|
||||||
#define Z_MAX_PIN 19
|
#define Z_MAX_PIN 19
|
||||||
|
|
||||||
// Joint 3
|
// Joint 3
|
||||||
#define Y_STEP_PIN 40
|
#define Y_STEP_PIN 48
|
||||||
#define Y_DIR_PIN 42
|
#define Y_DIR_PIN 46
|
||||||
#define Y_ENABLE_PIN 56
|
#define Y_ENABLE_PIN 56
|
||||||
#define Y_MIN_PIN 14
|
#define Y_MIN_PIN 14
|
||||||
#define Y_MAX_PIN 15
|
#define Y_MAX_PIN 15
|
||||||
|
|
||||||
// Joint 4
|
// Joint 4
|
||||||
#define X_STEP_PIN 54
|
#define X_STEP_PIN 40
|
||||||
#define X_DIR_PIN 55
|
#define X_DIR_PIN 42
|
||||||
#define X_ENABLE_PIN 38
|
#define X_ENABLE_PIN 38
|
||||||
|
|
||||||
// Joint 5
|
// Joint 5
|
||||||
|
@ -51,14 +51,14 @@ MultiStepper steppers;
|
||||||
unsigned int x = 1000;
|
unsigned int x = 1000;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(250000);
|
Serial.begin(115200);
|
||||||
|
|
||||||
// Configure each stepper
|
// Configure each stepper
|
||||||
joint1.setMaxSpeed(1500);
|
joint1.setMaxSpeed(100);
|
||||||
joint2.setMaxSpeed(750);
|
joint2.setMaxSpeed(200);
|
||||||
joint3.setMaxSpeed(2000);
|
joint3.setMaxSpeed(500);
|
||||||
joint4.setMaxSpeed(500);
|
joint4.setMaxSpeed(300);
|
||||||
joint5.setMaxSpeed(1000);
|
joint5.setMaxSpeed(80);
|
||||||
|
|
||||||
// Then give them to MultiStepper to manage
|
// Then give them to MultiStepper to manage
|
||||||
steppers.addStepper(joint1);
|
steppers.addStepper(joint1);
|
||||||
|
@ -66,9 +66,26 @@ void setup() {
|
||||||
steppers.addStepper(joint3);
|
steppers.addStepper(joint3);
|
||||||
steppers.addStepper(joint4);
|
steppers.addStepper(joint4);
|
||||||
steppers.addStepper(joint5);
|
steppers.addStepper(joint5);
|
||||||
|
|
||||||
|
pinMode(22, OUTPUT);
|
||||||
|
pinMode(26, OUTPUT);
|
||||||
|
pinMode(24, INPUT);
|
||||||
|
digitalWrite(22,0);
|
||||||
|
digitalWrite(26,0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// link1 -960*4
|
||||||
|
/// link2 -2230*4
|
||||||
|
/// link3 -2780*4
|
||||||
|
/// link4 790*4
|
||||||
|
/// link5 220*4
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
if(digitalRead(24) == 1){
|
||||||
|
Serial.print("enter test mode");
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
long positions[5]; // Array of desired stepper positions
|
long positions[5]; // Array of desired stepper positions
|
||||||
|
|
||||||
// Back of the envelope calculation for microsteps/revolution, where positions[i] is the number of steps (or microsteps).
|
// Back of the envelope calculation for microsteps/revolution, where positions[i] is the number of steps (or microsteps).
|
||||||
|
@ -78,16 +95,44 @@ void loop() {
|
||||||
positions[3] = 0; //820 is 1/4 revolution (200steps/revolution * 16microsteps/step (since microstepping) ~= 32800 microsteps/rev)
|
positions[3] = 0; //820 is 1/4 revolution (200steps/revolution * 16microsteps/step (since microstepping) ~= 32800 microsteps/rev)
|
||||||
positions[4] = 0; //2000 is 50/360 revolution ---> 14400
|
positions[4] = 0; //2000 is 50/360 revolution ---> 14400
|
||||||
|
|
||||||
|
Serial.print("move to ");
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[0]);
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[1]);
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[2]);
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[3]);
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[0]);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
steppers.moveTo(positions);
|
steppers.moveTo(positions);
|
||||||
steppers.runSpeedToPosition(); // Blocks until all are in position
|
steppers.runSpeedToPosition(); // Blocks until all are in position
|
||||||
delay(2000);
|
delay(1000);
|
||||||
// Move to a different coordinate
|
// Move to a different coordinate
|
||||||
positions[0] = 0;
|
positions[0] = 0;
|
||||||
positions[1] = 3000;
|
positions[1] = 0;
|
||||||
positions[2] = 0;
|
positions[2] = 0;
|
||||||
positions[3] = 0;
|
positions[3] = 0;
|
||||||
positions[4] = 0;
|
positions[4] = 220;
|
||||||
steppers.moveTo(positions);
|
steppers.moveTo(positions);
|
||||||
steppers.runSpeedToPosition(); // Blocks until all are in position
|
steppers.runSpeedToPosition(); // Blocks until all are in position
|
||||||
delay(2000);
|
delay(1000);
|
||||||
|
|
||||||
|
Serial.print("move to ");
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[0]);
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[1]);
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[2]);
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[3]);
|
||||||
|
Serial.println();
|
||||||
|
Serial.print(positions[0]);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue