G28 läuft für X Y Z
This commit is contained in:
parent
14c405b2b8
commit
fe85e1abe8
153
otto/otto.ino
153
otto/otto.ino
@ -54,7 +54,7 @@
|
||||
#define Z_CS_PIN 34 // Chip select
|
||||
#define Z_LIMIT 45 // Limit Switch
|
||||
#else
|
||||
#define Z_EN_PIN 31 // Enable
|
||||
#define Z_EN_PIN 62 // Enable
|
||||
#define Z_STEP_PIN 46 // Step
|
||||
#define Z_DIR_PIN 48 // Direction
|
||||
#define Z_CS_PIN 40 // Chip select
|
||||
@ -175,8 +175,8 @@ boolean homeP;
|
||||
//Total step per revolution = full steps/rev * microsteps
|
||||
//200 full steps * 16 microsteps = 3200 digital steps
|
||||
int x_steps_mm = 80;
|
||||
int y_steps_mm = 400;
|
||||
int z_steps_mm = 400;
|
||||
int y_steps_mm = 80;
|
||||
int z_steps_mm = 80;
|
||||
int p_steps_mm = 157.5;
|
||||
|
||||
|
||||
@ -193,6 +193,8 @@ int locP_in_steps;
|
||||
|
||||
#ifdef jfs
|
||||
int locX_max = 27000;
|
||||
int locY_max = -31200;
|
||||
int locZ_max = 4000;
|
||||
#endif
|
||||
|
||||
// variables to hold LED data
|
||||
@ -389,7 +391,7 @@ void parseData() { // split the data into its parts
|
||||
}
|
||||
if (strtokIndx[0] == 'Y'){
|
||||
memmove(strtokIndx, strtokIndx+1, strlen(strtokIndx));
|
||||
locY_in_mm = atof(strtokIndx);
|
||||
locY_in_mm = -atof(strtokIndx);
|
||||
}
|
||||
if (strtokIndx[0] == 'Z'){
|
||||
memmove(strtokIndx, strtokIndx+1, strlen(strtokIndx));
|
||||
@ -428,7 +430,19 @@ void parseData() { // split the data into its parts
|
||||
}
|
||||
#endif
|
||||
locY_in_steps = locY_in_mm * y_steps_mm;
|
||||
#ifdef jfs
|
||||
if (locY_in_steps < locY_max) {
|
||||
Serial.println(" Y off limits ");
|
||||
locY_in_steps = locY_max;
|
||||
}
|
||||
#endif
|
||||
locZ_in_steps = locZ_in_mm * z_steps_mm;
|
||||
#ifdef jfs
|
||||
if (locZ_in_steps > locZ_max) {
|
||||
Serial.println(" Z off limits ");
|
||||
locZ_in_steps = locZ_max;
|
||||
}
|
||||
#endif
|
||||
locP_in_steps = locP_in_mm * p_steps_mm;
|
||||
|
||||
}
|
||||
@ -576,14 +590,16 @@ void coordinateMove(){
|
||||
Serial.println( stepperX.currentPosition());
|
||||
Serial.print("Y Position ");
|
||||
Serial.println( stepperY.currentPosition());
|
||||
Serial.print("Y Position ");
|
||||
Serial.println( stepperY.currentPosition());
|
||||
Serial.print("Z Position ");
|
||||
Serial.println( stepperZ.currentPosition());
|
||||
}
|
||||
else if (strcmp(mode, "J1") == 0){
|
||||
//Serial.println(digitalRead(X_LIMIT));
|
||||
//Serial.println(digitalRead(Y_LIMIT));
|
||||
//Serial.println(digitalRead(Z_LIMIT));
|
||||
|
||||
//***** G28 - Homing Cycle *****
|
||||
// For this code to work as written the limit switches must be located at
|
||||
// X - Mininum
|
||||
// Y - Minimun
|
||||
// Z - Minimun
|
||||
else if (strcmp(mode, "G28") == 0){
|
||||
//Homing X at min
|
||||
stepperX.setMaxSpeed(5000);
|
||||
stepperX.setAcceleration(2000);
|
||||
@ -600,112 +616,49 @@ void coordinateMove(){
|
||||
}
|
||||
}
|
||||
}
|
||||
stepperX.setMaxSpeed(100.0);
|
||||
initial_homing=0;
|
||||
while (digitalRead(X_LIMIT) == 1) {
|
||||
initial_homing--;
|
||||
stepperX.moveTo(initial_homing);
|
||||
stepperX.run();
|
||||
}
|
||||
stepperX.setMaxSpeed(10000);
|
||||
stepperX.setAcceleration(5000);
|
||||
stepperX.setCurrentPosition(0);
|
||||
Serial.println("X at Home");
|
||||
|
||||
}
|
||||
//***** G28 - Homing Cycle *****
|
||||
// For this code to work as written the limit switches must be located at
|
||||
// X - Maximum
|
||||
// Y - Maximum
|
||||
// Z - Maximum
|
||||
else if (strcmp(mode, "G28") == 0){
|
||||
stepperX.setMaxSpeed(3000);
|
||||
stepperX.setAcceleration(1000);
|
||||
//Homing Y at min
|
||||
stepperY.setMaxSpeed(5000);
|
||||
stepperY.setAcceleration(5000);
|
||||
stepperZ.setMaxSpeed(2000);
|
||||
stepperZ.setAcceleration(1000);
|
||||
// Z-Axis Homing
|
||||
int initial_homing = stepperZ.currentPosition();
|
||||
homeZ = false;
|
||||
while (homeZ == false){
|
||||
initial_homing++;
|
||||
stepperZ.moveTo(initial_homing);
|
||||
stepperZ.run();
|
||||
if (digitalRead(Z_LIMIT) != 0) {
|
||||
delay(1);
|
||||
if (digitalRead(Z_LIMIT) !=0){
|
||||
homeZ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
stepperZ.setMaxSpeed(100.0);
|
||||
initial_homing=0;
|
||||
while (digitalRead(Z_LIMIT) == 1) {
|
||||
initial_homing--;
|
||||
stepperZ.move(initial_homing);
|
||||
stepperZ.runSpeed();
|
||||
}
|
||||
stepperZ.setCurrentPosition(0);
|
||||
|
||||
// X-Axis Homing
|
||||
initial_homing = stepperX.currentPosition();
|
||||
homeX = false;
|
||||
while (homeX == false){
|
||||
initial_homing--;
|
||||
stepperX.moveTo(initial_homing);
|
||||
stepperX.run();
|
||||
if (digitalRead(X_LIMIT) != 0) {
|
||||
delay(1);
|
||||
if (digitalRead(X_LIMIT) !=0){
|
||||
homeX = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
stepperX.setMaxSpeed(100.0);
|
||||
initial_homing=0;
|
||||
while (digitalRead(X_LIMIT) == 1) {
|
||||
initial_homing++;
|
||||
stepperX.moveTo(initial_homing);
|
||||
stepperX.run();
|
||||
}
|
||||
stepperX.setCurrentPosition(0);
|
||||
|
||||
// Y-Axis Homing
|
||||
stepperY.setAcceleration(2000);
|
||||
initial_homing = stepperY.currentPosition();
|
||||
homeY = false;
|
||||
while (homeY == false){
|
||||
initial_homing++;
|
||||
stepperY.moveTo(initial_homing);
|
||||
stepperY.run();
|
||||
if (digitalRead(Y_LIMIT) != 0) {
|
||||
if (digitalRead(Y_LIMIT) != 1) {
|
||||
delay(1);
|
||||
if (digitalRead(Y_LIMIT) !=0){
|
||||
if (digitalRead(Y_LIMIT) !=1){
|
||||
homeY = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
stepperY.setMaxSpeed(100.0);
|
||||
initial_homing=0;
|
||||
while (digitalRead(Y_LIMIT) == 1) {
|
||||
initial_homing--;
|
||||
stepperY.moveTo(initial_homing);
|
||||
stepperY.run();
|
||||
}
|
||||
|
||||
stepperY.setCurrentPosition(0);
|
||||
stepperY.setMaxSpeed(1000.0);
|
||||
|
||||
|
||||
stepperX.setCurrentPosition(26400);
|
||||
stepperY.setCurrentPosition(144000);
|
||||
stepperZ.setCurrentPosition(0);
|
||||
stepperP.setCurrentPosition(0);
|
||||
stepperX.setMaxSpeed(10000);
|
||||
stepperX.setAcceleration(5000);
|
||||
stepperY.setMaxSpeed(10000);
|
||||
stepperY.setAcceleration(1500);
|
||||
stepperY.setAcceleration(5000);
|
||||
stepperY.setCurrentPosition(0);
|
||||
//Homing Z at min
|
||||
stepperZ.setMaxSpeed(5000);
|
||||
stepperZ.setAcceleration(2000);
|
||||
initial_homing = stepperZ.currentPosition();
|
||||
homeZ = false;
|
||||
while (homeZ == false){
|
||||
initial_homing--;
|
||||
stepperZ.moveTo(initial_homing);
|
||||
stepperZ.run();
|
||||
if (digitalRead(Z_LIMIT) != 1) {
|
||||
delay(1);
|
||||
if (digitalRead(Z_LIMIT) !=1){
|
||||
homeZ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
stepperZ.setMaxSpeed(10000);
|
||||
stepperZ.setAcceleration(5000);
|
||||
stepperZ.setCurrentPosition(0);
|
||||
|
||||
stepperP.setCurrentPosition(0);
|
||||
Serial.println("<OK Homed>");
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user