Permalink
Browse files

Adds support for rack and pinion based Z axes to endstops. Z endstop …

…will back off before homing if the switch is set when the homing operation starts.
  • Loading branch information...
vonnieda committed Jun 17, 2016
1 parent d3bc6d2 commit 5de985c2a51398c59202e47eb462e57847197f84
Showing with 37 additions and 0 deletions.
  1. +37 −0 src/modules/tools/endstops/Endstops.cpp
@@ -416,6 +416,43 @@ void Endstops::do_homing_cartesian(char axes_to_move)
// check if on_halt (eg kill)
if(THEKERNEL->is_halted()) return;

/*
Rack and Pinion Head Homing
The Z axis has a home switch that is triggered for half the length
of the axis. To home it we need to first check if the switch is
triggered, and if it is we need to back off until it's no longer
triggered. Then we can perform a normal homing operation.
*/
int rp_axis = Z_AXIS;
// If we are homing Z and Z switch is already triggered, back away first
if (((axes_to_move >> rp_axis) & 1) && this->pins[rp_axis + (this->home_direction[rp_axis] ? 0 : 3)].get()) {
// Start moving away from the switch
this->status = MOVING_BACK;
this->feed_rate[rp_axis]= this->fast_rates[rp_axis];
STEPPER[rp_axis]->move(!this->home_direction[rp_axis], 10000000, 0);

// Wait for the switch to clear
unsigned int debounce = 0;
while (debounce <= debounce_count) {
if (!this->pins[rp_axis + (this->home_direction[rp_axis] ? 0 : 3)].get()) {
debounce++;
}
else {
debounce = 0;
}

THEKERNEL->call_event(ON_IDLE);

// check if on_halt (eg kill)
if(THEKERNEL->is_halted()) return;
}

// Stop the movement
if (STEPPER[rp_axis]->is_moving()) {
STEPPER[rp_axis]->move(0, 0);
}
}

// this homing works for cartesian and delta printers
// Start moving the axes to the origin
this->status = MOVING_TO_ENDSTOP_FAST;

0 comments on commit 5de985c

Please sign in to comment.