enable power and motors before homing, set position to n_MIN when hitting MIN limits if set

This commit is contained in:
Michael Moon 2011-06-22 11:16:46 +10:00
parent a262d72788
commit fd93109b63
1 changed files with 33 additions and 11 deletions

44
home.c
View File

@ -32,7 +32,9 @@ void home() {
/// find X MIN endstop /// find X MIN endstop
void home_x_negative() { void home_x_negative() {
power_on();
queue_wait(); queue_wait();
x_enable();
#if defined X_MIN_PIN #if defined X_MIN_PIN
uint8_t denoise_count = 0; uint8_t denoise_count = 0;
@ -68,13 +70,19 @@ void home_x_negative() {
} }
// set X home // set X home
startpoint.X = current_position.X = 0; #ifdef X_MIN
startpoint.X = current_position.X = (int32_t) (X_MIN * STEPS_PER_MM_X);
#else
startpoint.X = current_position.X = 0;
#endif
#endif #endif
} }
/// find X_MAX endstop /// find X_MAX endstop
void home_x_positive() { void home_x_positive() {
power_on();
queue_wait(); queue_wait();
x_enable();
#if defined X_MAX_PIN #if defined X_MAX_PIN
uint8_t denoise_count = 0; uint8_t denoise_count = 0;
@ -110,18 +118,19 @@ void home_x_positive() {
} }
// set X home // set X home
TARGET t = {0, 0, 0, 0, 0};
// set position to MAX // set position to MAX
startpoint.X = current_position.X = (int32_t) (X_MAX * STEPS_PER_MM_X); startpoint.X = current_position.X = (int32_t) (X_MAX * STEPS_PER_MM_X);
// go to zero // go to zero
t.F = MAXIMUM_FEEDRATE_X; TARGET t = {0, 0, 0, 0, MAXIMUM_FEEDRATE_X};
enqueue(&t); enqueue(&t);
#endif #endif
} }
/// fund Y MIN endstop /// fund Y MIN endstop
void home_y_negative() { void home_y_negative() {
power_on();
queue_wait(); queue_wait();
y_enable();
#if defined Y_MIN_PIN #if defined Y_MIN_PIN
uint8_t denoise_count = 0; uint8_t denoise_count = 0;
@ -157,13 +166,19 @@ void home_y_negative() {
} }
// set Y home // set Y home
startpoint.Y = current_position.Y = 0; #ifdef Y_MIN
startpoint.Y = current_position.Y = (int32_t) (Y_MIN * STEPS_PER_MM_Y);
#else
startpoint.Y = current_position.Y = 0;
#endif
#endif #endif
} }
/// find Y MAX endstop /// find Y MAX endstop
void home_y_positive() { void home_y_positive() {
power_on();
queue_wait(); queue_wait();
y_enable();
#if defined Y_MAX_PIN #if defined Y_MAX_PIN
uint8_t denoise_count = 0; uint8_t denoise_count = 0;
@ -199,18 +214,19 @@ void home_y_positive() {
} }
// set Y home // set Y home
TARGET t = {0, 0, 0, 0, 0};
// set position to MAX // set position to MAX
startpoint.Y = current_position.Y = (int32_t) (Y_MAX * STEPS_PER_MM_Y); startpoint.Y = current_position.Y = (int32_t) (Y_MAX * STEPS_PER_MM_Y);
// go to zero // go to zero
t.F = MAXIMUM_FEEDRATE_Y; TARGET t = {0, 0, 0, 0, MAXIMUM_FEEDRATE_Y};
enqueue(&t); enqueue(&t);
#endif #endif
} }
/// find Z MIN endstop /// find Z MIN endstop
void home_z_negative() { void home_z_negative() {
power_on();
queue_wait(); queue_wait();
z_enable();
#if defined Z_MIN_PIN #if defined Z_MIN_PIN
uint8_t denoise_count = 0; uint8_t denoise_count = 0;
@ -246,14 +262,20 @@ void home_z_negative() {
} }
// set Z home // set Z home
startpoint.Z = current_position.Z = 0; #ifdef Z_MIN
startpoint.Z = current_position.Z = (int32_t) (Z_MIN * STEPS_PER_MM_Z);
#else
startpoint.Z = current_position.Z = 0;
#endif
z_disable(); z_disable();
#endif #endif
} }
/// find Z MAX endstop /// find Z MAX endstop
void home_z_positive() { void home_z_positive() {
power_on();
queue_wait(); queue_wait();
z_enable();
#if defined Z_MAX_PIN #if defined Z_MAX_PIN
uint8_t denoise_count = 0; uint8_t denoise_count = 0;
@ -288,12 +310,12 @@ void home_z_positive() {
delay((uint32_t) (60.0 * 1000000.0 / STEPS_PER_MM_Z / ((float) SEARCH_FEEDRATE_Z))); delay((uint32_t) (60.0 * 1000000.0 / STEPS_PER_MM_Z / ((float) SEARCH_FEEDRATE_Z)));
} }
// set Z home // set Z home:
TARGET t = {0, 0, 0, 0, 0};
// set position to MAX // set position to MAX
startpoint.Z = current_position.Z = (int32_t) (Z_MAX * STEPS_PER_MM_Z); startpoint.Z = current_position.Z = (int32_t) (Z_MAX * STEPS_PER_MM_Z);
// go to zero // go to zero
t.F = MAXIMUM_FEEDRATE_Z; // TARGET t = {0, 0, 0, 0, MAXIMUM_FEEDRATE_Z};
enqueue(&t); // enqueue(&t);
#endif #endif
} }