dev version: print m114 coordinates when z endstop was triggered

This commit is contained in:
PavelSindler 2018-02-26 18:25:47 +01:00
parent 3bdaa70ba1
commit e249e854da
6 changed files with 55 additions and 30 deletions

View File

@ -60,7 +60,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define X_MIN_POS 0 #define X_MIN_POS 0
#define Y_MAX_POS 210 #define Y_MAX_POS 210
#define Y_MIN_POS -4 #define Y_MIN_POS -4
#define Z_MAX_POS 200 #define Z_MAX_POS 210
#define Z_MIN_POS 0.15 #define Z_MIN_POS 0.15
// Canceled home position // Canceled home position

View File

@ -435,6 +435,7 @@ void force_high_power_mode(bool start_high_power_section);
// G-codes // G-codes
bool gcode_M45(bool onlyZ, int8_t verbosity_level); bool gcode_M45(bool onlyZ, int8_t verbosity_level);
void gcode_M114();
void gcode_M701(); void gcode_M701();
#define UVLO !(PINE & (1<<4)) #define UVLO !(PINE & (1<<4))

View File

@ -1429,8 +1429,8 @@ void host_keepalive() {
switch (busy_state) { switch (busy_state) {
case IN_HANDLER: case IN_HANDLER:
case IN_PROCESS: case IN_PROCESS:
SERIAL_ECHO_START; //SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("busy: processing"); //SERIAL_ECHOLNPGM("busy: processing");
break; break;
case PAUSED_FOR_USER: case PAUSED_FOR_USER:
SERIAL_ECHO_START; SERIAL_ECHO_START;
@ -2276,6 +2276,29 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
return final_result; return final_result;
} }
void gcode_M114()
{
SERIAL_PROTOCOLPGM("X:");
SERIAL_PROTOCOL(current_position[X_AXIS]);
SERIAL_PROTOCOLPGM(" Y:");
SERIAL_PROTOCOL(current_position[Y_AXIS]);
SERIAL_PROTOCOLPGM(" Z:");
SERIAL_PROTOCOL(current_position[Z_AXIS]);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL(current_position[E_AXIS]);
SERIAL_PROTOCOLRPGM(MSG_COUNT_X);
SERIAL_PROTOCOL(float(st_get_position(X_AXIS)) / axis_steps_per_unit[X_AXIS]);
SERIAL_PROTOCOLPGM(" Y:");
SERIAL_PROTOCOL(float(st_get_position(Y_AXIS)) / axis_steps_per_unit[Y_AXIS]);
SERIAL_PROTOCOLPGM(" Z:");
SERIAL_PROTOCOL(float(st_get_position(Z_AXIS)) / axis_steps_per_unit[Z_AXIS]);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL(float(st_get_position(E_AXIS)) / axis_steps_per_unit[E_AXIS]);
SERIAL_PROTOCOLLN("");
}
void gcode_M701() void gcode_M701()
{ {
#ifdef SNMM #ifdef SNMM
@ -4246,7 +4269,7 @@ void process_commands()
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
break; break;
#if 0 #if 1
case 48: // M48: scan the bed induction sensor points, print the sensor trigger coordinates to the serial line for visualization on the PC. case 48: // M48: scan the bed induction sensor points, print the sensor trigger coordinates to the serial line for visualization on the PC.
{ {
// Disable the default update procedure of the display. We will do a modal dialog. // Disable the default update procedure of the display. We will do a modal dialog.
@ -4908,25 +4931,7 @@ Sigma_Exit:
lcd_setstatus(strchr_pointer + 5); lcd_setstatus(strchr_pointer + 5);
break;*/ break;*/
case 114: // M114 case 114: // M114
SERIAL_PROTOCOLPGM("X:"); gcode_M114();
SERIAL_PROTOCOL(current_position[X_AXIS]);
SERIAL_PROTOCOLPGM(" Y:");
SERIAL_PROTOCOL(current_position[Y_AXIS]);
SERIAL_PROTOCOLPGM(" Z:");
SERIAL_PROTOCOL(current_position[Z_AXIS]);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL(current_position[E_AXIS]);
SERIAL_PROTOCOLRPGM(MSG_COUNT_X);
SERIAL_PROTOCOL(float(st_get_position(X_AXIS))/axis_steps_per_unit[X_AXIS]);
SERIAL_PROTOCOLPGM(" Y:");
SERIAL_PROTOCOL(float(st_get_position(Y_AXIS))/axis_steps_per_unit[Y_AXIS]);
SERIAL_PROTOCOLPGM(" Z:");
SERIAL_PROTOCOL(float(st_get_position(Z_AXIS))/axis_steps_per_unit[Z_AXIS]);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL(float(st_get_position(E_AXIS))/axis_steps_per_unit[E_AXIS]);
SERIAL_PROTOCOLLN("");
break; break;
case 120: // M120 case 120: // M120
enable_endstops(false) ; enable_endstops(false) ;

View File

@ -975,13 +975,26 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
} }
} }
endloop: endloop:
// SERIAL_ECHOLN("First hit"); SERIAL_ECHO("First hit");
SERIAL_ECHO("- X: ");
MYSERIAL.print(current_position[X_AXIS]);
SERIAL_ECHO("; Y: ");
MYSERIAL.print(current_position[Y_AXIS]);
SERIAL_ECHO("; Z: ");
MYSERIAL.println(current_position[Z_AXIS]);
//scan
//if (current_position[X_AXIS] > 100 && current_position[Y_AXIS] > 100) {
// scan();
//}
// we have to let the planner know where we are right now as it is not where we said to go. // we have to let the planner know where we are right now as it is not where we said to go.
update_current_position_xyz(); update_current_position_xyz();
// Search in this plane for the first hit. Zig-zag first in X, then in Y axis. // Search in this plane for the first hit. Zig-zag first in X, then in Y axis.
for (int8_t iter = 0; iter < 3; ++ iter) { for (int8_t iter = 0; iter < 3; ++ iter) {
SERIAL_ECHOPGM("iter: ");
MYSERIAL.println(iter);
if (iter > 0) { if (iter > 0) {
// Slightly lower the Z axis to get a reliable trigger. // Slightly lower the Z axis to get a reliable trigger.
current_position[Z_AXIS] -= 0.02f; current_position[Z_AXIS] -= 0.02f;
@ -998,7 +1011,7 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
found = false; found = false;
for (i = 0, dir_positive = true; i < (nsteps_y - 1); current_position[Y_AXIS] += (y1 - y0) / float(nsteps_y - 1), ++ i, dir_positive = ! dir_positive) { for (i = 0, dir_positive = true; i < (nsteps_y - 1); current_position[Y_AXIS] += (y1 - y0) / float(nsteps_y - 1), ++ i, dir_positive = ! dir_positive) {
go_xy(dir_positive ? x1 : x0, current_position[Y_AXIS], feedrate); go_xy(dir_positive ? x1 : x0, current_position[Y_AXIS], feedrate);
if (endstop_z_hit_on_purpose()) { if (endstop_z_hit_on_purpose()) {
found = true; found = true;
break; break;
} }
@ -1368,7 +1381,7 @@ canceled:
// Searching in a zig-zag movement in a plane for the maximum width of the response. // Searching in a zig-zag movement in a plane for the maximum width of the response.
// This function may set the current_position[Y_AXIS] below Y_MIN_POS, if the function succeeded. // This function may set the current_position[Y_AXIS] below Y_MIN_POS, if the function succeeded.
// If this function failed, the Y coordinate will never be outside the working space. // If this function failed, the Y coordinate will never be outside the working space.
#define IMPROVE_BED_INDUCTION_SENSOR_POINT3_SEARCH_RADIUS (4.f) #define IMPROVE_BED_INDUCTION_SENSOR_POINT3_SEARCH_RADIUS (8.f)
#define IMPROVE_BED_INDUCTION_SENSOR_POINT3_SEARCH_STEP_FINE_Y (0.1f) #define IMPROVE_BED_INDUCTION_SENSOR_POINT3_SEARCH_STEP_FINE_Y (0.1f)
inline bool improve_bed_induction_sensor_point3(int verbosity_level) inline bool improve_bed_induction_sensor_point3(int verbosity_level)
{ {
@ -2462,6 +2475,10 @@ bool sample_mesh_and_store_reference()
return true; return true;
} }
void scan() {
scan_bed_induction_sensor_point();
}
bool scan_bed_induction_points(int8_t verbosity_level) bool scan_bed_induction_points(int8_t verbosity_level)
{ {
// Don't let the manage_inactivity() function remove power from the motors. // Don't let the manage_inactivity() function remove power from the motors.
@ -2490,7 +2507,7 @@ bool scan_bed_induction_points(int8_t verbosity_level)
bool endstop_z_enabled = enable_z_endstop(false); bool endstop_z_enabled = enable_z_endstop(false);
// Collect a matrix of 9x9 points. // Collect a matrix of 9x9 points.
for (int8_t mesh_point = 0; mesh_point < 9; ++ mesh_point) { for (int8_t mesh_point = 2; mesh_point < 3; ++ mesh_point) {
// Don't let the manage_inactivity() function remove power from the motors. // Don't let the manage_inactivity() function remove power from the motors.
refresh_cmd_timeout(); refresh_cmd_timeout();
@ -2501,14 +2518,14 @@ bool scan_bed_induction_points(int8_t verbosity_level)
go_to_current(homing_feedrate[Z_AXIS]/60); go_to_current(homing_feedrate[Z_AXIS]/60);
// Go to the measurement point. // Go to the measurement point.
// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew(). // Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points+mesh_point*2) + vec_y[0] * pgm_read_float(bed_ref_points+mesh_point*2+1) + cntr[0]; current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[0] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[0];
current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points+mesh_point*2+1) + cntr[1]; current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4+mesh_point*2) + vec_y[1] * pgm_read_float(bed_ref_points_4+mesh_point*2+1) + cntr[1];
// The calibration points are very close to the min Y. // The calibration points are very close to the min Y.
if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION) if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION)
current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION; current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
go_to_current(homing_feedrate[X_AXIS]/60); go_to_current(homing_feedrate[X_AXIS]/60);
find_bed_induction_sensor_point_z(); find_bed_induction_sensor_point_z();
scan_bed_induction_sensor_point(); scan_bed_induction_sensor_point();
} }
// Don't let the manage_inactivity() function remove power from the motors. // Don't let the manage_inactivity() function remove power from the motors.
refresh_cmd_timeout(); refresh_cmd_timeout();

View File

@ -172,6 +172,7 @@ extern bool is_bed_z_jitter_data_valid();
// write the trigger coordinates to the serial line. // write the trigger coordinates to the serial line.
// Useful for visualizing the behavior of the bed induction detector. // Useful for visualizing the behavior of the bed induction detector.
extern bool scan_bed_induction_points(int8_t verbosity_level); extern bool scan_bed_induction_points(int8_t verbosity_level);
extern void scan();
// Load Z babystep value from the EEPROM into babystepLoadZ, // Load Z babystep value from the EEPROM into babystepLoadZ,
// but don't apply it through the planner. This is useful on wake up // but don't apply it through the planner. This is useful on wake up

View File

@ -270,6 +270,7 @@ bool endstop_z_hit_on_purpose()
{ {
bool hit = endstop_z_hit; bool hit = endstop_z_hit;
endstop_z_hit=false; endstop_z_hit=false;
if (hit == true) gcode_M114();
return hit; return hit;
} }