void limits_go_home() { st_synchronize(); // Store the current limit switch state uint8_t original_limit_state = LIMIT_PIN; approach_limit_switch(false, false, true); // First home the z axis approach_limit_switch(true, true, false); // Then home the x and y axis // Xor previous and current limit switch state to determine which were high then but have become // low now. These are the actual installed limit switches. uint8_t limit_switches_present = (original_limit_state ^ LIMIT_PIN) & LIMIT_MASK; // Now carefully leave the limit switches leave_limit_switch( limit_switches_present & (1<<X_LIMIT_BIT), limit_switches_present & (1<<Y_LIMIT_BIT), limit_switches_present & (1<<Z_LIMIT_BIT)); }
void limits_go_home() { plan_synchronize(); // Enable steppers by resetting the stepper disable port STEPPERS_ENABLE_PORT |= (1<<STEPPERS_ENABLE_BIT); STEPPERS_ENABLE_PORT |= (1<<STEPPERS_ACTIVITY_BIT); // STEPPERS_DISABLE_PORT &= ~(1<<STEPPERS_DISABLE_BIT); sys.position[X_AXIS]=0; sys.position[Y_AXIS]=0; sys.position[Z_AXIS]=0; #ifdef Z_LIMIT_PRESENT approach_limit_switch(false, false, true); // First home the z axis delay_ms(50); // Now carefully leave the limit switches leave_limit_switch(false, false, true); delay_ms(50); #endif #ifdef Y_HOME_FIRST #ifdef Y_LIMIT_PRESENT approach_limit_switch(false, true, false); // Home Y axis delay_ms(50); leave_limit_switch(false, true, false); delay_ms(50); #endif #ifdef X_LIMIT_PRESENT approach_limit_switch(true, false, false); // Home X axis delay_ms(50); leave_limit_switch(true, false, false); delay_ms(50); #endif #else #ifdef X_LIMIT_PRESENT approach_limit_switch(true, false, false); // Home X axis delay_ms(50); leave_limit_switch(true, false, false); delay_ms(50); #endif #ifdef Y_LIMIT_PRESENT approach_limit_switch(false, true, false); // Home Y axis delay_ms(50); leave_limit_switch(false, true, false); delay_ms(50); #endif #endif // Disable steppers by setting stepper disable delay_ms(50); STEPPERS_ENABLE_PORT &= ~(1<<STEPPERS_ENABLE_BIT); STEPPERS_ENABLE_PORT &= ~(1<<STEPPERS_ACTIVITY_BIT); // STEPPERS_DISABLE_PORT |= (1<<STEPPERS_DISABLE_BIT); // Hardware-Zähler zurücksetzen st_counter_null(); }
void limits_go_home() { st_synchronize(); // home the x and y axis approach_limit_switch(true, true, false); leave_limit_switch(true, true, false); }