check zprobe is connected and not triggered before any bed leveling command
authorJim Morris <morris@wolfman.com>
Sat, 2 Aug 2014 22:55:37 +0000 (15:55 -0700)
committerJim Morris <morris@wolfman.com>
Sat, 2 Aug 2014 22:55:37 +0000 (15:55 -0700)
ConfigSamples/AzteegX5Mini/config
ConfigSamples/Smoothieboard/config
src/modules/tools/zprobe/ThreePointStrategy.cpp
src/modules/tools/zprobe/ZProbe.cpp

index 6676cd2..da8f307 100755 (executable)
@@ -144,6 +144,25 @@ alpha_homing_retract_mm                      5                # distance in mm
 beta_homing_retract_mm                       5                # "
 gamma_homing_retract_mm                      1                # "
 
+#endstop_debounce_count                       100              # uncomment if you get noise on your endstops, default is 100
+
+# optional Z probe
+zprobe.enable                                false           # set to true to enable a zprobe
+zprobe.probe_pin                             1.29!^          # pin probe is attached to if NC remove the !
+zprobe.slow_feedrate                         5               # mm/sec probe feed rate
+#zprobe.debounce_count                       100             # set if noisy
+zprobe.fast_feedrate                         100             # move feedrate mm/sec
+zprobe.probe_height                          5               # how much above bed to start probe
+
+# associated with zprobe the leveling strategy to use
+#leveling-strategy.three-point-leveling.enable     true        # a leveling strategy that probes three points to define a plane and keeps the Z parallel to that plane
+#leveling-strategy.three-point-leveling.point1     100.0,0.0   # the first probe point (x,y) optional may be defined with M557
+#leveling-strategy.three-point-leveling.point2     200.0,200.0 # the second probe point (x,y)
+#leveling-strategy.three-point-leveling.point3     0.0,200.0   # the third probe point (x,y)
+#leveling-strategy.three-point-leveling.home_first true        # home the XY axis before probing
+#leveling-strategy.three-point-leveling.tolerance  0.03        # the probe tolerance in mm, anything less that this will be ignored, default is 0.03mm
+
+
 # Pause button
 pause_button_enable                          true             #
 
index f556651..3ca0086 100644 (file)
@@ -226,7 +226,7 @@ alpha_homing_retract_mm                      5                # distance in mm
 beta_homing_retract_mm                       5                # "
 gamma_homing_retract_mm                      1                # "
 
-#endstop_debounce_count                       100              # uncomment if you get noise on your endstops
+#endstop_debounce_count                       100              # uncomment if you get noise on your endstops, default is 100
 
 # optional Z probe
 zprobe.enable                                false           # set to true to enable a zprobe
@@ -243,6 +243,7 @@ zprobe.probe_height                          5               # how much above be
 #leveling-strategy.three-point-leveling.point2     200.0,200.0 # the second probe point (x,y)
 #leveling-strategy.three-point-leveling.point3     0.0,200.0   # the third probe point (x,y)
 #leveling-strategy.three-point-leveling.home_first true        # home the XY axis before probing
+#leveling-strategy.three-point-leveling.tolerance  0.03        # the probe tolerance in mm, anything less that this will be ignored, default is 0.03mm
 
 
 # Pause button
index 1c06a26..2fbf7c7 100644 (file)
@@ -59,7 +59,7 @@ bool ThreePointStrategy::handleGcode(Gcode *gcode)
             // first wait for an empty queue i.e. no moves left
             THEKERNEL->conveyor->wait_for_empty_queue();
             if(!doProbing(gcode->stream)) {
-                gcode->stream->printf("Probe failed to complete, probe not triggered\n");
+                gcode->stream->printf("Probe failed to complete, probe not triggered or other error\n");
             } else {
                 gcode->stream->printf("Probe completed, bed plane defined\n");
             }
@@ -75,6 +75,8 @@ bool ThreePointStrategy::handleGcode(Gcode *gcode)
             if(gcode->has_letter('Y')) y = gcode->get_value('Y');
             if(idx >= 0 && idx <= 2) {
                 probe_points[idx] = std::make_tuple(x, y);
+            }else{
+                 gcode->stream->printf("only 3 probe points allowed P0-P2\n");
             }
             return true;
 
@@ -100,6 +102,7 @@ bool ThreePointStrategy::handleGcode(Gcode *gcode)
             std::tie(x, y) = probe_points[2]; v[2].set(x, y, c);
             delete this->plane;
             this->plane = new Plane3D(v[0], v[1], v[2]);
+            gcode->stream->printf("plane normal= %f, %f, %f\n", plane->getNormal()[0], plane->getNormal()[1], plane->getNormal()[2]);
             x= 0; y=0;
             if(gcode->has_letter('X')) x = gcode->get_value('X');
             if(gcode->has_letter('Y')) y = gcode->get_value('Y');
index 79270f3..c1642a4 100644 (file)
@@ -233,18 +233,21 @@ void ZProbe::on_gcode_received(void *argument)
     Gcode *gcode = static_cast<Gcode *>(argument);
 
     if( gcode->has_g && gcode->g >= 29 && gcode->g <= 32) {
-        // G code processing
+        // make sure the probe is defined and not already triggered before moving motors
+       if(!this->pin.connected()) {
+            gcode->stream->printf("ZProbe not connected.\n");
+            return;
+        }
+        if(this->pin.get()) {
+            gcode->stream->printf("ZProbe triggered before move, aborting command.\n");
+            return;
+        }
+
         if( gcode->g == 30 ) { // simple Z probe
             gcode->mark_as_taken();
             // first wait for an empty queue i.e. no moves left
             THEKERNEL->conveyor->wait_for_empty_queue();
 
-            // make sure the probe is not already triggered before moving motors
-            if(this->pin.get()) {
-                gcode->stream->printf("ZProbe triggered before move, aborting command.\n");
-                return;
-            }
-
             int steps;
             if(run_probe(steps)) {
                 gcode->stream->printf("Z:%1.4f C:%d\n", steps / Z_STEPS_PER_MM, steps);