aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/tmc2130.py
Commit message (Collapse)AuthorAgeFilesLines
* Run black on all first party python codeTomasz Kramkowski2025-08-061-109/+211
|
* tmc.py: add track of stallguardTimofey Titovets2025-07-121-0/+4
| | | | Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* tmc: add spi status decodeTimofey Titovets2025-07-121-0/+7
| | | | Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* tmc: add enriched SPI readTimofey Titovets2025-07-121-5/+16
| | | | | | | Currently TMC spi just drop the data that could be useful. Export that data. Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* tmc: add missing freewheel config optionsTimofey Titovets2025-04-171-0/+1
| | | | Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* tmc: Implement high_velocity_threshold for drivers that support itAlex Voinea2024-05-141-0/+1
| | | | Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Implement coolstep_threshold for drivers that support itAlex Voinea2024-05-141-0/+1
| | | | Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Implement CoolStep fields for all driversAlex Voinea2024-05-141-0/+6
| | | | Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc2130: implement missing HighVelocity fields in the configAlex Voinea2024-05-141-0/+2
| | | | Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Do not pass the frequency directly to the helpersAlex Voinea2024-05-141-1/+1
| | | | | | Use the new get_tmc_frequency() instead. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: SET_TMC_FIELD VELOCITYAlex Voinea2023-03-201-2/+6
| | | | | 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: Beautify initialization codeAlex Voinea2023-03-071-2/+7
| | | | | Purely esthetic. Make all tmc driver init code similar to one another. The various fields were grouped based on the register which they affect or the function they perform. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Configurable microstep lookup table (#5920)Alex Voinea2022-12-211-4/+28
| | | | | | | 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>
* tmc2130: Rework current selection to prefer vsense=1Kevin O'Connor2022-01-161-19/+22
| | | | | | | | | | | | | | It is preferable to program the tmc drivers with an irun (or cs) setting near 31, as otherwise the driver may have reduced microstep precision. It was possible for the driver to be programmed with irun=16 or irun=17 when it could have been configured with irun=31 with vsense=1 instead. This would occur on tmc2130/tmc2208/tmc2209 drivers for values around 0.900 to 1.000 amps (when using a typical sense_resistor settings of 0.110 Ohms). Change the code to prefer using vsense=1 to avoid this issue. 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-2/+4
| | | | | | | | | | | 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 support for a get_status() methodKevin O'Connor2021-08-301-0/+1
| | | | | | Export mcu_phase_offset and drv_status information. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop_phase: Convert to using tmc mcu_phase_offsetKevin O'Connor2021-08-081-2/+1
| | | | | | | 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: Move stepper phase reading code to TMCCommandHelper classKevin O'Connor2021-08-061-3/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Consistently use lower case for all TMC field namesKevin O'Connor2021-08-061-34/+34
| | | | | | | | | | | | 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>
* tmc2130: Report CS_ACTUAL in DUMP_TMC even if zeroKevin O'Connor2021-03-161-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Move clear_gstat check for tmc2130 to within TMCErrorCheck classKevin O'Connor2021-03-151-2/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Fix broken error report due to missing self.nameKevin O'Connor2021-03-111-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Verify SPI register writesKevin O'Connor2021-03-101-2/+17
| | | | | | | | The tmc2130 (and tmc5160) will respond back with the value written during the next SPI command. Use this feature to verify that the value written matches the value sent. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Add support for periodic checking of driver statusKevin O'Connor2021-02-271-1/+2
| | | | | | | | 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>
* tmc5160: Merge field formatters into tmc2130.pyKevin O'Connor2021-02-271-0/+1
| | | | | | | | The tmc5160 field formatters were mostly duplicates of the tmc2130 - add the "reset" field to tmc2130.py so both drivers have similar reporting. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Move SET_TMC_CURRENT command to TMCCommandHelper()Kevin O'Connor2021-02-271-24/+2
| | | | | | | 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>
* tmc2130: Add set_current()/get_current() helper functions to TMCCurrentHelperKevin O'Connor2021-02-271-16/+20
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Add spi daisy chain supportMarco D'Alessio2021-02-261-14/+59
| | | | | | | | This patch adds the ability to daisy-chain multiple tmc2130 and tmc5160 drivers. Signed-off-by: Marco D'Alessio <marco@wrecklab.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc5160: diag0 support (#3159)Trevor Jones2020-08-091-2/+1
| | | | | Allow for diag0 only hardware to use sensorless homing. Signed-off-by: Trevor Jones <trevorjones141@gmail.com>
* extras: Use "from . import module" for relative importsKevin O'Connor2020-06-151-1/+1
| | | | | | Use alternate import syntax to improve Python3 compatibility. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Use new GCodeCommand wrappersKevin O'Connor2020-05-051-18/+17
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: use local variable instead of global Registers in MCU_TMC_SPIPetri Honkala2019-12-031-1/+1
| | | | Signed-off-by: Petri Honkala <cruwaller@gmail.com>
* tmc2130: Do not error if run current below hold current (#2190)Florian Heilmann2019-11-211-3/+5
| | | Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
* tmc: Configure "intpol" field from TMCMicrostepHelperKevin O'Connor2019-06-281-1/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Add support for virtual enable pinsKevin O'Connor2019-06-281-2/+2
| | | | | | | 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>
* tmc2130: Hold a mutex during MCU_TMC_SPI get/set_register()Kevin O'Connor2019-06-281-5/+8
| | | | 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-3/+5
| | | | | | | | 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-4/+1
| | | | | | | | 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>
* tmc: Move common TMC stepper driver code to new file tmc.pyKevin O'Connor2019-06-101-243/+7
| | | | | | Move common code from tmc2130.py to tmc.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Rework remaining config helpers to use mcu_tmc interfaceKevin O'Connor2019-06-101-28/+42
| | | | | | | | Introduce TMCMicrostepHelper and TMCStealthchopHelper helper code that uses the mcu_tmc interface. Update the callers to use these new helpers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Move TMC virtual endstop code into a new TMCEndstopHelper classKevin O'Connor2019-06-101-40/+55
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Move current setting code to its own helper classKevin O'Connor2019-06-101-84/+83
| | | | | | | Concentrate the current setting code into its own TMCCurrentHelper class. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Transmit register initialization during connect callbackKevin O'Connor2019-06-101-3/+9
| | | | | | | | Perform the register initialization directly from TMCCommandHelper and perform it during the "connect" phase. This unifies the register setup for the TMC2130, TMC2208, TMC2660, and TMC5160. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Factor out g-code command handlers to their own classKevin O'Connor2019-06-101-47/+70
| | | | | | | Create a TMCCommandHelper class that implements INIT_TMC, SET_TMC_FIELD, and DUMP_TMC. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Move low-level get/set_register functions to new MCU_TMC_SPI classKevin O'Connor2019-06-101-28/+42
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* test: Add test cases for tmc driversKevin O'Connor2019-06-101-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Check field name validity. (#1697)Artem Belevich2019-06-021-1/+3
| | | | | This avoids crashing Klipper if user entered invalid field name. Signed-off-by: Artem Belevich <artemb@gmail.com>
* tmc2130: Add support for two's complement signed fields to FieldHelperKevin O'Connor2019-05-291-18/+19
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: add SET_TMC_CURRENT and SET_TMC_FIELD commands (#1419)amblidex2019-03-221-6/+74
| | | Signed-off-by: Frank Kang <amblidex@outlook.com>
* tmc2130: Rename driver_BLANK_TIME_SELECT to driver_TBLKevin O'Connor2019-03-081-1/+1
| | | | | | | Use the field names from the trinamic specification. This makes the field similar to all the other driver_XXX config options. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>