diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-04-04 12:31:03 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-04-07 13:43:56 -0400 |
commit | c4b1a79db26d2e6bcc43d39822f854256cc30a10 (patch) | |
tree | 4fd3715415874d9c6cfa1e5d6e509ec4f96e8c50 /klippy/cartesian.py | |
parent | 47f12f107d613ce0ccd11b69aee126df24fcb8e7 (diff) | |
download | kutter-c4b1a79db26d2e6bcc43d39822f854256cc30a10.tar.gz kutter-c4b1a79db26d2e6bcc43d39822f854256cc30a10.tar.xz kutter-c4b1a79db26d2e6bcc43d39822f854256cc30a10.zip |
mcu: Pass constant velocity and acceleration directly to mcu_stepper
Rename step_sqrt/step_factor to step_accel/step_const and have them
directly take the velocity and acceleration in millimeters and
seconds. This simplifies the kinematic classes.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/cartesian.py')
-rw-r--r-- | klippy/cartesian.py | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/klippy/cartesian.py b/klippy/cartesian.py index 2dc0df3d..6ec12a5b 100644 --- a/klippy/cartesian.py +++ b/klippy/cartesian.py @@ -99,46 +99,32 @@ class CartKinematics: def move(self, move_time, move): if self.need_motor_enable: self._check_motor_enable(move_time, move) - inv_accel = 1. / move.accel - inv_cruise_v = 1. / move.cruise_v for i in StepList: - if not move.axes_d[i]: + axis_d = move.axes_d[i] + if not axis_d: continue mcu_stepper = self.steppers[i].mcu_stepper mcu_time = mcu_stepper.print_to_mcu_time(move_time) - step_pos = mcu_stepper.commanded_position - inv_step_dist = self.steppers[i].inv_step_dist - step_offset = step_pos - move.start_pos[i] * inv_step_dist - steps = move.axes_d[i] * inv_step_dist - move_step_d = move.move_d / abs(steps) + start_pos = move.start_pos[i] + axis_r = abs(axis_d) / move.move_d + accel = move.accel * axis_r + cruise_v = move.cruise_v * axis_r # Acceleration steps - accel_multiplier = 2.0 * move_step_d * inv_accel if move.accel_r: - #t = sqrt(2*pos/accel + (start_v/accel)**2) - start_v/accel - accel_time_offset = move.start_v * inv_accel - accel_sqrt_offset = accel_time_offset**2 - accel_steps = move.accel_r * steps - count = mcu_stepper.step_sqrt( - mcu_time - accel_time_offset, accel_steps, step_offset - , accel_sqrt_offset, accel_multiplier) - step_offset += count - accel_steps + accel_d = move.accel_r * axis_d + mcu_stepper.step_accel( + mcu_time, start_pos, accel_d, move.start_v * axis_r, accel) + start_pos += accel_d mcu_time += move.accel_t # Cruising steps if move.cruise_r: - #t = pos/cruise_v - cruise_multiplier = move_step_d * inv_cruise_v - cruise_steps = move.cruise_r * steps - count = mcu_stepper.step_factor( - mcu_time, cruise_steps, step_offset, cruise_multiplier) - step_offset += count - cruise_steps + cruise_d = move.cruise_r * axis_d + mcu_stepper.step_const(mcu_time, start_pos, cruise_d, cruise_v) + start_pos += cruise_d mcu_time += move.cruise_t # Deceleration steps if move.decel_r: - #t = cruise_v/accel - sqrt((cruise_v/accel)**2 - 2*pos/accel) - decel_time_offset = move.cruise_v * inv_accel - decel_sqrt_offset = decel_time_offset**2 - decel_steps = move.decel_r * steps - count = mcu_stepper.step_sqrt( - mcu_time + decel_time_offset, decel_steps, step_offset - , decel_sqrt_offset, -accel_multiplier) + decel_d = move.decel_r * axis_d + mcu_stepper.step_accel( + mcu_time, start_pos, decel_d, cruise_v, -accel) |