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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-10-25 21:05:31 -04:00
parent 2904a0bbac
commit f0cefebff7
1 changed files with 7 additions and 5 deletions

View File

@ -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