void checkHitEndstops() { if (endstop_hit_bits) { ECHO_SM(DB, MSG_ENDSTOPS_HIT); if (endstop_hit_bits & BIT(X_MIN)) { ECHO_MV(MSG_ENDSTOP_X, (float)endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_XS); } if (endstop_hit_bits & BIT(Y_MIN)) { ECHO_MV(MSG_ENDSTOP_Y, (float)endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_YS); } if (endstop_hit_bits & BIT(Z_MIN)) { ECHO_MV(MSG_ENDSTOP_Z, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZS); } #ifdef Z_PROBE_ENDSTOP if (endstop_hit_bits & BIT(Z_PROBE)) { ECHO_MV(MSG_ENDSTOP_ZPS, (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ZPS); } #endif #ifdef NPR2 if (endstop_hit_bits & BIT(E_MIN)) { ECHO_MV(MSG_ENDSTOP_E, (float)endstops_trigsteps[E_AXIS] / axis_steps_per_unit[E_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT MSG_ENDSTOP_ES); } #endif ECHO_E; endstops_hit_on_purpose(); #if defined(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && defined(SDSUPPORT) if (abort_on_endstop_hit) { card.sdprinting = false; card.closeFile(); quickStop(); disable_all_heaters(); // switch off all heaters. } #endif } }
void checkHitEndstops() { if (endstop_x_hit || endstop_y_hit || endstop_z_hit || endstop_z_probe_hit) { // #ifdef || endstop_z_probe_hit to save space if needed. SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT); if (endstop_x_hit) { SERIAL_ECHOPAIR(" X:", (float)endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "X"); } if (endstop_y_hit) { SERIAL_ECHOPAIR(" Y:", (float)endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Y"); } if (endstop_z_hit) { SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z"); } #ifdef Z_PROBE_ENDSTOP if (endstop_z_probe_hit) { SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP"); } #endif SERIAL_EOL; endstops_hit_on_purpose(); #if defined(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && defined(SDSUPPORT) if (abort_on_endstop_hit) { card.sdprinting = false; card.closefile(); quickStop(); setTargetHotend0(0); setTargetHotend1(0); setTargetHotend2(0); setTargetHotend3(0); setTargetBed(0); } #endif } }
void checkHitEndstops() { if (endstop_hit_bits) { SERIAL_ECHO_START; SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT); if (endstop_hit_bits & BIT(X_MIN)) { SERIAL_ECHOPAIR(" X:", (float)endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "X"); } if (endstop_hit_bits & BIT(Y_MIN)) { SERIAL_ECHOPAIR(" Y:", (float)endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Y"); } if (endstop_hit_bits & BIT(Z_MIN)) { SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z"); } #ifdef Z_PROBE_ENDSTOP if (endstop_hit_bits & BIT(Z_PROBE)) { SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]); LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP"); } #endif SERIAL_EOL; endstops_hit_on_purpose(); #if defined(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && defined(SDSUPPORT) if (abort_on_endstop_hit) { card.sdprinting = false; card.closefile(); quickStop(); disable_all_heaters(); // switch off all heaters. } #endif } }
float Probe_Bed(float x_pos, float y_pos, int n) { //returns Probed Z average height float ProbeDepth[n]; float ProbeDepthAvg=0; //force bed heater off for probing int save_bed_targ = target_raw_bed; target_raw_bed = 0; WRITE(HEATER_BED_PIN,LOW); if (Z_HOME_DIR==-1) { //int probe_flag =1; float meas = 0; int fails = 0; saved_feedrate = feedrate; saved_feedmultiply = feedmultiply; feedmultiply = 100; //previous_millis_cmd = millis(); //Move to probe position if (x_pos >= 0) destination[X_AXIS]=x_pos; if (y_pos >= 0) destination[Y_AXIS]=y_pos; //destination[Z_AXIS]=current_position[Z_AXIS]; destination[Z_AXIS]=Z_HOME_RETRACT_MM; feedrate = 9000; prepare_move(); enable_endstops(true); SERIAL_ECHO("PRE-PROBE current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]); SERIAL_ECHOLN("Ready to probe..."); //Probe bed n times //*******************************************************************************************Bed Loop************************************* for(int8_t i=0; i < n ; i++) { //int z = 0; //fast probe //plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); destination[Z_AXIS] = 1.1 * Z_MAX_LENGTH * Z_HOME_DIR; feedrate = homing_feedrate[Z_AXIS]; plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); //feedrate = 0.0; SERIAL_ECHO("current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]); if(endstop_z_hit == true) { SERIAL_ECHO("endstops_trigsteps[Z_AXIS]=");SERIAL_ECHOLN(endstops_trigsteps[Z_AXIS]); ProbeDepth[i]= endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]; meas = ProbeDepth[i]; SERIAL_ECHO("ProbeDepth[");SERIAL_ECHO(i);SERIAL_ECHO("]=");SERIAL_ECHOLN(ProbeDepth[i]); //************************************************************************************************************* if (i > 0 ) //Second probe has happened so compare results { if (abs(ProbeDepth[i] - ProbeDepth[i - 1]) > .05) { //keep going until readings match to avoid sticky bed SERIAL_ECHO("Probing again: "); SERIAL_ECHO(ProbeDepth[i]); SERIAL_ECHO(" - "); SERIAL_ECHO(ProbeDepth[i - 1]);SERIAL_ECHO(" = "); SERIAL_ECHOLN(abs(ProbeDepth[i] - ProbeDepth[i - 1])); meas = ProbeDepth[i]; i--; i--; //Throw out both that don't match because we don't know which one is accurate if(fails++ > 4) break; } } }else{ SERIAL_ECHOLN("Probe not triggered."); i=n-1; } //************************************************************************************************************************************************** //fast move clear plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], meas, current_position[E_AXIS]); destination[Z_AXIS] = Z_HOME_RETRACT_MM; feedrate = fast_home_feedrate[Z_AXIS]; plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); //check z stop isn't still triggered if ( READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING ) { SERIAL_ECHOLN("Poking Stuck Bed:"); destination[Z_AXIS] = -1; prepare_move(); destination[Z_AXIS] = Z_HOME_RETRACT_MM; prepare_move(); st_synchronize(); i--; //Throw out this meaningless measurement } feedrate = 0; } //end probe loop #ifdef ENDSTOPS_ONLY_FOR_HOMING enable_endstops(false); #endif feedrate = saved_feedrate; feedmultiply = saved_feedmultiply; //previous_millis_cmd = millis(); endstops_hit_on_purpose(); } for(int8_t i=0;i<n;i++) { ProbeDepthAvg += ProbeDepth[i]; } ProbeDepthAvg /= n; SERIAL_ECHO("Probed Z="); SERIAL_ECHOLN(ProbeDepthAvg); SERIAL_ECHO("RAW current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], Z_HOME_RETRACT_MM, current_position[E_AXIS]); current_position[Z_AXIS] = Z_HOME_RETRACT_MM; target_raw_bed = save_bed_targ; return ProbeDepthAvg; }