do not hardcode maximum Zprobe distance use gamma_max*2
authorJim Morris <morris@wolfman.com>
Tue, 2 Sep 2014 21:42:01 +0000 (14:42 -0700)
committerJim Morris <morris@wolfman.com>
Tue, 2 Sep 2014 21:42:01 +0000 (14:42 -0700)
src/modules/tools/endstops/Endstops.cpp
src/modules/tools/zprobe/ZProbe.cpp
src/modules/tools/zprobe/ZProbe.h

index 090ee25..6722399 100644 (file)
@@ -189,8 +189,8 @@ void Endstops::on_config_reload(void *argument)
     this->home_direction[2]         = home_dir != home_to_max_checksum;
 
     this->homing_position[0]        =  this->home_direction[0] ? THEKERNEL->config->value(alpha_min_checksum)->by_default(0)->as_number() : THEKERNEL->config->value(alpha_max_checksum)->by_default(200)->as_number();
-    this->homing_position[1]        =  this->home_direction[1] ? THEKERNEL->config->value(beta_min_checksum )->by_default(0)->as_number() : THEKERNEL->config->value(beta_max_checksum )->by_default(200)->as_number();;
-    this->homing_position[2]        =  this->home_direction[2] ? THEKERNEL->config->value(gamma_min_checksum)->by_default(0)->as_number() : THEKERNEL->config->value(gamma_max_checksum)->by_default(200)->as_number();;
+    this->homing_position[1]        =  this->home_direction[1] ? THEKERNEL->config->value(beta_min_checksum )->by_default(0)->as_number() : THEKERNEL->config->value(beta_max_checksum )->by_default(200)->as_number();
+    this->homing_position[2]        =  this->home_direction[2] ? THEKERNEL->config->value(gamma_min_checksum)->by_default(0)->as_number() : THEKERNEL->config->value(gamma_max_checksum)->by_default(200)->as_number();
 
     this->is_corexy                 =  THEKERNEL->config->value(corexy_homing_checksum)->by_default(false)->as_bool();
     this->is_delta                  =  THEKERNEL->config->value(delta_homing_checksum)->by_default(false)->as_bool();
index a880078..45bc2e3 100644 (file)
@@ -36,6 +36,7 @@
 #define slow_feedrate_checksum   CHECKSUM("slow_feedrate")
 #define fast_feedrate_checksum   CHECKSUM("fast_feedrate")
 #define probe_height_checksum    CHECKSUM("probe_height")
+#define gamma_max_checksum       CHECKSUM("gamma_max")
 
 // from endstop section
 #define delta_homing_checksum    CHECKSUM("delta_homing")
@@ -114,9 +115,10 @@ void ZProbe::on_config_reload(void *argument)
         }
     }
 
-    this->probe_height  THEKERNEL->config->value(zprobe_checksum, probe_height_checksum)->by_default(5.0F)->as_number();
+    this->probe_height  = THEKERNEL->config->value(zprobe_checksum, probe_height_checksum)->by_default(5.0F)->as_number();
     this->slow_feedrate = THEKERNEL->config->value(zprobe_checksum, slow_feedrate_checksum)->by_default(5)->as_number(); // feedrate in mm/sec
     this->fast_feedrate = THEKERNEL->config->value(zprobe_checksum, fast_feedrate_checksum)->by_default(100)->as_number(); // feedrate in mm/sec
+    this->max_z         = THEKERNEL->config->value(gamma_max_checksum)->by_default(500)->as_number(); // maximum zprobe distance
 }
 
 bool ZProbe::wait_for_probe(int& steps)
@@ -163,16 +165,17 @@ bool ZProbe::run_probe(int& steps, bool fast)
     // Enable the motors
     THEKERNEL->stepper->turn_enable_pins_on();
     this->current_feedrate = (fast ? this->fast_feedrate : this->slow_feedrate) * Z_STEPS_PER_MM; // steps/sec
+    float maxz= this->max_z*2;
 
     // move Z down
     STEPPER[Z_AXIS]->set_speed(0); // will be increased by acceleration tick
-    STEPPER[Z_AXIS]->move(true, 1000 * Z_STEPS_PER_MM); // always probes down, no more than 1000mm TODO should be 2*maxz
+    STEPPER[Z_AXIS]->move(true, maxz * Z_STEPS_PER_MM); // always probes down, no more than 2*maxz
     if(this->is_delta) {
         // for delta need to move all three actuators
         STEPPER[X_AXIS]->set_speed(0);
-        STEPPER[X_AXIS]->move(true, 1000 * STEPS_PER_MM(X_AXIS));
+        STEPPER[X_AXIS]->move(true, maxz * STEPS_PER_MM(X_AXIS));
         STEPPER[Y_AXIS]->set_speed(0);
-        STEPPER[Y_AXIS]->move(true, 1000 * STEPS_PER_MM(Y_AXIS));
+        STEPPER[Y_AXIS]->move(true, maxz * STEPS_PER_MM(Y_AXIS));
     }
 
     // start acceration hrprocessing
index 2bf5908..4d966f4 100644 (file)
@@ -53,6 +53,7 @@ private:
     float slow_feedrate;
     float fast_feedrate;
     float probe_height;
+    float max_z;
     volatile struct {
         volatile bool running:1;
         bool is_delta:1;