From f0cefebff7c9077dd5f39a9d265cada04b76e6b6 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 25 Oct 2016 21:05:31 -0400 Subject: [PATCH] cartesian.py: Determine start step offset using last commanded position The existing code calculates the number of steps in a move and then spreads them out evenly throughout that move. Change the code so that step timing is based on where the head is commanded to be relative to the axis step locations. This makes the timing more accurate - in particular the axis velocities will be more accurate during cornering introduced by the lookahead code. It also results in slightly smoother stepper motion which results in better step compression. Signed-off-by: Kevin O'Connor --- klippy/cartesian.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/klippy/cartesian.py b/klippy/cartesian.py index c3a34db7..16db25d2 100644 --- a/klippy/cartesian.py +++ b/klippy/cartesian.py @@ -97,20 +97,22 @@ class CartKinematics: inv_accel = 1. / move.accel inv_cruise_v = 1. / move.cruise_v for i in StepList: - new_step_pos = int( - move.end_pos[i]*self.steppers[i].inv_step_dist + 0.5) - steps = new_step_pos - self.stepper_pos[i] - if not steps: + inv_step_dist = self.steppers[i].inv_step_dist + new_step_pos = int(move.end_pos[i]*inv_step_dist + 0.5) + step_pos = self.stepper_pos[i] + if new_step_pos == step_pos: continue self.stepper_pos[i] = new_step_pos + steps = move.axes_d[i] * inv_step_dist + step_offset = step_pos - move.start_pos[i] * inv_step_dist + 0.5 sdir = 0 if steps < 0: sdir = 1 steps = -steps + step_offset = 1. - step_offset mcu_time, so = self.steppers[i].prep_move(move_time, sdir) move_step_d = move.move_d / steps - step_offset = 0.5 # Acceleration steps #t = sqrt(2*pos/accel + (start_v/accel)**2) - start_v/accel