Skip to content

Commit 06dcc04

Browse files
committed
Clarify that mechanical_advantage should be manually folded into rotation_distance
1 parent 8e87689 commit 06dcc04

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

docs/Config_Reference.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,9 @@ rotation_distance:
795795
# moves towards the cable winch for each full rotation of the
796796
# stepper motor. This parameter must be provided.
797797
# For buildup compensation, set this to the effective distance at the
798-
# origin, which is 2*pi times the effective spool radius.
798+
# origin. If winch_mechanical_advantage is used, divide the physical
799+
# origin circumference by that factor (for example, a 2:1 tackle halves
800+
# the configured value for the same spool radius).
799801
# There is no separate spool_radius config option; Klipper derives the
800802
# internal radius from rotation_distance.
801803
# If the spool itself is geared, use the regular stepper gear_ratio

test/klippy/test_winch.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def spool_lengths(self, helper, pos):
9494
def expected_motor_to_line_pos(self, motor_pos, rotation_distance,
9595
steps_per_rotation, buildup_factor,
9696
mechanical_advantage=1):
97-
radius = rotation_distance / (2.0 * math.pi)
97+
radius = rotation_distance * float(mechanical_advantage) / (2.0 * math.pi)
9898
steps_per_mm = steps_per_rotation / rotation_distance
9999
k2 = -float(buildup_factor) * float(mechanical_advantage)
100100
if abs(k2) <= 1.0e-12 or steps_per_mm <= 0.0:
@@ -159,6 +159,23 @@ def test_buildup_model_matches_closed_form_with_gearing(self):
159159
motor_pos, rotation_distance, steps_per_rotation, buildup, 1)
160160
self.assertAlmostEqual(actual, expected, places=12)
161161

162+
def test_buildup_model_scales_with_mechanical_advantage(self):
163+
buildup = 0.6366197723675814
164+
rotation_distance = 123.10
165+
steps_per_rotation = 3200.0 * 12.75
166+
helper = self.build_helper(((0.0, 0.0, 0.0),),
167+
mover_weight=0.0,
168+
spring=0.0,
169+
target=0.0,
170+
buildup_factor=buildup,
171+
mechanical_advantage=[2])
172+
helper.set_spool_params(0, rotation_distance, steps_per_rotation)
173+
motor_pos = 18.5
174+
actual = helper.motor_to_line_pos(0, motor_pos)
175+
expected = self.expected_motor_to_line_pos(
176+
motor_pos, rotation_distance, steps_per_rotation, buildup, 2)
177+
self.assertAlmostEqual(actual, expected, places=12)
178+
162179
def test_four_anchor_near_singularity(self):
163180
helper = self.build_helper(FOUR_ANCHORS_PROBLEM)
164181
origin_lengths, _, _ = self.spool_lengths(helper, (0.0, 0.0, 0.0))

0 commit comments

Comments
 (0)