aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/cartesian.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-10-25 21:05:31 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-10-31 11:06:19 -0400
commitf0cefebff7c9077dd5f39a9d265cada04b76e6b6 (patch)
treef37f754cd2fd8a3d60e9e51dcb16c84d296c7fc6 /klippy/cartesian.py
parent2904a0bbac514bcde6b758ba002bb1e32a28106d (diff)
downloadkutter-f0cefebff7c9077dd5f39a9d265cada04b76e6b6.tar.gz
kutter-f0cefebff7c9077dd5f39a9d265cada04b76e6b6.tar.xz
kutter-f0cefebff7c9077dd5f39a9d265cada04b76e6b6.zip
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>
Diffstat (limited to 'klippy/cartesian.py')
-rw-r--r--klippy/cartesian.py12
1 files 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