aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/stepper.py
Commit message (Collapse)AuthorAgeFilesLines
* delta: Default stepper_b/c position_endstop to stepper_a'sKevin O'Connor2017-12-081-2/+6
| | | | | | | If the position_endstop is not set for stepper_b or stepper_c then use the value from stepper_a. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Only align the stepper motor to a full step when requestedKevin O'Connor2017-12-071-1/+2
| | | | | | | | | Add a new config option 'homing_endstop_align_zero' to enable the alignment of the endstop to a stepper full step. It's possible one may wish to specify a homing_endstop_phase while not aligning the endstop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Remove unneeded MCU_digital_out.get_last_setting() methodKevin O'Connor2017-12-061-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Reset the stepper step clock on init - not after each motor onKevin O'Connor2017-12-061-2/+0
| | | | | | | Reset the last step clock during the init phase and after each home - this simplifies the runtime code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Pass list of endstops (not steppers) to the homing codeKevin O'Connor2017-12-061-3/+2
| | | | | | | 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>
* stepper: get_homed_offset() should return a floatKevin O'Connor2017-12-031-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Support for multiple steppers controlling a single axisKevin O'Connor2017-11-181-0/+46
| | | | | | | 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>
* stepper: Add get_endstops() / set_position wrappersKevin O'Connor2017-11-181-0/+4
| | | | | | | 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>
* stepper: Store pointers to step_const and step_delta in PrinterStepperKevin O'Connor2017-11-181-4/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Remove unused variables from PrinterStepper classKevin O'Connor2017-11-181-4/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Additional code commentsKevin O'Connor2017-11-181-5/+9
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Calculate the stepper name directly from the config sectionKevin O'Connor2017-11-181-4/+6
| | | | | | | 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>
* endstop: Eliminate end_stop_set_oversample commandKevin O'Connor2017-10-121-5/+0
| | | | | | | | | | Pass the sample_ticks and sample_count parameters directly in the end_stop_home command instead. This simplifies the code. Also, simplify calculation of next wakeup time in end_stop_oversample_event(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: If homing_endstop_phase is configured, make 0.0 be at a full stepKevin O'Connor2017-10-031-0/+14
| | | | | | | | | If the stepper phases are known then it is possible to arrange for the 0.0 position to occur at a full step. On cartesian style printer, this makes it possible for the Z levels to occur at full steps (which may help reduce "Z ribbing"). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Support oversampling of the endstopKevin O'Connor2017-10-011-0/+5
| | | | | | | | Some printers can show occasional noise on the endstop pin. Support sampling the endstop pin multiple times to attempt to filter out this noise. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Avoid using '%' syntax when calling logging moduleKevin O'Connor2017-09-271-2/+2
| | | | | | | The logging module can build strings directly from printf syntax - no need to build the string first. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Move print_time to clock conversion code to clocksync.pyKevin O'Connor2017-09-191-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Move query_endstop() code from kinematic classes to homing.pyKevin O'Connor2017-09-191-6/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Pass print_time directly to MCU callsKevin O'Connor2017-09-191-10/+6
| | | | | | | | | 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>
* mcu: Use is_fileoutput() externallyKevin O'Connor2017-09-191-1/+1
| | | | | | | Use mcu.is_fileoutput() instead of looking up the "debugoutput" flag in the start args. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Fix bug causing 'enable_pin' to be requiredKevin O'Connor2017-09-191-0/+1
| | | | | | | Make sure to initialize mcu_enable to None so that it is initialized if no 'enable_pin' config value is provided. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Adjust homing_speed so that it's an even number of ticks per stepKevin O'Connor2017-08-291-0/+6
| | | | | | | | | | | 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>
* mcu: Add get_mcu() call to the mcu oid objectsKevin O'Connor2017-08-291-3/+3
| | | | | | | | | Allow external code to obtain the mcu object that controls a pin setup with setup_pin(). Also, don't bother defining print_to_mcu_time() and system_to_mcu_time() on each pin object as they can be obtained via the new get_mcu() method. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Support registering arbitrary chips that supply configurable pinsKevin O'Connor2017-08-251-10/+13
| | | | | | | | | Allow multiple chips to provide pin mappings (not just the main mcu chip). Move the pin parsing from the mcu.py code to pins.py and support mapping from pin descriptions to their corresponding chips and parameters. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Store printer startup parameters in new "start_args" dictionaryKevin O'Connor2017-08-251-1/+1
| | | | | | | | | Store pertinent information from the software startup in a dictionary that the various printer components can access instead of in individual variables in the Printer() class. This makes it easier to add future command-line options. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Use a sane default for homing_positive_dirKevin O'Connor2017-07-241-2/+11
| | | | | | | Use the endstop position to determine a sane default for homing_positive_dir. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Separate out homing code to its own PrinterHomingStepper classKevin O'Connor2017-07-241-39/+42
| | | | | | | 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>
* klippy: Remove some obscure python2 dependenciesKevin O'Connor2017-06-101-1/+1
| | | | | | | Don't modify dictionaries while iterating them and be careful to use // when doing an integer divide. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Support minimum/maximum value checks on configuration variablesKevin O'Connor2017-04-111-8/+14
| | | | | | | Verify that numeric parameters are in a sane range when reading the config. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Change mcu_stepper.set_position() to take a location in millimetersKevin O'Connor2017-04-071-1/+1
| | | | | | | | | | 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>
* mcu: Pass constant velocity and acceleration directly to mcu_stepperKevin O'Connor2017-04-071-0/+1
| | | | | | | | 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>
* endstop: Support halting more than one stepper on triggerKevin O'Connor2017-04-031-1/+2
| | | | | | | | Extend the endstop code so that more than one stepper can be halted during endstop homing. Some kinematic setups (eg, corexy) require an endstop to support this. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Disable homing_endstop_accuracy errors on debug runsKevin O'Connor2017-03-311-0/+2
| | | | | | | If klippy is started in file output debugging, disable the homing_endstop_accuracy error check. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Fix set_min_stop_interval() calculationKevin O'Connor2017-03-161-4/+10
| | | | | | | | | | | The previous calculation was only valid if the stepper is always commanded to a position that is an exact multiple of the step_distance. The safety check was programmed with a value too large for other commanded positions, which could result in "No next step" errors. Fix by changing the calculation to use the worst case scenario. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Eliminate high-level build_config phaseKevin O'Connor2017-03-131-22/+15
| | | | | | | | | | 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>
* mcu: Delay setting of mcu_stepper.min_stop_intervalKevin O'Connor2017-03-131-4/+2
| | | | | | | | | Create a separate callback for setting the min_stop_interval. Also, move the setting of the stepper max_error from the stepper configs to the mcu config and rename it to max_stepper_error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Change default max_error from 50us to 25usKevin O'Connor2016-12-281-1/+1
| | | | | | | | | Change the default compression error window (max_error) from 50us to 25us - it's common for stepper motor drivers to have 30us for their "pwm fixed off time" and it would be good for the steps to be scheduled within that time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rework homing to use greenletsKevin O'Connor2016-12-091-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gcode: Rework endstop query to use greenletsKevin O'Connor2016-12-091-2/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Specify maximum acceleration and velocity in toolhead classKevin O'Connor2016-12-011-10/+7
| | | | | | | | | | 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>
* klippy: Throw an exception if any required config parameter is missingKevin O'Connor2016-11-301-8/+10
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Raise an EndstopError if invalid phase found during homingKevin O'Connor2016-11-181-3/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Create QueryEndstops class from gcodeKevin O'Connor2016-11-181-3/+5
| | | | | | | | | | | 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>
* stepper: Check if the motor needs to be enabled in the kinematic classesKevin O'Connor2016-11-141-9/+5
| | | | | | | 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>
* stepper: Reset the next step time on a stepper stopKevin O'Connor2016-11-141-1/+1
| | | | | | | | | Automatically reset the next step time to zero on a stepper_stop() call. This makes the host code simpler as it no longer needs to schedule an explicit reset_step_clock command on the step after a homing operation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepcompress: Do all step rounding in C codeKevin O'Connor2016-11-131-2/+2
| | | | | | | | | | | | | | | | | 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>
* stepper: Return homing offset in steps instead of an absolute positionKevin O'Connor2016-10-131-5/+5
| | | | | | | | | | 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>
* homing: Support querying the current status of endstopsKevin O'Connor2016-09-221-0/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: convert stepper, endstop, and digital_out to take mcu_timeKevin O'Connor2016-08-241-17/+12
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Support stepper phase adjustments when homingKevin O'Connor2016-07-281-0/+35
| | | | | | | 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>