aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/mcu.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-04-04 21:59:28 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-04-07 14:43:48 -0400
commitdf42b0d1ac0b303025c8762fa727d79bc01a28a3 (patch)
treeab5ae5786d01b7a7c73866cc4380d27f34349fee /klippy/mcu.py
parent98add22891d66d0a9ce21d35b750d20d3671382e (diff)
downloadkutter-df42b0d1ac0b303025c8762fa727d79bc01a28a3.tar.gz
kutter-df42b0d1ac0b303025c8762fa727d79bc01a28a3.tar.xz
kutter-df42b0d1ac0b303025c8762fa727d79bc01a28a3.zip
stepcompress: Pass delta velocity and acceleration directly to C code
Update the C delta kinematic code to take velocity and acceleration directly in step distances and clock ticks. This simplifies the mcu.py python code as it only needs to do unit and axis conversion. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/mcu.py')
-rw-r--r--klippy/mcu.py35
1 files changed, 13 insertions, 22 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py
index 741ac0aa..26e98d39 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -130,36 +130,27 @@ class MCU_stepper:
self._commanded_pos += count
def step_delta_const(self, mcu_time, start_pos, dist, cruise_v
, height_base, closestxy_d, closest_height2, movez_r):
- mcu_freq = self._mcu_freq
- step_dist = self._step_dist
- height = self._commanded_pos*step_dist - height_base
- if dist < 0:
- dist = -dist
- step_dist = -step_dist
+ inv_step_dist = self._inv_step_dist
+ height = self._commanded_pos - height_base * inv_step_dist
count = self._ffi_lib.stepcompress_push_delta_const(
- self._stepqueue, mcu_time * mcu_freq, dist, -start_pos
- , mcu_freq / cruise_v, step_dist
- , height, closestxy_d, closest_height2, movez_r)
+ self._stepqueue, mcu_time * self._mcu_freq,
+ -start_pos * inv_step_dist, dist * inv_step_dist,
+ cruise_v * self._velocity_factor,
+ height, closestxy_d * inv_step_dist,
+ closest_height2 * inv_step_dist**2, movez_r)
if count == STEPCOMPRESS_ERROR_RET:
raise error("Internal error in stepcompress")
self._commanded_pos += count
def step_delta_accel(self, mcu_time, start_pos, dist, start_v, accel
, height_base, closestxy_d, closest_height2, movez_r):
inv_step_dist = self._inv_step_dist
- mcu_freq = self._mcu_freq
- inv_accel = 1. / accel
- time_offset = start_v * inv_accel * mcu_freq
- accel_offset = start_v**2 * 0.5 * inv_accel
- step_dist = self._step_dist
- height = self._commanded_pos*step_dist - height_base
- if dist < 0:
- dist = -dist
- step_dist = -step_dist
- clock = mcu_time * mcu_freq - time_offset
+ height = self._commanded_pos - height_base * inv_step_dist
count = self._ffi_lib.stepcompress_push_delta_accel(
- self._stepqueue, clock, dist, accel_offset - start_pos
- , 2. * inv_accel * mcu_freq**2, step_dist
- , height, closestxy_d, closest_height2, movez_r)
+ self._stepqueue, mcu_time * self._mcu_freq,
+ -start_pos * inv_step_dist, dist * inv_step_dist,
+ start_v * self._velocity_factor, accel * self._accel_factor,
+ height, closestxy_d * inv_step_dist,
+ closest_height2 * inv_step_dist**2, movez_r)
if count == STEPCOMPRESS_ERROR_RET:
raise error("Internal error in stepcompress")
self._commanded_pos += count