quad_gantry_level: Add additional comments on how leveling works

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-06-18 13:05:42 -04:00
parent c69527e2b0
commit 6c872c71a7
1 changed files with 41 additions and 18 deletions

View File

@ -6,6 +6,22 @@
import logging import logging
from . import probe, z_tilt from . import probe, z_tilt
# Leveling code for XY rails that are controlled by Z steppers as in:
#
# Z stepper1 ----> O O <---- Z stepper2
# | * <-- probe1 probe2 --> * |
# | |
# | | <--- Y2 rail
# Y1 rail -----> | |
# | |
# |=============================|
# | ^ |
# | | |
# | X rail --/ |
# | |
# | * <-- probe0 probe3 --> * |
# Z stepper0 ----> O O <---- Z stepper3
class QuadGantryLevel: class QuadGantryLevel:
def __init__(self, config): def __init__(self, config):
self.printer = config.get_printer() self.printer = config.get_printer()
@ -48,29 +64,36 @@ class QuadGantryLevel:
" ".join(["%s: %.6f" % (z_id, z_positions[z_id]) " ".join(["%s: %.6f" % (z_id, z_positions[z_id])
for z_id in range(len(z_positions))])) for z_id in range(len(z_positions))]))
self.gcode.respond_info(points_message) self.gcode.respond_info(points_message)
p1 = [positions[0][0] + offsets[0],z_positions[0]] # Calculate slope along X axis between probe point 0 and 3
p2 = [positions[1][0] + offsets[0],z_positions[1]] ppx0 = [positions[0][0] + offsets[0], z_positions[0]]
p3 = [positions[2][0] + offsets[0],z_positions[2]] ppx3 = [positions[3][0] + offsets[0], z_positions[3]]
p4 = [positions[3][0] + offsets[0],z_positions[3]] slope_x_pp03 = self.linefit(ppx0, ppx3)
f1 = self.linefit(p1,p4) # Calculate slope along X axis between probe point 1 and 2
f2 = self.linefit(p2,p3) ppx1 = [positions[1][0] + offsets[0], z_positions[1]]
logging.info("quad_gantry_level f1: %s, f2: %s" % (f1,f2)) ppx2 = [positions[2][0] + offsets[0], z_positions[2]]
slope_x_pp12 = self.linefit(ppx1, ppx2)
logging.info("quad_gantry_level f1: %s, f2: %s"
% (slope_x_pp03, slope_x_pp12))
# Calculate gantry slope along Y axis between stepper 0 and 1
a1 = [positions[0][1] + offsets[1], a1 = [positions[0][1] + offsets[1],
self.plot(f1,self.gantry_corners[0][0])] self.plot(slope_x_pp03, self.gantry_corners[0][0])]
a2 = [positions[1][1] + offsets[1], a2 = [positions[1][1] + offsets[1],
self.plot(f2,self.gantry_corners[0][0])] self.plot(slope_x_pp12, self.gantry_corners[0][0])]
slope_y_s01 = self.linefit(a1, a2)
# Calculate gantry slope along Y axis between stepper 2 and 3
b1 = [positions[0][1] + offsets[1], b1 = [positions[0][1] + offsets[1],
self.plot(f1,self.gantry_corners[1][0])] self.plot(slope_x_pp03, self.gantry_corners[1][0])]
b2 = [positions[1][1] + offsets[1], b2 = [positions[1][1] + offsets[1],
self.plot(f2,self.gantry_corners[1][0])] self.plot(slope_x_pp12, self.gantry_corners[1][0])]
af = self.linefit(a1,a2) slope_y_s23 = self.linefit(b1, b2)
bf = self.linefit(b1,b2) logging.info("quad_gantry_level af: %s, bf: %s"
logging.info("quad_gantry_level af: %s, bf: %s" % (af,bf)) % (slope_y_s01, slope_y_s23))
# Calculate z height of each stepper
z_height = [0,0,0,0] z_height = [0,0,0,0]
z_height[0] = self.plot(af,self.gantry_corners[0][1]) z_height[0] = self.plot(slope_y_s01, self.gantry_corners[0][1])
z_height[1] = self.plot(af,self.gantry_corners[1][1]) z_height[1] = self.plot(slope_y_s01, self.gantry_corners[1][1])
z_height[2] = self.plot(bf,self.gantry_corners[1][1]) z_height[2] = self.plot(slope_y_s23, self.gantry_corners[1][1])
z_height[3] = self.plot(bf,self.gantry_corners[0][1]) z_height[3] = self.plot(slope_y_s23, self.gantry_corners[0][1])
ainfo = zip(["z","z1","z2","z3"], z_height[0:4]) ainfo = zip(["z","z1","z2","z3"], z_height[0:4])
apos = " ".join(["%s: %06f" % (x) for x in ainfo]) apos = " ".join(["%s: %06f" % (x) for x in ainfo])