aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/toolhead.py
Commit message (Collapse)AuthorAgeFilesLines
* extruder: Add initial support for multi-extrudersKevin O'Connor2017-06-091-7/+16
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Allow each module to define their config sectionsKevin O'Connor2017-06-091-0/+3
| | | | | | | | Create add_printer_objects() functions in the fan, heater, extruder, and toolhead modules. Create the necessary printer component objects from this call instead of placing the code directly in klippy.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Don't log stats when the printer is idleKevin O'Connor2017-04-141-5/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Support minimum/maximum value checks on configuration variablesKevin O'Connor2017-04-111-10/+17
| | | | | | | Verify that numeric parameters are in a sane range when reading the config. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* corexy: Initial corexy kinematic implementationKevin O'Connor2017-04-031-1/+2
| | | | | | Add initial support for corexy kinematics. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Increase the motor_off_time default to 10 minutesKevin O'Connor2017-03-301-1/+1
| | | | | | | Increase the default motor_off_time from 1 minute to 10 minutes. The small value is a common source of confusion. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Don't raise exception from force_shutdownKevin O'Connor2017-03-161-3/+6
| | | | | | | | | Catch and ignore any exceptions when trying to shutdown the printer in toolhead.force_shutdown() - there's a good chance an exception will be raised as this method is often called after an invalid internal state is found. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Eliminate high-level build_config phaseKevin O'Connor2017-03-131-2/+0
| | | | | | | | | | 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>
* toolhead: Fix error in lookahead logicKevin O'Connor2017-02-201-11/+11
| | | | | | | | | | | | | | Commit c24b7a7e reworked the way lookahead was done and it introduced a bug when a full acceleration move is immiedietly followed by a full deceleration move. In that situation, depending on when the lookahead queue was flushed, it was possible to call move.move() without calling move.set_junction(). This resulted in a "Move instance has no attribute 'accel_t'" internal error. Simplify and fix the logic for checking full accel moves followed by full decel moves. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rework lookahead flush to be more stable during high cpuKevin O'Connor2017-02-121-20/+48
| | | | | | | | | | | | | | | | | Change the lookahead queue so that it attempts to buffer at least buffer_time_high amount of moves when first starting a print. This helps ensure the buffer is normally always full. If the buffer falls below buffer_time_low then it is either due to the end of a print or because octoprint/klippy is unable to keep up. Change the code so that in this case the lookahead queue will attempt to gather buffer_time_high amount of moves before restarting movement. Update the default buffer_time_low to 1 second and buffer_time_high to 2 seconds. With the above changes a smaller buffer_time_high and a larger buffer_time_low are more practical. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Flush lookahead buffer by timeKevin O'Connor2017-02-121-7/+12
| | | | | | | | | Use a minimum time window as a heuristic for determining when to try to lazily flush the lookahead buffer. In the common case this will result in more moves processed for each flush and thus reduce the overall cost of the lookahead processing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Separate motor off timer from main flush timerKevin O'Connor2017-02-121-24/+38
| | | | | | | Move the motor off time checking to its own code. This simplifies the main flush handler. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Increase maximum stepper halt velocityKevin O'Connor2017-02-121-1/+3
| | | | | | | | | | | | | Do a better job of calculating the maximum halt velocity for the stepper motors. The maximum cornering velocity is related to both the maximum acceleration and the junction_deviation, so both should be in the formula. Tests show that "math.sqrt(8. * self.junction_deviation * self.max_accel)" very closely fits the maximum on cartesian robots. This fixes potential "no next step" shutdowns that could occur on some print moves. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* reactor: Use the system monotonic clock instead of the normal system clockKevin O'Connor2017-02-061-6/+7
| | | | | | | | | | | | | The normal system clock can have sudden jumps if the system clock is changed. Use the system monotonic clock to avoid these sudden changes in time. It appears the Raspbian OS (which is used by OctoPi) is setup to update the system clock upon network connectivity. This could cause sudden system clock changes which could lead to Klippy processing errors. Using the monotonic clock eliminates these issues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Introduce "smoothed" acceleration during lookaheadKevin O'Connor2017-02-061-9/+41
| | | | | | | | | Update the lookahead code to track both normal toolhead acceleration as well as a pseudo acceleration to the point of deceleration. This reduces the top speed of small zig-zag moves and it reduces printer vibration during these moves. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Remove unneeded forward pass in MoveQueue.flush()Kevin O'Connor2017-02-061-10/+10
| | | | | | | Simplify the code now that the extruder lookahead is separate from the main lookahead code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Remove the do_calc_junction flagKevin O'Connor2017-02-061-23/+14
| | | | | | | | It is not necessary to track the do_calc_junction flag as it can just as easily be determined at the top of the calc_junction() method. This simplifies the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Do extruder lookahead based on time instead of corneringKevin O'Connor2017-02-061-1/+1
| | | | | | | | | When calculating the extruder lookahead, determine how far to lookahead by the amount of elapsed time each move takes. This makes the extruder lookahead code more flexible as it is no longer limited to the next immediate cornering moves. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Move extruder specific lookahead into extruder classKevin O'Connor2017-02-061-44/+37
| | | | | | | | Instead of calculating min/max_corner_v in the toolhead class, calculate it in the extruder class. This keeps the extruder specific code together. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Make sure max_corner_v2 is fully calculated on a lazy flushKevin O'Connor2017-01-161-3/+7
| | | | | | | | | | | | Make sure max_corner_v2 is fully calculated before proactively flushing moves from the lookahead queue. Without this, some moves would do unnecessary pressure advance during cornering. Also, handle the min/max_corner_v2 calculations correctly in the rare case where a move that does only acceleration is immediately followed by a move that does only deceleration. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Change variables to use suffix "_v2" instead of prefix "junction_"Kevin O'Connor2017-01-161-42/+38
| | | | | | | | The junction speeds are tracked in velocity squared - introduce the common suffix "_v2" to track that instead of using a prefix of "junction_". Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Clear do_calc_junction if using non-default accelKevin O'Connor2017-01-141-6/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Change cornering_min/max variable name to junction_corner_min/maxKevin O'Connor2017-01-101-7/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Calculate sane defaults for extrude only velocity and accelKevin O'Connor2017-01-031-1/+4
| | | | | | | | 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>
* toolhead: Also call reset_print_time() on force_shutdown()Kevin O'Connor2016-12-281-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Add support for M400 commandKevin O'Connor2016-12-281-0/+5
| | | | | | Add ability to fully stall the input until all moves are complete. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Don't call into kinematic class on extrude only movesKevin O'Connor2016-12-281-4/+6
| | | | | | | | Add a is_kinematic_move flag to the Move class and clear it on extrude only moves. Don't call the kinematic check_move() or move() methods for extrude only moves. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rework toolhead stalling to use greenletsKevin O'Connor2016-12-091-8/+21
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rework endstop query to use greenletsKevin O'Connor2016-12-091-2/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Specify maximum acceleration and velocity in toolhead classKevin O'Connor2016-12-011-1/+3
| | | | | | | | | | 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>
* gcode: Support parsing of "extended" gcode commandsKevin O'Connor2016-11-301-1/+1
| | | | | | | | | | Support human readable commands (eg, "help"). Add a "help" command to list these extended commands. Also, add support for declaring command aliases, command help, and command availability next to the handlers themselves. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Add ConfigWrapper.getchoice methodKevin O'Connor2016-11-301-2/+1
| | | | | | | | Add helper function that ensures a config option is one of several choices. This helps ensure that a proper error is raised if an invalid choice is made. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Direct stepper phase detection from kinematic classesKevin O'Connor2016-11-181-7/+0
| | | | | | | | 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>
* homing: Create Homing class from gcodeKevin O'Connor2016-11-181-6/+5
| | | | | | | | 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>
* homing: Create QueryEndstops class from gcodeKevin O'Connor2016-11-181-3/+2
| | | | | | | | | | | 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>
* delta: Initial support for linear delta kinematicsKevin O'Connor2016-11-141-2/+5
| | | | | | This adds support for delta based robots. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Support calculation of cornering minimum and maximumKevin O'Connor2016-11-051-21/+25
| | | | | | | | | | | | | | Calculate the next "cornering" minimum and maximum for each move. The "cornering minimum" is the lowest speed the head will reach immediately after this move (with no interleaving acceleration or cruising). The "cornering maximum" is the maximum speed the head will reach after the cornering minimum (with no interleaving deceleration or cruising). These cornering calculations will be helpful in the extruder "pressure advance" code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Simplify calculation of junction_cruiseKevin O'Connor2016-11-051-6/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Calculate maximum junction start when adding movesKevin O'Connor2016-11-051-12/+9
| | | | | | | Take into account the maximum possible start speed of a move when calculating junction_start_max. This simplifies the lookahead logic. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Store both the start and end position in the Move classKevin O'Connor2016-10-251-10/+12
| | | | | | | | 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>
* toolhead: Allow kinematics class to verify the move prior to queuing itKevin O'Connor2016-09-301-31/+28
| | | | | | | | | | | | 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>
* homing: Support querying the current status of endstopsKevin O'Connor2016-09-221-0/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Force a firmware shutdown on an unhandled exceptionKevin O'Connor2016-09-221-19/+29
| | | | | | | Check for unhandled exceptions and force the MCU to shutdown in that case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Support stepper phase adjustments when homingKevin O'Connor2016-07-281-1/+9
| | | | | | | 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>
* homing: Move low-level coordinate manipulation to kinematic classKevin O'Connor2016-07-251-2/+2
| | | | | | | 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>
* toolhead: Limit lookahead optimization to moves with similar extrude ratiosKevin O'Connor2016-07-221-3/+12
| | | | | | | | Only skip acceleration between moves if both moves perform a similar amount of extrusion. This ensures the extruder has sufficient time to accelerate to and from each extrude move. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Add some comments to acceleration codeKevin O'Connor2016-07-161-6/+18
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Create a new class and python file to track the printer extruderKevin O'Connor2016-07-101-1/+5
| | | | | | | | | 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>
* toolhead: Avoid using a dummy_move for an empty move_queueKevin O'Connor2016-07-101-11/+3
| | | | | | | | | Explicitly check for when the move_queue is empty and only call move.calc_junction() when there is a previous move. This avoids the need to create a dummy "sentinal" move object and it simplifies the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Merge lookahead.py into toolhead.pyKevin O'Connor2016-07-101-3/+53
| | | | | | | | Remove the lookahead.py file and move its code directly into toolhead.py. The MoveQueue() class is small and tightly coupled to the toolhead code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>