stepper: Store pointers to step_const and step_delta in PrinterStepper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
fc1d690d75
commit
eecf3b6ea8
|
@ -107,7 +107,7 @@ class CartKinematics:
|
||||||
axis_d = move.axes_d[i]
|
axis_d = move.axes_d[i]
|
||||||
if not axis_d:
|
if not axis_d:
|
||||||
continue
|
continue
|
||||||
mcu_stepper = self.steppers[i].mcu_stepper
|
step_const = self.steppers[i].step_const
|
||||||
move_time = print_time
|
move_time = print_time
|
||||||
start_pos = move.start_pos[i]
|
start_pos = move.start_pos[i]
|
||||||
axis_r = abs(axis_d) / move.move_d
|
axis_r = abs(axis_d) / move.move_d
|
||||||
|
@ -117,19 +117,17 @@ class CartKinematics:
|
||||||
# Acceleration steps
|
# Acceleration steps
|
||||||
if move.accel_r:
|
if move.accel_r:
|
||||||
accel_d = move.accel_r * axis_d
|
accel_d = move.accel_r * axis_d
|
||||||
mcu_stepper.step_const(
|
step_const(move_time, start_pos, accel_d,
|
||||||
move_time, start_pos, accel_d, move.start_v * axis_r, accel)
|
move.start_v * axis_r, accel)
|
||||||
start_pos += accel_d
|
start_pos += accel_d
|
||||||
move_time += move.accel_t
|
move_time += move.accel_t
|
||||||
# Cruising steps
|
# Cruising steps
|
||||||
if move.cruise_r:
|
if move.cruise_r:
|
||||||
cruise_d = move.cruise_r * axis_d
|
cruise_d = move.cruise_r * axis_d
|
||||||
mcu_stepper.step_const(
|
step_const(move_time, start_pos, cruise_d, cruise_v, 0.)
|
||||||
move_time, start_pos, cruise_d, cruise_v, 0.)
|
|
||||||
start_pos += cruise_d
|
start_pos += cruise_d
|
||||||
move_time += move.cruise_t
|
move_time += move.cruise_t
|
||||||
# Deceleration steps
|
# Deceleration steps
|
||||||
if move.decel_r:
|
if move.decel_r:
|
||||||
decel_d = move.decel_r * axis_d
|
decel_d = move.decel_r * axis_d
|
||||||
mcu_stepper.step_const(
|
step_const(move_time, start_pos, decel_d, cruise_v, -accel)
|
||||||
move_time, start_pos, decel_d, cruise_v, -accel)
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ class CoreXYKinematics:
|
||||||
axis_d = axes_d[i]
|
axis_d = axes_d[i]
|
||||||
if not axis_d:
|
if not axis_d:
|
||||||
continue
|
continue
|
||||||
mcu_stepper = self.steppers[i].mcu_stepper
|
step_const = self.steppers[i].step_const
|
||||||
move_time = print_time
|
move_time = print_time
|
||||||
start_pos = move_start_pos[i]
|
start_pos = move_start_pos[i]
|
||||||
axis_r = abs(axis_d) / move.move_d
|
axis_r = abs(axis_d) / move.move_d
|
||||||
|
@ -132,19 +132,17 @@ class CoreXYKinematics:
|
||||||
# Acceleration steps
|
# Acceleration steps
|
||||||
if move.accel_r:
|
if move.accel_r:
|
||||||
accel_d = move.accel_r * axis_d
|
accel_d = move.accel_r * axis_d
|
||||||
mcu_stepper.step_const(
|
step_const(move_time, start_pos, accel_d,
|
||||||
move_time, start_pos, accel_d, move.start_v * axis_r, accel)
|
move.start_v * axis_r, accel)
|
||||||
start_pos += accel_d
|
start_pos += accel_d
|
||||||
move_time += move.accel_t
|
move_time += move.accel_t
|
||||||
# Cruising steps
|
# Cruising steps
|
||||||
if move.cruise_r:
|
if move.cruise_r:
|
||||||
cruise_d = move.cruise_r * axis_d
|
cruise_d = move.cruise_r * axis_d
|
||||||
mcu_stepper.step_const(
|
step_const(move_time, start_pos, cruise_d, cruise_v, 0.)
|
||||||
move_time, start_pos, cruise_d, cruise_v, 0.)
|
|
||||||
start_pos += cruise_d
|
start_pos += cruise_d
|
||||||
move_time += move.cruise_t
|
move_time += move.cruise_t
|
||||||
# Deceleration steps
|
# Deceleration steps
|
||||||
if move.decel_r:
|
if move.decel_r:
|
||||||
decel_d = move.decel_r * axis_d
|
decel_d = move.decel_r * axis_d
|
||||||
mcu_stepper.step_const(
|
step_const(move_time, start_pos, decel_d, cruise_v, -accel)
|
||||||
move_time, start_pos, decel_d, cruise_v, -accel)
|
|
||||||
|
|
|
@ -201,26 +201,23 @@ class DeltaKinematics:
|
||||||
vt_startz = origz
|
vt_startz = origz
|
||||||
|
|
||||||
# Generate steps
|
# Generate steps
|
||||||
mcu_stepper = self.steppers[i].mcu_stepper
|
step_delta = self.steppers[i].step_delta
|
||||||
move_time = print_time
|
move_time = print_time
|
||||||
if accel_d:
|
if accel_d:
|
||||||
mcu_stepper.step_delta(
|
step_delta(move_time, accel_d, move.start_v, accel,
|
||||||
move_time, accel_d, move.start_v, accel,
|
vt_startz, vt_startxy_d, vt_arm_d, movez_r)
|
||||||
vt_startz, vt_startxy_d, vt_arm_d, movez_r)
|
|
||||||
vt_startz += accel_d * movez_r
|
vt_startz += accel_d * movez_r
|
||||||
vt_startxy_d -= accel_d * movexy_r
|
vt_startxy_d -= accel_d * movexy_r
|
||||||
move_time += move.accel_t
|
move_time += move.accel_t
|
||||||
if cruise_d:
|
if cruise_d:
|
||||||
mcu_stepper.step_delta(
|
step_delta(move_time, cruise_d, cruise_v, 0.,
|
||||||
move_time, cruise_d, cruise_v, 0.,
|
vt_startz, vt_startxy_d, vt_arm_d, movez_r)
|
||||||
vt_startz, vt_startxy_d, vt_arm_d, movez_r)
|
|
||||||
vt_startz += cruise_d * movez_r
|
vt_startz += cruise_d * movez_r
|
||||||
vt_startxy_d -= cruise_d * movexy_r
|
vt_startxy_d -= cruise_d * movexy_r
|
||||||
move_time += move.cruise_t
|
move_time += move.cruise_t
|
||||||
if decel_d:
|
if decel_d:
|
||||||
mcu_stepper.step_delta(
|
step_delta(move_time, decel_d, cruise_v, -accel,
|
||||||
move_time, decel_d, cruise_v, -accel,
|
vt_startz, vt_startxy_d, vt_arm_d, movez_r)
|
||||||
vt_startz, vt_startxy_d, vt_arm_d, movez_r)
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
@ -189,29 +189,27 @@ class PrinterExtruder:
|
||||||
decel_d -= extra_decel_d
|
decel_d -= extra_decel_d
|
||||||
|
|
||||||
# Prepare for steps
|
# Prepare for steps
|
||||||
mcu_stepper = self.stepper.mcu_stepper
|
step_const = self.stepper.step_const
|
||||||
move_time = print_time
|
move_time = print_time
|
||||||
|
|
||||||
# Acceleration steps
|
# Acceleration steps
|
||||||
if accel_d:
|
if accel_d:
|
||||||
mcu_stepper.step_const(move_time, start_pos, accel_d, start_v, accel)
|
step_const(move_time, start_pos, accel_d, start_v, accel)
|
||||||
start_pos += accel_d
|
start_pos += accel_d
|
||||||
move_time += accel_t
|
move_time += accel_t
|
||||||
# Cruising steps
|
# Cruising steps
|
||||||
if cruise_d:
|
if cruise_d:
|
||||||
mcu_stepper.step_const(move_time, start_pos, cruise_d, cruise_v, 0.)
|
step_const(move_time, start_pos, cruise_d, cruise_v, 0.)
|
||||||
start_pos += cruise_d
|
start_pos += cruise_d
|
||||||
move_time += cruise_t
|
move_time += cruise_t
|
||||||
# Deceleration steps
|
# Deceleration steps
|
||||||
if decel_d:
|
if decel_d:
|
||||||
mcu_stepper.step_const(
|
step_const(move_time, start_pos, decel_d, decel_v, -accel)
|
||||||
move_time, start_pos, decel_d, decel_v, -accel)
|
|
||||||
start_pos += decel_d
|
start_pos += decel_d
|
||||||
move_time += decel_t
|
move_time += decel_t
|
||||||
# Retraction steps
|
# Retraction steps
|
||||||
if retract_d:
|
if retract_d:
|
||||||
mcu_stepper.step_const(
|
step_const(move_time, start_pos, -retract_d, retract_v, accel)
|
||||||
move_time, start_pos, -retract_d, retract_v, accel)
|
|
||||||
start_pos -= retract_d
|
start_pos -= retract_d
|
||||||
self.extrude_pos = start_pos
|
self.extrude_pos = start_pos
|
||||||
|
|
||||||
|
|
|
@ -12,21 +12,23 @@ class PrinterStepper:
|
||||||
self.name = config.section
|
self.name = config.section
|
||||||
if self.name.startswith('stepper_'):
|
if self.name.startswith('stepper_'):
|
||||||
self.name = self.name[8:]
|
self.name = self.name[8:]
|
||||||
|
self.need_motor_enable = True
|
||||||
self.step_dist = config.getfloat('step_distance', above=0.)
|
# Stepper definition
|
||||||
self.mcu_stepper = pins.setup_pin(
|
self.mcu_stepper = pins.setup_pin(
|
||||||
printer, 'stepper', config.get('step_pin'))
|
printer, 'stepper', config.get('step_pin'))
|
||||||
dir_pin_params = pins.get_printer_pins(printer).parse_pin_desc(
|
dir_pin_params = pins.get_printer_pins(printer).parse_pin_desc(
|
||||||
config.get('dir_pin'), can_invert=True)
|
config.get('dir_pin'), can_invert=True)
|
||||||
self.mcu_stepper.setup_dir_pin(dir_pin_params)
|
self.mcu_stepper.setup_dir_pin(dir_pin_params)
|
||||||
|
self.step_dist = config.getfloat('step_distance', above=0.)
|
||||||
self.mcu_stepper.setup_step_distance(self.step_dist)
|
self.mcu_stepper.setup_step_distance(self.step_dist)
|
||||||
|
self.step_const = self.mcu_stepper.step_const
|
||||||
|
self.step_delta = self.mcu_stepper.step_delta
|
||||||
|
# Enable pin
|
||||||
enable_pin = config.get('enable_pin', None)
|
enable_pin = config.get('enable_pin', None)
|
||||||
self.mcu_enable = None
|
self.mcu_enable = None
|
||||||
if enable_pin is not None:
|
if enable_pin is not None:
|
||||||
self.mcu_enable = pins.setup_pin(printer, 'digital_out', enable_pin)
|
self.mcu_enable = pins.setup_pin(printer, 'digital_out', enable_pin)
|
||||||
self.mcu_enable.setup_max_duration(0.)
|
self.mcu_enable.setup_max_duration(0.)
|
||||||
self.need_motor_enable = True
|
|
||||||
def _dist_to_time(self, dist, start_velocity, accel):
|
def _dist_to_time(self, dist, start_velocity, accel):
|
||||||
# Calculate the time it takes to travel a distance with constant accel
|
# Calculate the time it takes to travel a distance with constant accel
|
||||||
time_offset = start_velocity / accel
|
time_offset = start_velocity / accel
|
||||||
|
|
Loading…
Reference in New Issue