aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-07-24 14:12:17 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-07-24 14:31:46 -0400
commit981c53682f58c49f7c140bad945e54d7d61d2755 (patch)
tree42306830ad35e4dc78438998af7a35460e621cb1
parent143b7cccf4bb170fa6a78d88da9d061487288792 (diff)
downloadkutter-981c53682f58c49f7c140bad945e54d7d61d2755.tar.gz
kutter-981c53682f58c49f7c140bad945e54d7d61d2755.tar.xz
kutter-981c53682f58c49f7c140bad945e54d7d61d2755.zip
stepper: Use a sane default for homing_positive_dir
Use the endstop position to determine a sane default for homing_positive_dir. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--config/example-corexy.cfg4
-rw-r--r--config/example-delta.cfg2
-rw-r--r--config/example.cfg28
-rw-r--r--config/generic-cramps.cfg5
-rw-r--r--config/generic-rambo.cfg5
-rw-r--r--config/generic-ramps.cfg5
-rw-r--r--config/generic-replicape.cfg5
-rw-r--r--config/makergear-m2-2012.cfg21
-rw-r--r--klippy/stepper.py13
9 files changed, 46 insertions, 42 deletions
diff --git a/config/example-corexy.cfg b/config/example-corexy.cfg
index ac2b23c6..71752cd6 100644
--- a/config/example-corexy.cfg
+++ b/config/example-corexy.cfg
@@ -15,9 +15,9 @@ dir_pin: ar55
enable_pin: !ar38
step_distance: .01
endstop_pin: ^ar3
-homing_speed: 50.0
position_endstop: 0
position_max: 200
+homing_speed: 50
# The stepper_y section is used to describe the Y axis as well as the
# stepper controlling the X-Y movement.
@@ -27,9 +27,9 @@ dir_pin: ar61
enable_pin: !ar56
step_distance: .01
endstop_pin: ^ar14
-homing_speed: 50.0
position_endstop: 0
position_max: 200
+homing_speed: 50
[stepper_z]
step_pin: ar46
diff --git a/config/example-delta.cfg b/config/example-delta.cfg
index aa03fa1d..ca11ac1b 100644
--- a/config/example-delta.cfg
+++ b/config/example-delta.cfg
@@ -16,12 +16,12 @@ dir_pin: ar55
enable_pin: !ar38
step_distance: .01
endstop_pin: ^ar2
-homing_speed: 50.0
position_endstop: 297.05
#angle:
# This option specifies the angle (in degrees) that the tower is
# at. The default is 210 for stepper_a, 330 for stepper_b, and 90
# for stepper_c.
+homing_speed: 50
# The stepper_b section describes the stepper controlling the front
# right tower (at 330 degrees).
diff --git a/config/example.cfg b/config/example.cfg
index 36f609c6..71ac0563 100644
--- a/config/example.cfg
+++ b/config/example.cfg
@@ -35,15 +35,27 @@ step_distance: .0225
endstop_pin: ^ar3
# Endstop switch detection pin. This parameter must be provided for
# the X, Y, and Z steppers on cartesian style printers.
+#position_min: 0
+# Minimum valid distance (in mm) the user may command the stepper to
+# move to. The default is 0mm.
+position_endstop: 0
+# Location of the endstop (in mm). This parameter must be provided
+# for the X, Y, and Z steppers on cartesian style printers.
+position_max: 200
+# Maximum valid distance (in mm) the user may command the stepper to
+# move to. This parameter must be provided for the X, Y, and Z
+# steppers on cartesian style printers.
#homing_speed: 5.0
# Maximum velocity (in mm/s) of the stepper when homing. The default
# is 5mm/s.
#homing_retract_dist: 5.0
# Distance to backoff (in mm) before homing a second time during
# homing. The default is 5mm.
-#homing_positive_dir: False
-# If true, homes in a positive direction (away from zero). The
-# default is False.
+#homing_positive_dir:
+# If true, homing will cause the stepper to move in a positive
+# direction (away from zero); if false, home towards zero. The
+# default is true if position_endstop is near position_max and false
+# if near position_min.
#homing_stepper_phases: 0
# One may optionally set this to the number of phases of the stepper
# motor driver (which is the number of micro-steps multiplied by
@@ -64,16 +76,6 @@ endstop_pin: ^ar3
# reset. If this is not set, but homing_stepper_phases is set, then
# the stepper phase will be detected on the first home and that
# phase will be used on all subsequent homes.
-#position_min: 0
-# Minimum valid distance (in mm) the user may command the stepper to
-# move to. The default is 0mm.
-position_endstop: 0
-# Location of the endstop (in mm). This parameter must be provided
-# for the X, Y, and Z steppers on cartesian style printers.
-position_max: 200
-# Maximum valid distance (in mm) the user may command the stepper to
-# move to. This parameter must be provided for the X, Y, and Z
-# steppers on cartesian style printers.
# The stepper_y section is used to describe the stepper controlling
# the Y axis in a cartesian robot. It has the same settings as the
diff --git a/config/generic-cramps.cfg b/config/generic-cramps.cfg
index 70c3d578..610b0793 100644
--- a/config/generic-cramps.cfg
+++ b/config/generic-cramps.cfg
@@ -11,9 +11,9 @@ dir_pin: P8_12
enable_pin: !P9_14
step_distance: .0125
endstop_pin: ^P8_8
-homing_speed: 50
position_endstop: 0
position_max: 200
+homing_speed: 50
[stepper_y]
step_pin: P8_15
@@ -21,9 +21,9 @@ dir_pin: P8_14
enable_pin: !P9_14
step_distance: .0125
endstop_pin: ^P8_10
-homing_speed: 50
position_endstop: 0
position_max: 200
+homing_speed: 50
[stepper_z]
step_pin: P8_19
@@ -31,7 +31,6 @@ dir_pin: P8_18
enable_pin: !P9_14
step_distance: 0.00025
endstop_pin: ^P9_13
-homing_speed: 5
position_endstop: 0
position_max: 200
diff --git a/config/generic-rambo.cfg b/config/generic-rambo.cfg
index 886394e6..f1cc0389 100644
--- a/config/generic-rambo.cfg
+++ b/config/generic-rambo.cfg
@@ -10,9 +10,9 @@ enable_pin: !PA7
step_distance: .0125
endstop_pin: ^PB6
#endstop_pin: ^PA2
-homing_speed: 50
position_endstop: 0
position_max: 200
+homing_speed: 50
[stepper_y]
step_pin: PC1
@@ -21,9 +21,9 @@ enable_pin: !PA6
step_distance: .0125
endstop_pin: ^PB5
#endstop_pin: ^PA1
-homing_speed: 50
position_endstop: 0
position_max: 200
+homing_speed: 50
[stepper_z]
step_pin: PC2
@@ -32,7 +32,6 @@ enable_pin: !PA5
step_distance: 0.00025
endstop_pin: ^PB4
#endstop_pin: ^PC7
-homing_speed: 5
position_endstop: 0.5
position_max: 200
diff --git a/config/generic-ramps.cfg b/config/generic-ramps.cfg
index 51ad9509..614214d9 100644
--- a/config/generic-ramps.cfg
+++ b/config/generic-ramps.cfg
@@ -11,9 +11,9 @@ enable_pin: !ar38
step_distance: .0125
endstop_pin: ^ar3
#endstop_pin: ^ar2
-homing_speed: 50
position_endstop: 0
position_max: 200
+homing_speed: 50
[stepper_y]
step_pin: ar60
@@ -22,9 +22,9 @@ enable_pin: !ar56
step_distance: .0125
endstop_pin: ^ar14
#endstop_pin: ^ar15
-homing_speed: 50
position_endstop: 0
position_max: 200
+homing_speed: 50
[stepper_z]
step_pin: ar46
@@ -33,7 +33,6 @@ enable_pin: !ar62
step_distance: 0.00025
endstop_pin: ^ar18
#endstop_pin: ^ar19
-homing_speed: 5
position_endstop: 0.5
position_max: 200
diff --git a/config/generic-replicape.cfg b/config/generic-replicape.cfg
index 376bbe9b..4095eace 100644
--- a/config/generic-replicape.cfg
+++ b/config/generic-replicape.cfg
@@ -11,9 +11,9 @@ dir_pin: P8_26
enable_pin: !P9_41
step_distance: .0125
endstop_pin: ^P9_25
-homing_speed: 50
position_endstop: 0
position_max: 200
+homing_speed: 50
[stepper_y]
step_pin: P8_12
@@ -21,9 +21,9 @@ dir_pin: P8_19
enable_pin: !P9_41
step_distance: .0125
endstop_pin: ^P9_23
-homing_speed: 50
position_endstop: 0
position_max: 200
+homing_speed: 50
[stepper_z]
step_pin: P8_13
@@ -31,7 +31,6 @@ dir_pin: P8_14
enable_pin: !P9_41
step_distance: 0.00025
endstop_pin: ^P9_13
-homing_speed: 5
position_endstop: 0
position_max: 200
diff --git a/config/makergear-m2-2012.cfg b/config/makergear-m2-2012.cfg
index 380e0e93..a2b0e89d 100644
--- a/config/makergear-m2-2012.cfg
+++ b/config/makergear-m2-2012.cfg
@@ -9,12 +9,11 @@ dir_pin: !PL1
enable_pin: !PA7
step_distance: .0225
endstop_pin: ^!PB6
-homing_speed: 50.0
-homing_stepper_phases: 32
-homing_endstop_accuracy: .200
-position_min: -0.25
position_endstop: 0.0
position_max: 200
+homing_speed: 50
+homing_stepper_phases: 32
+homing_endstop_accuracy: .200
[stepper_y]
step_pin: PC1
@@ -22,12 +21,11 @@ dir_pin: PL0
enable_pin: !PA6
step_distance: .0225
endstop_pin: ^!PB5
-homing_speed: 50.0
-homing_stepper_phases: 32
-homing_endstop_accuracy: .200
-position_min: -0.25
position_endstop: 0.0
position_max: 250
+homing_speed: 50
+homing_stepper_phases: 32
+homing_endstop_accuracy: .200
[stepper_z]
step_pin: PC2
@@ -35,13 +33,12 @@ dir_pin: !PL2
enable_pin: !PA5
step_distance: .005
endstop_pin: ^!PB4
-homing_speed: 4.0
-homing_retract_dist: 2.0
-homing_stepper_phases: 32
-homing_endstop_accuracy: .050
position_min: 0.1
position_endstop: 0.7
position_max: 200
+homing_retract_dist: 2.0
+homing_stepper_phases: 32
+homing_endstop_accuracy: .070
[extruder]
step_pin: PC3
diff --git a/klippy/stepper.py b/klippy/stepper.py
index 61900a20..1b2841f4 100644
--- a/klippy/stepper.py
+++ b/klippy/stepper.py
@@ -57,8 +57,17 @@ class PrinterHomingStepper(PrinterStepper):
self.position_endstop = config.getfloat('position_endstop')
self.homing_speed = config.getfloat('homing_speed', 5.0, above=0.)
- self.homing_positive_dir = config.getboolean(
- 'homing_positive_dir', False)
+ self.homing_positive_dir = config.getboolean('homing_positive_dir', None)
+ if self.homing_positive_dir is None:
+ axis_len = self.position_max - self.position_min
+ if self.position_endstop <= self.position_min + axis_len / 4.:
+ self.homing_positive_dir = False
+ elif self.position_endstop >= self.position_max - axis_len / 4.:
+ self.homing_positive_dir = True
+ else:
+ raise config.error(
+ "Unable to infer homing_positive_dir in section '%s'" % (
+ config.section,))
self.homing_retract_dist = config.getfloat(
'homing_retract_dist', 5., above=0.)
self.homing_stepper_phases = config.getint(