aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/tmc2660.py
Commit message (Collapse)AuthorAgeFilesLines
* Isort all klippy codeTomasz Kramkowski2025-08-151-1/+3
|
* Run black on all first party python codeTomasz Kramkowski2025-08-061-53/+67
|
* tmc.py: add track of stallguardTimofey Titovets2025-07-121-0/+2
| | | | Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* tmc2660: add enriched SPI readTimofey Titovets2025-07-121-3/+11
| | | | Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* tmc: SET_TMC_FIELD VELOCITYAlex Voinea2023-03-201-0/+2
| | | | | 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>
* tmc2130: Rework current selection to prefer vsense=1Kevin O'Connor2022-01-161-8/+17
| | | | | | | | | | | | | | 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>
* stepper: Add support for stepping on both edges of a step pulseKevin O'Connor2021-11-041-1/+0
| | | | | | | | | | 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: Track requested hold_current so SET_TMC_CURRENT doesn't reduce itKevin O'Connor2021-10-271-1/+1
| | | | | | | | | | | 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-4/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Consistently use lower case for all TMC field namesKevin O'Connor2021-08-061-51/+51
| | | | | | | | | | | | 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>
* tmc2660: Fix typo in seup fieldKevin O'Connor2021-03-181-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Use lowercase for stallguard/coolstep fieldsKevin O'Connor2021-03-181-15/+15
| | | | | | | Use lowercase for the field names so that it matches the tmc2130/tmc5160 field names. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Report SE in DUMP_TMC even if zeroKevin O'Connor2021-03-161-2/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Change stallguard flags to better match tmc2130/tmc5160Kevin O'Connor2021-03-151-6/+5
| | | | | | | | | The tmc2660 spec has an ambiguous "SG" field that sometimes refers to the "stallGuard" flag and sometimes refers to the "SG_RESULT" field. The tmc2130 and tmc5160 have similar fields that are not ambiguous, so adopt that naming strategy. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Do not enable SFILT by defaultKevin O'Connor2021-03-101-2/+1
| | | | | | | None of the other TMC driver enable SFILT by default and it seems enabling SFILT may not be ideal for sensorless homing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Fix tmc register readingKevin O'Connor2021-02-271-30/+35
| | | | | | | | | The tmc2660 appears to send responses as soon as the clk starts toggling. That means the 20 bit response is at the top of the 24bit sent message. Also, this implies that RDSEL must already have the correct value in the prior message. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Use common warning/error flag names and descriptionsKevin O'Connor2021-02-271-43/+30
| | | | | | | | Where the tmc2660 flags match other drivers, use lowercase so that the same monitoring code can be used for all the tmc drivers. Also, use the same field formatters where applicable. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Move SET_TMC_CURRENT command to TMCCommandHelper()Kevin O'Connor2021-02-271-15/+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>
* tmc2660: Add set_current()/get_current() helpers to TMC2660CurrentHelperKevin O'Connor2021-02-271-9/+15
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* 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>
* tmc2660: Use new GCodeCommand wrappersKevin O'Connor2020-05-051-11/+10
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Remove virtual_enable support and replace with automatic supportKevin O'Connor2019-11-121-2/+0
| | | | | | | 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>
* tmc: Configure "intpol" field from TMCMicrostepHelperKevin O'Connor2019-06-281-4/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Add support for virtual enable pinsKevin O'Connor2019-06-281-3/+5
| | | | | | | 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>
* tmc2660: Hold a mutex during MCU_TMC2660_SPI get/set_register()Kevin O'Connor2019-06-281-5/+10
| | | | 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-7/+10
| | | | | | | | 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-5/+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>
* tmc2660: Set SDOFF=0 before accessing DRVCTRLKevin O'Connor2019-06-181-2/+1
| | | | | | | Make sure to configure DRVCONF with SDOFF=0 prior to writing DRVCTRL as that field controls access to that register. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Don't allow configuration of DEDGEKevin O'Connor2019-06-181-1/+0
| | | | | | Setting DEDGE would just break the code. 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-5/+5
| | | | | | 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-15/+4
| | | | | | | | 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>
* tmc2660: Move current setting code to its own helper classKevin O'Connor2019-06-101-66/+78
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Transmit register initialization during connect callbackKevin O'Connor2019-06-101-3/+0
| | | | | | | | 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>
* tmc2660: Use TMCCommandHelperKevin O'Connor2019-06-101-50/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Move get/set_register functions to new MCU_TMC2660_SPI classKevin O'Connor2019-06-101-29/+48
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Define get_register() methodKevin O'Connor2019-06-101-13/+14
| | | | | | | | | | Use a get_register() method instead of get_response(). This makes the tmc2660 class more similar to other TMC drivers. It also enables DUMP_TMC to dump all the readable content. Also, use the tmc2130.get_config_microsteps() helper. 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-2/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Automate VSENSE computationFlorian Heilmann2019-03-221-21/+32
| | | | | | Adjust the HEND default, which was faulty after the the fields update, remove disallowance of setting CS Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
* tmc2660: Minor indentation fixKevin O'Connor2019-03-081-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: Add INIT_TMC and SET_TMC_FIELD gcodesFlorian Heilmann2019-03-081-2/+31
| | | | Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
* tmc2660: Raise SPI speed to 4 MhzFlorian Heilmann2019-03-081-1/+1
| | | | Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
* tmc2660: Use helper functions for register access and simplify TMC2660 ↵Florian Heilmann2019-03-081-193/+174
| | | | | | | | parameters sense_resistor is now a mandatory parameter for tmc2660 blocks. Duet2 users should use a value of 0.051 Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
* tmc2660: Add vsense_resistor config parameterFlorian Heilmann2019-03-081-18/+18
| | | | Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
* tmc2660: Wrap code to 80 columnsKevin O'Connor2019-02-271-26/+56
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2660: error and whitespace fixesPetri Honkala2018-12-271-4/+4
| | | | | | | | - redundant parentheses removed - parameter reference fixed - raise error fixed Signed-off-by: Petri Honkala <cruwaller@gmail.com>
* tmc2660: Use bus.py helper code for spiKevin O'Connor2018-11-211-31/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>