aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/tmc.py
Commit message (Collapse)AuthorAgeFilesLines
* tmc: Do not override tcoolthrs if it is configuredAlex Voinea2023-03-151-10/+8
| | | | | | | | | | | If tcoolthrs is configured (not the default 0), then do not force the value of tcoolthrs=0xfffff during homing. This way, tcoolthrs can be set to a custom value during homing. `tpwmthrs` and `en_pwm_mode`/`en_spreadcycle` are now also correctly restored if they were changed after startup. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Configurable microstep lookup table (#5920)Alex Voinea2022-12-211-0/+21
| | | | | | | Make all the microstep lookup table registers configurable via the config file. It also loads the default values. TMC220x and TMC2660 do not support this feature. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Improve error on missing stepper sectionKevin O'Connor2022-09-051-0/+4
| | | | | | | | If a tmc driver can't find the stepper config section it reports a "missing microsteps" error which can be confusing. Provide a more explicit error message. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Add support for reversing the direction of extruder stepper movementKevin O'Connor2022-02-101-1/+3
| | | | | | | 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-2/+3
| | | | | | | | 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>
* tmc: Fix number of arguments in phase endstop warning (#5184)D4SK2022-01-221-1/+1
| | | Signed-off-by: Konstantin Vogel <konstantin.vogel@gmx.net>
* stepper: Add support for stepping on both edges of a step pulseKevin O'Connor2021-11-041-3/+12
| | | | | | | | | | 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>
* tmc: Rename handle_stepper_enable() method to _handle_stepper_enable()Kevin O'Connor2021-10-291-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Track requested hold_current so SET_TMC_CURRENT doesn't reduce itKevin O'Connor2021-10-271-10/+9
| | | | | | | | | | | The code automatically reduces the hold_current so that it is no greater than the run_current. However, this could lead to confusing behavior if one reduced and then increased the run_current via SET_TMC_CURRENT commands. To avoid that, this change adds support for tracking the requested hold_current - thus changes to run_current don't subtly alter the hold_current. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: add current values to get_status() (#4696)Philipp Temminghoff2021-10-111-1/+4
| | | Signed-off-by: Philipp Temminghoff <philipptemminghoff@gmail.com>
* tmc: Fix typo in get_status()Kevin O'Connor2021-08-301-0/+1
| | | | | | Fix missing variable assignement introduced in commit 5fd1c985. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Add support for a get_status() methodKevin O'Connor2021-08-301-1/+25
| | | | | | Export mcu_phase_offset and drv_status information. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Support config.getchoice() with integer keysKevin O'Connor2021-08-251-5/+2
| | | | | | | | If the choice mapping uses integer keys then lookup the config option using self.getint(). This simplifies the callers and improves the encoding of the printer.configfile.settings export. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Use config.getint() when reading microstep settingKevin O'Connor2021-08-221-3/+5
| | | | | | | Don't use config.getchoice() as that results in a string reported by printer.configfile.settings. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop_phase: Convert to using tmc mcu_phase_offsetKevin O'Connor2021-08-081-10/+11
| | | | | | | Now that the TMC drivers track the phase offset, use that to implement endstop phase. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Track offset between tmc driver and mcu positionKevin O'Connor2021-08-081-6/+59
| | | | | | | | 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>
* tmc: Move stepper phase reading code to TMCCommandHelper classKevin O'Connor2021-08-061-25/+26
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Consistently use lower case for all TMC field namesKevin O'Connor2021-08-061-22/+22
| | | | | | | | | | | | The Trinamic specs aren't consistent with upper vs lower case, which can be confusing. Improve clarity by using lower case names consistently in the code. Register names will continue to use all upper case naming in the code. Update the SET_TMC_FIELD command to automatically convert field names to lower case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Pass the HomingMove class to homing_move_begin/end eventsKevin O'Connor2021-03-291-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Only check for tmc2130 reset via CS_ACTUAL if IHOLD > 0Kevin O'Connor2021-03-151-0/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Improve driver reset check on tmc2130 and tmc2660Kevin O'Connor2021-03-151-9/+23
| | | | | | Use the CS_ACTUAL/SE field to check for a mid-print driver reset. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Move clear_gstat check for tmc2130 to within TMCErrorCheck classKevin O'Connor2021-03-151-5/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Fix order of init during sensorless homingKevin O'Connor2021-02-281-4/+8
| | | | | | | | | | | With commit 53b10d3a the setup of sensorless homing could occur before the driver was enabled which would cause the reinitialization of the driver settings to undo the sensorless homing setup. Use set_field() when setting the sensorless homing registers so that it wont conflict with a driver init. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: No need to delay init on a stepper enableKevin O'Connor2021-02-281-3/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Allow more retries on a TMC UART read error during background checksKevin O'Connor2021-02-281-1/+10
| | | | | | | Allow three retries if we can't contact the TMC driver at all when it is in UART mode. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Add support for periodic checking of driver statusKevin O'Connor2021-02-271-1/+76
| | | | | | | | Check the status of all Trinamic stepper motor drivers once a second. If the driver reports an error then invoke a shutdown. Also log any serious warnings. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Reinitialize on every driver enableKevin O'Connor2021-02-271-32/+36
| | | | | | | | | | | | | Send the full TMC stepper motor driver initialization sequence every time the driver is enabled. Don't raise an error on startup if unable to contact a tmc2208/tmc2209 driver. If the driver is still unavailable when it is enabled then a shutdown will be issued. This allows users to troubleshoot (and possibly bring up communication to the driver) prior to enabling the driver. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Always report values after a SET_TMC_CURRENT commandKevin O'Connor2021-02-271-14/+15
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Move SET_TMC_CURRENT command to TMCCommandHelper()Kevin O'Connor2021-02-271-1/+27
| | | | | | | Refactor the tmc driver implementations so that there is a single implementation of the SET_TMC_CURRENT command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Improve error message on missing microsteps configKevin O'Connor2021-02-231-1/+2
| | | | | | | If microsteps is missing, warn about it in the stepper config section, not the tmc config section. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop_phase: Obtain phases directly from stepper microsteps configKevin O'Connor2020-12-181-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Calculate step_distance from rotation_distanceKevin O'Connor2020-12-181-3/+9
| | | | | | | | 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>
* tmc: Use configfile note_valid=False when inspecting stepper step_distanceKevin O'Connor2020-12-131-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc5160: diag0 support (#3159)Trevor Jones2020-08-091-4/+13
| | | | | Allow for diag0 only hardware to use sensorless homing. Signed-off-by: Trevor Jones <trevorjones141@gmail.com>
* tmc: Use new GCodeCommand wrappersKevin O'Connor2020-05-051-23/+21
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Revert incorrect changes to TPWMTHRS settingKevin O'Connor2020-02-201-26/+18
| | | | | | | | | | | | | | It's not valid to set the TPWMTHRS in a "klippy:connect" event handler because the TMCVirtualPinHelper and TMCCommandHelper classes were expecting that field to be set during the config reading phase. Revert "tmc: Fix typo preventing stealthchop threshold from being set" This reverts commit 7d76067ff9efaf75808b05f768dfef4295251ede. Revert "tmc: Query the stepper step_distance from the stepper object" This reverts commit 67b285224952749583d7bb3af3eb6397f63b492e. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* homing: Merge home_prepare()/home_finalize() into move_begin/move_end eventsKevin O'Connor2020-02-151-35/+34
| | | | | | | | Collapse the "homing:move_begin", "homing:move_end", home_prepare(), and home_finalize() into two new events: "homing:homing_move_begin" and "homing:homing_move_end". This simplifies the homing code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Fix typo preventing stealthchop threshold from being setKevin O'Connor2020-02-091-2/+3
| | | | | | Fix typo introduced in commit 67b28522. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Query the stepper step_distance from the stepper objectKevin O'Connor2020-02-011-17/+24
| | | | | | | Don't obtain the step_distance from the config, instead obtain step_distance from the instantiated stepper object. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Remove virtual_enable support and replace with automatic supportKevin O'Connor2019-11-121-33/+30
| | | | | | | Automatically detect if the stepper has a dedicated enable line. If it does not, then automatically enable virtual enable support. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2209: Add support for sensorless homingKevin O'Connor2019-08-191-6/+24
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Integrate query_endstop_wait() into query_endstop()Kevin O'Connor2019-07-101-1/+0
| | | | | | There is no need to have two separate calls to query an endstop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Configure "intpol" field from TMCMicrostepHelperKevin O'Connor2019-06-281-3/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Add support for virtual enable pinsKevin O'Connor2019-06-281-6/+34
| | | | | | | Add support for enabling the stepper via the communication channel. This improves support for boards with a shared enable line. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: It's not valid to schedule messages with print_time=0Kevin O'Connor2019-06-251-2/+2
| | | | | | | | A print_time of zero may translate to a negative clock on a secondary micro-controller, which would cause an internal error. Change the code to pass a real print_time or None if it is not needed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Simplify internal DUMP_TMC interfaceKevin O'Connor2019-06-251-7/+9
| | | | | | | | Only the tmc2208 driver needs special read register translation logic. Rework the code so a default implementation is available for all the other drivers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop_phase: Fix endstop_phase on trinamic drivers that aren't invertedKevin O'Connor2019-06-211-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Retry register init during connectKevin O'Connor2019-06-181-4/+12
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Move common TMC stepper driver code to new file tmc.pyKevin O'Connor2019-06-101-0/+242
Move common code from tmc2130.py to tmc.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>