aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/tmc.py
Commit message (Collapse)AuthorAgeFilesLines
* Isort all klippy codeTomasz Kramkowski2025-08-151-2/+4
|
* Run black on all first party python codeTomasz Kramkowski2025-08-061-118/+203
|
* tmc.py: add track of stallguardTimofey Titovets2025-07-121-0/+92
| | | | Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* tmc: Remove code that could read microsteps in tmc config sectionsKevin O'Connor2024-05-161-7/+3
| | | | | | | | 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>
* tmc: Save and restore thigh during sensorless homingKevin O'Connor2024-05-161-2/+17
| | | | | | | Make sure thigh is set to zero during sensorless homing, as it would not make sense for it to be enabled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Refactor TMCtstepHelper()Kevin O'Connor2024-05-161-37/+22
| | | | | | | Update TMCtstepHelper() to obtain the step_distance, tmc_frequency, and mres fields directly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Implement high_velocity_threshold for drivers that support itAlex Voinea2024-05-141-0/+17
| | | | Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Implement coolstep_threshold for drivers that support itAlex Voinea2024-05-141-0/+16
| | | | Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Do not pass the frequency directly to the helpersAlex Voinea2024-05-141-2/+3
| | | | | | Use the new get_tmc_frequency() instead. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Query latest value during _init_registers()Kevin O'Connor2023-11-281-1/+2
| | | | | | | | | | | | The set_register() code may block, and it therefore may be possible that the loop in _init_registers() could occur in parallel with other updates. That could result in a "OrderedDict mutated during iteration" error. Avoid the error by querying the latest value during each iteration of the loop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* heaters: adds temperature monitorsPedro Lamas2023-08-011-0/+3
| | | | Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
* tmc: Support reporting tmc2240 temperature in driver get_status()Kevin O'Connor2023-04-071-5/+19
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: DUMP_TMC optional REGISTER parameterAlex Voinea2023-03-301-10/+25
| | | | | | Add an optional REGISTER parameter to DUMP_TMC so that the output is more filtered/cleaner for manual TMC calibration. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: SET_TMC_FIELD VELOCITYAlex Voinea2023-03-201-1/+12
| | | | | Ability to specify `VELOCITY` as a parameter for SET_TMC_FIELD. Useful for configuring at runtime the TSTEP based fields of the driver. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Implement TMCtstepHelperAlex Voinea2023-03-201-7/+20
| | | | | Implement a helper for calculating velocity based thresholds for tmc drivers. This code was written in such a way that it can be used with more fields than just tpwmthrs. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Initialize self.coolthrs in TMCVirtualPinHelper constructorKevin O'Connor2023-03-151-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* 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>