aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/tmc5160.py
Commit message (Collapse)AuthorAgeFilesLines
* tmc5160: Increase maximum current error checkKevin O'Connor2023-11-201-1/+1
| | | | | | | | | | | | It's possible to build and configure tmc5160 drivers with external mosfets that support more than 3 amps. The actual maximum for tmc5160 drivers is dependent on how the board is wired and the mosfets used. Increase the error check to 10 amps. This error checking is primarily intended to catch "obvious misconfigurations" (eg, specifying milli-amps instead of amps), and the new value of 10 amps should suffice for this task. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc: Configurable `multistep_filt`Alex Voinea2023-06-161-1/+2
| | | | Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc5160: add DRV_CONF Register for TMC5160 (#6154)vcore852023-04-111-0/+12
| | | | | | | In some condition ,“drvstrength 2” does not work. According to page 17, some mosfets need “drvstrength” set to 0 . From datasheet rev1.15, the DRVSTRENGTH reset default is 0 . (instead of 2) Signed-off-by: Albert Lin <vcore85@gmail.com>
* tmc: SET_TMC_FIELD VELOCITYAlex Voinea2023-03-201-1/+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>
* tmc: Enable `multistep_filt` for drivers that support itAlex Voinea2023-03-151-0/+1
| | | | | | | `multistep_filt` was not configured at all on tmc2240 and tmc5160. As such, it would default to the value of 0 when the GCONF field was sent to the driver. However, that field has a default value of 1 in the driver, so klipper was overriding the defaults by accident. This field improves the stability of velocity based thresholds (it's effectively TSTEP filtering) and it also improves the current regulation stability in stealthchop2 (according to the datasheet). This field was already set to 1 correctly in the tmc2208/tmc2209 driver code. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Beautify initialization codeAlex Voinea2023-03-071-1/+1
| | | | | 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>
* tmc5160: allow changing the globalscaler at runtimeAlex Voinea2023-03-071-10/+12
| | | | | | | | | Previously, the globalscaler was calculated during the config parsing and set to a fixed value. If the current was changed for any reason after the initialization, only IRUN and IHOLD would be changed. This however caused issues: - If the new current was lower, then the resolution of the possible current values would be low since there are only 32 IRUN/IHOLD steps. - If the new current was higher, it wouldn't actually work since IRUN and IHOLD are capped at 31, so it wouldn't be possible to increase the current without increasing globalscaler. With this commit, the globalscaler is recalculated whenever necessary in order to ensure the correct range of IRUN/IHOLD is used. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Fix s2vs field formattersAlex Voinea2023-03-071-0/+4
| | | | | Rename the field formatter text for tmc2208/tmc2209 and implement it also for tmc5160. Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
* tmc: Configurable microstep lookup table (#5920)Alex Voinea2022-12-211-0/+22
| | | | | | | 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: 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-54/+54
| | | | | | | | | | | | 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>
* tmc: Fix order of init during sensorless homingKevin O'Connor2021-02-281-0/+3
| | | | | | | | | | | 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>
* tmc5160: Merge field formatters into tmc2130.pyKevin O'Connor2021-02-271-5/+0
| | | | | | | | 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>
* tmc5160: Add set_current()/get_current() helpers to TMC5160CurrentHelperKevin O'Connor2021-02-271-14/+18
| | | | 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>
* tmc5160: Change the default for the pwm_freq field to zeroKevin O'Connor2020-05-241-1/+1
| | | | | | | The tmc5160 spec shows a default of zero, so use that same default for Klipper. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc5160: Use new GCodeCommand wrappersKevin O'Connor2020-05-051-18/+17
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc5160: Support setting GLOBALSCALER to fine tune current selectionKevin O'Connor2020-03-041-4/+22
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc5160: PWMCONF is write onlyPetri Honkala2019-12-041-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-2/+2
| | | 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>
* 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>
* config: Update tmc5160 block in example-extras.cfgKevin O'Connor2019-06-181-1/+0
| | | | | | | | | | List all the configurable parameters in the tmc5160 example block and use similar wording as the other tmc drivers. Also, don't allow DEDGE to be configured as it would just break the current 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-7/+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-19/+7
| | | | | | | | 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-9/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc5160: Move current setting code to its own helper classKevin O'Connor2019-06-101-66/+61
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc2130: Transmit register initialization during connect callbackKevin O'Connor2019-06-101-2/+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>
* tmc5160: Use TMCCommandHelperKevin O'Connor2019-06-101-46/+7
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc5160: Use tmc2130.MCU_TMC_SPI for low-level get/set_register accessKevin O'Connor2019-06-101-43/+13
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* tmc5160: Rename registers to Registers and fields to FieldsKevin O'Connor2019-06-101-87/+87
| | | | | | | Minor change to the code so that it is more similar to the other tmc drivers. 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>
* tmc5160: Add support for TMC5160 steppers (#1637)Stephan2019-05-201-0/+437
Signed-off-by: Stephan Oelze <stephan.oelze@gmail.com>