diff --git a/klippy/extras/tmc2130.py b/klippy/extras/tmc2130.py index d5130cbf..cc4c8e12 100644 --- a/klippy/extras/tmc2130.py +++ b/klippy/extras/tmc2130.py @@ -279,6 +279,8 @@ class TMC2130: def get_register(self, reg_name): reg = Registers[reg_name] self.spi.spi_send([reg, 0x00, 0x00, 0x00, 0x00]) + if self.printer.get_start_args().get('debugoutput') is not None: + return 0 params = self.spi.spi_transfer([reg, 0x00, 0x00, 0x00, 0x00]) pr = bytearray(params['response']) return (pr[1] << 24) | (pr[2] << 16) | (pr[3] << 8) | pr[4] diff --git a/klippy/extras/tmc2660.py b/klippy/extras/tmc2660.py index 7f0c95d1..ae2b4ba8 100644 --- a/klippy/extras/tmc2660.py +++ b/klippy/extras/tmc2660.py @@ -225,6 +225,8 @@ class TMC2660: def get_response(self): reg = Registers["DRVCTRL"] val = self.regs["DRVCTRL"] + if self.printer.get_start_args().get('debugoutput') is not None: + return 0 params = self.spi.spi_transfer([((val >> 16) | reg) & 0xff, (val >> 8) & 0xff, val & 0xff]) pr = bytearray(params['response']) diff --git a/klippy/extras/tmc5160.py b/klippy/extras/tmc5160.py index 70736f2e..a2438dda 100644 --- a/klippy/extras/tmc5160.py +++ b/klippy/extras/tmc5160.py @@ -350,6 +350,8 @@ class TMC5160: def get_register(self, reg_name): reg = registers[reg_name] self.spi.spi_send([reg, 0x00, 0x00, 0x00, 0x00]) + if self.printer.get_start_args().get('debugoutput') is not None: + return 0 params = self.spi.spi_transfer([reg, 0x00, 0x00, 0x00, 0x00]) pr = bytearray(params['response']) return (pr[1] << 24) | (pr[2] << 16) | (pr[3] << 8) | pr[4] diff --git a/test/klippy/tmc.cfg b/test/klippy/tmc.cfg new file mode 100644 index 00000000..2a73ae58 --- /dev/null +++ b/test/klippy/tmc.cfg @@ -0,0 +1,85 @@ +# Test config for tmc drivers + +[stepper_x] +step_pin: PC0 +dir_pin: PL0 +enable_pin: !PA7 +step_distance: .005 +endstop_pin: tmc2130_stepper_x:virtual_endstop +position_endstop: 0 +position_max: 250 + +[tmc2130 stepper_x] +cs_pin: PG0 +microsteps: 16 +run_current: .5 +sense_resistor: 0.220 +diag1_pin: !PK2 + +[stepper_x1] +step_pin: PC3 +dir_pin: PL6 +enable_pin: !PA4 +step_distance: .005 +endstop_pin: ^PB6 + +[tmc2130 stepper_x1] +cs_pin: PG1 +microsteps: 16 +run_current: .5 +sense_resistor: 0.220 +diag1_pin: !PK2 + +[stepper_y] +step_pin: PC1 +dir_pin: !PL1 +enable_pin: !PA6 +step_distance: .005 +endstop_pin: tmc5160_stepper_y:virtual_endstop +position_endstop: 0 +position_max: 210 + +[tmc5160 stepper_y] +cs_pin: PG2 +microsteps: 16 +run_current: .5 +sense_resistor: 0.220 +diag1_pin: !PK7 + +[stepper_z] +step_pin: PC2 +dir_pin: PL2 +enable_pin: !PA5 +step_distance: .0025 +endstop_pin: ^PB4 +position_endstop: 0.5 +position_max: 200 + +[tmc2208 stepper_z] +uart_pin: PK5 +microsteps: 16 +run_current: .5 +sense_resistor: 0.220 + +[stepper_z1] +step_pin: PB5 +dir_pin: PK6 +enable_pin: !PH5 +step_distance: .0025 +endstop_pin: ^PH3 + +[tmc2660 stepper_z1] +cs_pin: PK1 +microsteps: 16 +run_current: .5 +sense_resistor: 0.220 + +[mcu] +serial: /dev/ttyACM0 + +[printer] +kinematics: cartesian +max_velocity: 300 +max_accel: 3000 +max_z_velocity: 5 +max_z_accel: 100 diff --git a/test/klippy/tmc.test b/test/klippy/tmc.test new file mode 100644 index 00000000..0cd1de17 --- /dev/null +++ b/test/klippy/tmc.test @@ -0,0 +1,41 @@ +# Tests for the tmc drivers +CONFIG tmc.cfg +DICTIONARY atmega2560.dict + +; Start by homing the printer. +G28 +G90 +G1 F6000 + +; Z / X / Y moves +G1 Z1 +G1 X1 +G1 Y1 + +; Test DUMP_TMC commands +DUMP_TMC STEPPER=stepper_x +DUMP_TMC STEPPER=stepper_x1 +DUMP_TMC STEPPER=stepper_y +DUMP_TMC STEPPER=stepper_z +DUMP_TMC STEPPER=stepper_z1 + +; Test INIT_TMC commands +INIT_TMC STEPPER=stepper_x +INIT_TMC STEPPER=stepper_x1 +INIT_TMC STEPPER=stepper_y +INIT_TMC STEPPER=stepper_z +INIT_TMC STEPPER=stepper_z1 + +; Test SET_TMC_CURRENT commands +SET_TMC_CURRENT STEPPER=stepper_x CURRENT=.7 +SET_TMC_CURRENT STEPPER=stepper_x1 CURRENT=.7 +SET_TMC_CURRENT STEPPER=stepper_y CURRENT=.7 +SET_TMC_CURRENT STEPPER=stepper_z CURRENT=.7 +SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT=.7 + +; Test SET_TMC_FIELD commands +SET_TMC_CURRENT STEPPER=stepper_x FIELD=intpol VALUE=0 +SET_TMC_CURRENT STEPPER=stepper_x1 FIELD=intpol VALUE=0 +SET_TMC_CURRENT STEPPER=stepper_y FIELD=intpol VALUE=0 +SET_TMC_CURRENT STEPPER=stepper_z FIELD=intpol VALUE=0 +SET_TMC_CURRENT STEPPER=stepper_z1 FIELD=intpol VALUE=0