Commit Graph

56 Commits

Author SHA1 Message Date
Kevin O'Connor 4d48c111d8 cartesian: Initial support for dual carriages
Add support for additional carriages on cartesian printers.  This is
used by some printers to handle multiple extruders.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-03-09 10:26:21 -05:00
Kevin O'Connor 1a67902858 homing_override: Allow moves prior to homing an axis
Add support for disabling homing checks via the homing_override
mechanism.  This may be useful to move an axis prior to homing it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor ce9db609ad probe: Initial support for Z-Probe hardware
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor 1d21bf66c6 homing: Handle speed rounding when homing speed greater than max_velocity
Commit 002dc0df added rounding to the homing speed, but it did not
work if the configured homing speed was less than the printer's
maximum velocity.  Move the speed rounding from stepper.py to
homing.py and make sure the rounded speed is less than the maximum
speed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-20 14:41:20 -05:00
Kevin O'Connor f6d4284d5c homing: Directly interact with the kinematic class on query_endstops()
Move the query_endstop logic out of toolhead.py and into homing.py.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 19:13:54 -05:00
Kevin O'Connor 7785d3a87d homing: Pass list of endstops (not steppers) to the homing code
The homing code wants the list of endstops to enable during a homing
operation - it's confusing to pass the steppers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 18:49:14 -05:00
Kevin O'Connor 8c2fa2e2d6 stepper: Support for multiple steppers controlling a single axis
Allow multiple steppers to be defined for a single cartesian axis.
This adds support for dual-z setups.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-11-18 17:37:04 -05:00
Kevin O'Connor 38643f52c9 stepper: Add get_endstops() / set_position wrappers
Add wrappers around mcu_endstop and mcu_stepper so that the kinematic
classes do not need to directly access these low-level classes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-11-18 17:36:45 -05:00
Kevin O'Connor eecf3b6ea8 stepper: Store pointers to step_const and step_delta in PrinterStepper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-11-18 17:29:23 -05:00
Kevin O'Connor aaeda540b6 stepper: Calculate the stepper name directly from the config section
There is no need to pass the name to the PrinterStepper class as it
can determine the name itself.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-11-18 17:29:22 -05:00
Kevin O'Connor cc7c99a4a4 cartesian: Fix min_stop_interval calculation error
It is possible to have an acceleration greater than max_z_accel on
XY+Z moves.  That needs to be taken into account when calculating the
min_stop_interval.  This prevents spurious "No next step" MCU errors.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-12 01:16:11 -04:00
Kevin O'Connor ce9523fb90 gcode: Report the raw MCU position from the M114 command
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-03 22:03:52 -04:00
Kevin O'Connor 857eb01bfa homing: Move query_endstop() code from kinematic classes to homing.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-19 17:25:42 -04:00
Kevin O'Connor a100f174f9 mcu: Pass print_time directly to MCU calls
Now that the print_time is always synchronized with the mcu_time,
there is no longer a need to track mcu_time as a separate quantity.
Eliminate references to mcu_time from the code and pass print_time
directly in its place.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-19 17:25:42 -04:00
Kevin O'Connor 7a81bfc4a4 toolhead: Eliminate set_max_jerk() from kinematic classes
Allow the kinematic classes to query the max velocity, max accel, and
max halt velocity from the toolhead class instead of having the
toolhead class call into the kinematic classes with those values.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-03 15:45:04 -04:00
Kevin O'Connor 002dc0dfaf stepper: Adjust homing_speed so that it's an even number of ticks per step
Adjust the configured homing speed so that it always results in a
speed that is an even number of mcu ticks per step.  This ensures that
the code can always get good step compression during homing, which is
important as the entire homing operation must be able to fit within
the mcu's move queue.  This fixes some "move queue empty" mcu shutdown
errors that could occur when the Z step distance was an unusual size.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-29 18:00:17 -04:00
Kevin O'Connor 143b7cccf4 stepper: Separate out homing code to its own PrinterHomingStepper class
Keep the homing code separate from the main stepper class.  This makes
it easier to verify the correct config parameters are provided.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-24 13:54:46 -04:00
Kevin O'Connor 7b03b04c78 klippy: Support minimum/maximum value checks on configuration variables
Verify that numeric parameters are in a sane range when reading the
config.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-11 11:42:55 -04:00
Kevin O'Connor 98add22891 stepcompress: Merge stepcompress_push_accel() and stepcompress_push_const()
It's not necessary to have separate C functions for constant
acceleration and constant velocity as constant velocity can be
obtained by using a constant acceleration of zero.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 14:43:25 -04:00
Kevin O'Connor e4153a536f mcu: Change mcu_stepper.set_position() to take a location in millimeters
Update the set_position() method to convert from millimeters to
absolute step position.

Also, update PrinterStepper.get_homed_offset() and
mcu_stepper.get_commanded_position() to return millimeters.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 13:44:17 -04:00
Kevin O'Connor c4b1a79db2 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>
2017-04-07 13:43:56 -04:00
Kevin O'Connor d21b9280f0 klippy: Eliminate high-level build_config phase
Now that the mcu objects can be created prior to connecting to the
mcu, it is no longer necessary to separate the init and build_config
phases in the high-level code.  Move the mcu objection creation from
the build_config phase to the init phase and eliminate the
build_config phase.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-13 00:38:17 -04:00
Kevin O'Connor c87c090264 extruder: Calculate sane defaults for extrude only velocity and accel
Instead of requiring the user enter velocity and accel parameters for
extrude only moves, calculate sane defaults from the printer's maximum
velocity and accel.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-01-03 18:18:30 -05:00
Kevin O'Connor 89f5452ddb gcode: Rework homing to use greenlets
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-09 17:09:51 -05:00
Kevin O'Connor a6de1db94d gcode: Rework endstop query to use greenlets
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-09 17:09:51 -05:00
Kevin O'Connor 35428f2e04 cartesian: Make it clear which methods of CartKinematics are internal
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-08 18:14:46 -05:00
Kevin O'Connor c49d3fdb17 toolhead: Specify maximum acceleration and velocity in toolhead class
Change the config file so the maximum accel and velocity are specified
in the "printer" section instead of the individual "stepper" sections.
The underlying code limits the velocity and accel of the toolhead
relative to the print object, so it makes sense to configure the
system that was as well.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-01 18:17:54 -05:00
Kevin O'Connor 9755182adf homing: Check homing distance to verify endstop trigger after retract
Instead of checking the endstop trigger directly after a retract move,
verify some distance is traveled during the following homing
operation.  This reduces the amount of synchronization between mcu and
host during homing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-28 11:23:26 -05:00
Kevin O'Connor 1e1364c3d4 mcu: Store the stepper position in the mcu_stepper class
Move the storage of the stepper location from the kinematic classes to
the low-level mcu_stepper class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-19 11:34:42 -05:00
Kevin O'Connor ab1972d1cf homing: Verify the endstops are no longer triggered after retract move
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-18 14:17:53 -05:00
Kevin O'Connor 4f30dce64f homing: Add EndstopMoveError wrapper around EndstopError
Allow an EndstopError to be raised without a destination position.
Introduce EndstopMoveError wrapper so that current callers can
continue to pass in a move destination.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-18 14:17:53 -05:00
Kevin O'Connor 2b5b899d35 homing: Direct stepper phase detection from kinematic classes
Change the scheduling of the final homed position (which takes into
account the stepper phases) so that it is scheduled from the kinematic
classes instead of from the toolhead class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-18 14:04:10 -05:00
Kevin O'Connor 781cf608d7 homing: Create Homing class from gcode
Create the Homing class in the gcode handler instead of in the
kinematic classes.  This will make it easier to pass error messages
back to the user.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-18 14:04:09 -05:00
Kevin O'Connor 9e1059afb4 homing: Create QueryEndstops class from gcode
Create the QueryEndstops in the gcode handler instead of in the
kinematic classes.  This simplifies the gcode handler as it can
directly register its response callback.

Also, store the stepper name in the stepper class.  Also, propagate
the print_time of the query request to the mcu_endstop class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-18 14:04:09 -05:00
Kevin O'Connor 5a1ec817d4 stepper: Check if the motor needs to be enabled in the kinematic classes
Check for motor enable in the kinematic classes so it doesn't need to
be checked on every move.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-14 13:40:35 -05:00
Kevin O'Connor 7554c7f694 stepcompress: Do all step rounding in C code
Commits f0cefebf and 8f331f08 changed the way the code determined what
steps to take on fractional steps.  Unfortunately, it was possible in
some situations for the C code to round differently from the python
code which could result in warnings and lost steps.

Change the code so that all fractional step handling is done in the C
code.  Implementing the step rounding logic in one location avoids any
conflicts.

In order to efficiently handle the step rounding in the C code, the C
code has also been extended to directly send the "set_next_step_dir"
command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-13 18:29:45 -05:00
Kevin O'Connor afecf7ce36 stepper: Default to a high direction pin meaning positive direction
Invert the default meaning of the stepper direction pin.  Instead of
treating a low value as position motion, treat a high value as
positive motion.  This matches what other firmwares do, and it matches
what common stepper motor drivers document.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-08 10:39:32 -05:00
Kevin O'Connor f0cefebff7 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>
2016-10-31 11:06:19 -04:00
Kevin O'Connor 2904a0bbac cartesian: Rename step_dist to move_step_d
Don't use step_dist for the "distance along the line of movement per
step" as it's too similar to the stepper.step_dist variable.  Use the
name "move_step_d" instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-10-31 11:05:52 -04:00
Kevin O'Connor 6a96e83ea9 toolhead: Store both the start and end position in the Move class
Store the start position (in addition to the existing end position) in
the Move class.  The start position can be useful to the kinematic
classes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-10-25 19:19:29 -04:00
Kevin O'Connor 977aabe038 stepper: Return homing offset in steps instead of an absolute position
Rename get_homed_position() to get_homed_offset() and return the
endstop position delta in steps instead of an absolute position
relative to position_endstop.  The conversion to absolute positions
can be dependent on the type of kinematics in use, so is inappropriate
to do in the low level stepper.py code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-10-13 10:09:56 -04:00
Kevin O'Connor b53da365a1 cartesian: Enforce endstop min and max boundaries
Verify that each move command is within range of the configured
minimum and maximum for each axis.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-30 21:36:51 -04:00
Kevin O'Connor 275b386856 toolhead: Allow kinematics class to verify the move prior to queuing it
Introduce a check_move() method in the extruder and cartesian
kinematic classes.  This allows the lower level classes to verify the
contents of the move prior to queing that move.

The speed and acceleration handling for special Z and extrude only
moves are also moved from the generic toolhead class to the low-level
classes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-30 21:27:46 -04:00
Kevin O'Connor 0685802cb8 homing: Support querying the current status of endstops
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-22 11:29:27 -04:00
Kevin O'Connor 0824d32319 cartesian: Minor change to clarify end stop homing direction code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-09-15 12:20:16 -04:00
Kevin O'Connor e52113a319 mcu: convert stepper, endstop, and digital_out to take mcu_time
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-24 16:42:25 -04:00
Kevin O'Connor 654546e338 stepper: Support stepper phase adjustments when homing
Add support for enhancing the precision of endstop switches by also
inspecting the phase of the stepper motor when the endstop triggers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-28 11:22:28 -04:00
Kevin O'Connor 92f81d51f4 homing: Move low-level coordinate manipulation to kinematic class
Rework the code so that the kinematic class (currently just
cartesian.py) has more control over the homing process.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-25 23:47:30 -04:00
Kevin O'Connor 589017a3d6 stepper: Have caller calculate max jerk velocity
Allow the owner of the stepper object to cacluate the maximum step
jerk velocity.  This is used to ensure there is no communication error
between mcu and host.

Disable checking of jerk velocity for extruder stepper motors.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-22 15:42:18 -04:00
Kevin O'Connor af99ab1645 extruder: Create a new class and python file to track the printer extruder
Create a new python file (extruder.py) to control the extruder heater
and stepper motors.  This separates the extruder control logic from
the cartesian robot code - making it easier to customize both the
kinematic control of the robot as well as the extruder.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-10 22:49:02 -04:00