Browse Source

dev version: print m114 coordinates when z endstop was triggered

PavelSindler 6 years ago
parent
commit
e249e854da

+ 1 - 1
Firmware/Configuration_prusa.h

@@ -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 Y_MAX_POS 210
 #define Y_MIN_POS -4
-#define Z_MAX_POS 200
+#define Z_MAX_POS 210
 #define Z_MIN_POS 0.15
 
 // Canceled home position

+ 1 - 0
Firmware/Marlin.h

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

+ 27 - 22
Firmware/Marlin_main.cpp

@@ -1429,8 +1429,8 @@ void host_keepalive() {
      switch (busy_state) {
       case IN_HANDLER:
       case IN_PROCESS:
-        SERIAL_ECHO_START;
-        SERIAL_ECHOLNPGM("busy: processing");
+        //SERIAL_ECHO_START;
+        //SERIAL_ECHOLNPGM("busy: processing");
         break;
       case PAUSED_FOR_USER:
         SERIAL_ECHO_START;
@@ -2276,6 +2276,29 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
 	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()
 {
 #ifdef SNMM
@@ -4246,7 +4269,7 @@ void process_commands()
 		KEEPALIVE_STATE(IN_HANDLER);
         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.
     {
         // 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);
       break;*/
     case 114: // 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("");
+		gcode_M114();
       break;
     case 120: // M120
       enable_endstops(false) ;

+ 24 - 7
Firmware/mesh_bed_calibration.cpp

@@ -975,13 +975,26 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
             }
         }
         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.
         update_current_position_xyz();
 
         // 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) {
+			SERIAL_ECHOPGM("iter: ");
+			MYSERIAL.println(iter);
             if (iter > 0) {
                 // Slightly lower the Z axis to get a reliable trigger.
                 current_position[Z_AXIS] -= 0.02f;
@@ -998,7 +1011,7 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
             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) {
                 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;
                     break;
                 }
@@ -1368,7 +1381,7 @@ canceled:
 // 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.
 // 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)
 inline bool improve_bed_induction_sensor_point3(int verbosity_level)
 {	
@@ -2462,6 +2475,10 @@ bool sample_mesh_and_store_reference()
     return true;
 }
 
+void scan() {
+	scan_bed_induction_sensor_point();
+}
+
 bool scan_bed_induction_points(int8_t verbosity_level)
 {
     // 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);
 
     // 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.
         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 the measurement point.
         // 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[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[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_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.
         if (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);
         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.
     refresh_cmd_timeout();

+ 1 - 0
Firmware/mesh_bed_calibration.h

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

+ 1 - 0
Firmware/stepper.cpp

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