aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/stepper.py
Commit message (Collapse)AuthorAgeFilesLines
* stepper: Fix broken manual_stepper rail naming (#6929)Dmitry Butyugin2025-05-101-4/+6
| | | | | The naming got broken during refactoring for generic_cartesian. Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* kinematics: Generic Cartesian kinematics implementation (#6815)Dmitry Butyugin2025-05-061-30/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tests: Added a regression test for generic_cartesian kinematics * kinematics: An intial implementation of generic_cartesian kinematics * generic_cartesian: Refactored kinematics configuration API * generic_cartesian: Use stepper instead of kinematic_stepper in configs * generic_cartesian: Added SET_STEPPER_KINEMATICS command * generic_cartesian: Fixed parsing of section names * docs: Generic Caretsian kinematics documentation and config samples * generic_cartesian: Implemented multi-mcu homing validation * generic_cartesian: Fixed typos in docs, minor fixes * generic_cartesian: Renamed `kinematics` option to `carriages` * generic_cartesian: Moved kinematic_stepper.py file * idex_modes: Internal refactoring of handling dual carriages * stepper: Refactored the code to not store a reference to config object * config: Updated example-generic-cartesian config * generic_cartesian: Restricted SET_STEPPER_CARRIAGES and exported status * idex_modes: Fixed handling stepper kinematics with input shaper enabled * config: Updated configs and tests for SET_DUAL_CARRIAGE new params * generic_cartesian: Avoid inheritance in the added classes Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* stepper: Support step on both edges with custom minimum pulse durationKevin O'Connor2025-03-201-7/+28
| | | | | | | | | | Add support for "step on both edges" to the main stepper_event_full() code. This makes that mode of operation available even when the micro-controller is not compiled for "optimized step on both edges". It also enables the custom pulse duration support (step_pulse_ticks) when in "step on both edges" mode. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* force_move: Implement CLEAR for SET_KINEMATIC_POSITION (#6262)Dennis Marttinen2025-01-101-1/+1
| | | | | | | | `CLEAR` clears the homing status (resets the axis limits) without turning off the motors. This is particularly useful when implementing safe Z homing in `[homing_override]` on printers with multiple independent Z steppers (where `FORCE_MOVE` can't be used). Signed-off-by: Dennis Marttinen <twelho@welho.tech>
* homing: Log a warning if probe alters stepper kinematic positionsKevin O'Connor2024-10-261-2/+4
| | | | | | | | | After a probe attempt the toolhead position needs to be recalculated to the position that the toolhead ultimately halted at. Check that the position setting wouldn't actually change the internal view of the stepper motor and log a warning if any skew is detected. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Remove code that could read microsteps in tmc config sectionsKevin O'Connor2024-05-161-1/+2
| | | | | | | | Setting of microsteps in the stepper config section has been required since commit eea0137b. Remove the no longer needed compatibility code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* idex_modes: Native input shaping support with dual carriagesDmitry Butyugin2023-06-061-0/+2
| | | | Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* mcu: Move lookup_command_tag() to CommandWrapper classKevin O'Connor2023-02-221-6/+6
| | | | | | | | Use mcu.lookup_command().get_command_tag() instead of mcu.lookup_command_tag(). This improves error reporting on a protocol mismatch. It also enables support for a msgtag that is negative. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Verify trapq is unmodified on default SET_PRESSURE_ADVANCEKevin O'Connor2022-03-041-0/+2
| | | | | | | | | Check that a SET_PRESSURE_ADVANCE without an explicit EXTRUDER parameter isn't done after the user disables or reassociates the extruder stepper motor (via SYNC_EXTRUDER_MOTION). Otherwise, it could lead to very confusing results. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* delta: Multiple steppers on delta tower (#5217)Andrei Ignat2022-02-281-2/+4
| | | | | Updated tower rail setup to support multiple steppers per tower. Signed-off-by: Andrei Ignat <andrei@ignat.se>
* extruder: Add support for reversing the direction of extruder stepper movementKevin O'Connor2022-02-101-4/+13
| | | | | | | Extend SET_EXTRUDER_ROTATION_DISTANCE to support reversing the direction of extruder movement. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Add a SET_EXTRUDER_ROTATION_DISTANCE commandKevin O'Connor2022-02-101-7/+15
| | | | | | | | Support altering the extruder distance using the higher-level rotation_distance. This is in preparation for removal of the SET_EXTRUDER_STEP_DISTANCE command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Support step_pulse_duration even on TMC drivers in UART/SPI modeKevin O'Connor2021-11-291-1/+4
| | | | | | | | | | | | | | | Commit 689231df changed the default step_pulse_duration to 100ns for TMC drivers that are configured in UART/SPI mode, but it failed to document that change in Config_Changes.md and Config_Reference.md. Update those documents to reflect that change. Update the code so that a user may specify a custom step_pulse_duration even on TMC drivers that are configured in UART/SPI mode. This may be useful for drivers that use a level shifter on the step pin that requires more than a ~300ns to detect a level change. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Add support for stepping on both edges of a step pulseKevin O'Connor2021-11-041-1/+15
| | | | | | | | | | Add an optimized step function for drivers that support stepping on both rising and falling edges of the step pin. Enable this optimization on 32bit ARM micro-controllers. Automatically detect this capability in the host code and enable on TMC drivers running in SPI/UART mode. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Make step pulse duration customizable at run-timeKevin O'Connor2021-11-041-5/+12
| | | | | | | | | | | | Remove the STEP_DELAY Kconfig option and replace it with a per-stepper step_pulse_duration printer.cfg config option. The AVR code will continue to have optimized code to step and "unstep" in the same function (which is automatically activated when the step delay is 40 ticks or less). This change removes the Kconfig option for single function step/unstep on 32bit processors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Remove support for deprecated step_distance optionKevin O'Connor2021-11-021-7/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Remove unused _dist_to_time() methodKevin O'Connor2021-10-291-4/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* kinematics: Convert to Python3 string encodingKevin O'Connor2021-10-011-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Make sure to report an error if endstop_pin is not definedKevin O'Connor2021-09-291-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Add support for reporting deprecated optionsKevin O'Connor2021-09-161-0/+1
| | | | | | | Add a new printer.configfile.warnings with a list of config features that are deprecated. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: detect duplicate endstopsLasse Dalegaard2021-08-311-6/+26
| | | | | | | When adding steppers to a `PrinterRail`, detect duplicated `endstop_pin` settings and add them to the already-registered endstop. Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
* stepper: Add mcu_to_commanded_position() methodKevin O'Connor2021-08-221-2/+1
| | | | | | | Convert stepper.get_past_commanded_position() to the more general stepper.mcu_to_commanded_position(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Use config.getlists() for gear_ratio config optionKevin O'Connor2021-08-211-10/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Calculate homing position based on trigger timeKevin O'Connor2021-08-171-1/+2
| | | | | | | | | Calculate the "homing position" using the endstop trigger time instead of the position of the steppers. This is in preparation for multi-mcu homing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Track offset between tmc driver and mcu positionKevin O'Connor2021-08-081-0/+1
| | | | | | | | Track the offset between driver phase and mcu position. This offset should be constant as long as neither the driver nor the mcu is reset. If the offset ever changes, log a warning. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Query the stepper mcu position during startupKevin O'Connor2021-08-061-2/+7
| | | | | | | | Try to keep the host mcu_position synchronized with the micro-controller by querying during startup and after every homing event. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Pass clock to stepcompress_set_last_position()Kevin O'Connor2021-08-061-1/+4
| | | | | | | | | Using sc->last_step_clock for the last position marker does not work properly, because the stepper.py code calls stepcompress_reset() prior to calling stepcompress_set_last_position(). Fix by passing an explicit clock to stepcompress_set_last_position(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* motion_report: Add new extras module for low-level motion diagnosticsKevin O'Connor2021-07-291-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Simplify helper module registration of stepper motorsKevin O'Connor2021-07-291-6/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Support extracting stepcompress historyKevin O'Connor2021-07-291-0/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Minor indentation changesKevin O'Connor2021-07-031-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Restore mcu_position on set_stepper_kinematics() and set_step_dist()Kevin O'Connor2021-06-111-15/+20
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Remove set_tag_position() codeKevin O'Connor2021-05-291-7/+2
| | | | | | Have callers store the stepper positions in a dict. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Improve get_past_commanded_position()Kevin O'Connor2021-05-291-5/+7
| | | | | | | | Pass a print_time instead of a clock to get_past_commanded_position(). Fix calculation on steppers that home and use an inverted direction pin. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Remove min_stop_interval from mcu codeKevin O'Connor2021-04-301-2/+1
| | | | | | | Now that the host never uses a min_stop_interval, remove it from the mcu code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Do not set min_stop_interval in micro-controllerKevin O'Connor2021-04-301-17/+3
| | | | | | | | The min_stop_interval safety check is fragile and leads to a notable amount of complexity. Avoid these issues by not programming this safety check. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Register a config default for calculated homing_positive_dirKevin O'Connor2021-04-161-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Add support for tracking history of queue_step commandsKevin O'Connor2021-03-131-1/+10
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Improve error messages on missing rotation_distanceKevin O'Connor2021-02-231-5/+8
| | | | | | | | If neither rotation_distance nor step_distance is present, then generate an error saying rotation_distance is needed (instead of an error about step_distance). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Don't cache ffi_lib object in the stepperKevin O'Connor2021-02-181-20/+25
| | | | | | | It's easier to just call chelper.get_ffi() if the ffi_lib object is needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* buildcommands: Extend number of available mcu messages from 96 to 128Kevin O'Connor2021-02-181-9/+9
| | | | | | | | | | | Some internal code treats the message ids as encoded "variable length quantities", while other internal code assumes the message id is always one byte long. Continue using this scheme, but convert the VLQ users to use the name "msgtag" while the 1-byte users use "msgid". Increase the number of available msgids from 96 to 127 - the higher values get encoded as negative "msgtags". Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Calculate step_distance from rotation_distanceKevin O'Connor2020-12-181-1/+42
| | | | | | | | Add support for automatically calculating the internal step_distance from new config parameters - rotation_distance, microsteps, full_steps_per_rotation, and gear_ratio. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Prefer printer.command_error() instead of homing.CommandError()Kevin O'Connor2020-09-041-1/+1
| | | | | | | Update callers to use the printer.command_error reference instead of directly using homing.CommandError() when raising or catching errors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Add support for commands to send only on a host restartKevin O'Connor2020-07-251-2/+2
| | | | | | | | Add a new "on_restart" parameter to mcu.add_config_cmd() and only send those commands on a host restart that does not involve a micro-controller restart. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Make sure to reload trapq in set_stepper_kinematics()Kevin O'Connor2020-06-301-2/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Rename try_load_module() to load_object()Kevin O'Connor2020-05-081-3/+3
| | | | | | | | Rename try_load_module() so that it uses consistent naming for "printer objects". Change the function to raise an error by default if the specified module does not exist. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: No need to pass stepper_kinematics to set_step_dist()Kevin O'Connor2020-03-281-3/+2
| | | | | | | Also, no need to log in stepper.py as the update is already logged in extruder.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Extruder: Add g-code to set extruder step_distance (#2598)David Smith2020-03-281-0/+4
| | | Signed off by: David Smith <davidosmith@gmail.com>
* stepper: Add a config check for obvious incorrect homing_positive_dirKevin O'Connor2020-03-241-0/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Introduce new lookup_query_command() command wrapperKevin O'Connor2020-02-201-4/+4
| | | | | | | Use new mcu.lookup_query_command() for all commands that query information from the micro-controller. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>