From 25dc634447d05a7c66e2fdef112e88e5fe3e764a Mon Sep 17 00:00:00 2001 From: Jim Morris Date: Sat, 2 Aug 2014 15:55:37 -0700 Subject: [PATCH] check zprobe is connected and not triggered before any bed leveling command --- ConfigSamples/AzteegX5Mini/config | 19 +++++++++++++++++++ ConfigSamples/Smoothieboard/config | 3 ++- .../tools/zprobe/ThreePointStrategy.cpp | 5 ++++- src/modules/tools/zprobe/ZProbe.cpp | 17 ++++++++++------- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/ConfigSamples/AzteegX5Mini/config b/ConfigSamples/AzteegX5Mini/config index 6676cd2c..da8f307b 100755 --- a/ConfigSamples/AzteegX5Mini/config +++ b/ConfigSamples/AzteegX5Mini/config @@ -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 # diff --git a/ConfigSamples/Smoothieboard/config b/ConfigSamples/Smoothieboard/config index f556651c..3ca0086a 100644 --- a/ConfigSamples/Smoothieboard/config +++ b/ConfigSamples/Smoothieboard/config @@ -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 diff --git a/src/modules/tools/zprobe/ThreePointStrategy.cpp b/src/modules/tools/zprobe/ThreePointStrategy.cpp index 1c06a26c..2fbf7c7f 100644 --- a/src/modules/tools/zprobe/ThreePointStrategy.cpp +++ b/src/modules/tools/zprobe/ThreePointStrategy.cpp @@ -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'); diff --git a/src/modules/tools/zprobe/ZProbe.cpp b/src/modules/tools/zprobe/ZProbe.cpp index 79270f33..c1642a4a 100644 --- a/src/modules/tools/zprobe/ZProbe.cpp +++ b/src/modules/tools/zprobe/ZProbe.cpp @@ -233,18 +233,21 @@ void ZProbe::on_gcode_received(void *argument) Gcode *gcode = static_cast(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); -- 2.20.1