andrewmcgr / klipper_tmc_autotune

TMC stepper driver autotuning Klipper python extra
GNU General Public License v3.0
610 stars 132 forks source link

Sensorless Homing not working #12

Open seanmccully opened 1 year ago

seanmccully commented 1 year ago

Tried to use this with LDO 2504AH on Octopus v1.1 with TMC2209(s) and senseless homing doesn't appear to be working even with a value of 255 the X Axis is crashing into the gantry.

I add 2504ah to the motor_database.cfg but looks the same as 2504ac

`#####################################################################

Klipper TMC AutoTune

##################################################################### [include motor_database.cfg]

[autotune_tmc stepper_x] motor: ldo-42sth48-2504ah sg4_thrs: 255

Sensorless homing threshold, tune if using sensorless

voltage: 24.0

Motor supply voltage for this stepper driver

[autotune_tmc stepper_y] motor: ldo-42sth48-2504ah sg4_thrs: 255

Sensorless homing threshold, tune if using sensorless

voltage: 24.0

Motor supply voltage for this stepper driver

[autotune_tmc stepper_z] motor: omc-17hs19-2004s1 [autotune_tmc stepper_z1] motor: omc-17hs19-2004s1 [autotune_tmc stepper_z2] motor: omc-17hs19-2004s1 [autotune_tmc stepper_z3] motor: omc-17hs19-2004s1

[autotune_tmc extruder] motor: ldo-36sth20-1004ahg`

andrewmcgr commented 1 year ago

Do you use the Voron-standard sensorless homing macro, or something like it, that reduces current while homing?

e.g. (working example, but note it's for 2240, change the driver type):

[gcode_macro _HOME_X]
gcode:
    # Always use consistent run_current on A/B steppers during sensorless homing
    {% set RUN_CURRENT_X = printer.configfile.settings['tmc2240 stepper_x'].run_current|float %}
    {% set RUN_CURRENT_Y = printer.configfile.settings['tmc2240 stepper_y'].run_current|float %}
    {% set HOME_CURRENT = 0.4 %}
    SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT}
    SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT}
    # dump_tmc stepper=stepper_x

    # Home
    G28 X
    # Move away
    G91
    G1 X-10 F1200
    G90

    # Wait just a second… (give StallGuard registers time to clear)
    G4 P1000
    # Set current during print
    SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X}
    SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y}

[gcode_macro _HOME_Y]
gcode:
    # Set current for sensorless homing
    {% set RUN_CURRENT_X = printer.configfile.settings['tmc2240 stepper_x'].run_current|float %}
    {% set RUN_CURRENT_Y = printer.configfile.settings['tmc2240 stepper_y'].run_current|float %}
    {% set HOME_CURRENT =0.4 %}
    SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT}
    SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT}

    # Home
    G28 Y
    # Move away
    G91
    G1 Y-10 F1200
    G90

    # Wait just a second… (give StallGuard registers time to clear)
    G4 P1000
    # Set current during print
    SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X}
    SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y}

[homing_override]
set_position_z:10
axes: xyz
gcode:
  {% set home_all = 'X' not in params and 'Y' not in params and 'Z' not in params %}

  {% if home_all or 'Z' in params %}
    G91
    G1 Z20 F600
    G90
  {% endif %}

  {% if home_all or 'X' in params or 'Z' in params %}
    _HOME_X
  {% endif %}

  {% if home_all or 'Y' in params or 'Z' in params %}
    _HOME_Y
  {% endif %}

  {% if home_all or 'Z' in params %}
    G0 X175 Y175 F3600
    G28 Z
    G1 Z10
  {% endif %}
seanmccully commented 1 year ago

Just now seeing this, but more or less the same MACRO except I initially had set HOME_CURRENT =0.7 in mine and tried 0.4 but still seeing the same.

gcode_macro _HOME_X]
gcode:
    # Always use consistent run_current on A/B steppers during sensorless homing
    {% set RUN_CURRENT_X = printer.configfile.settings['tmc2209 stepper_x'].run_current|float %}
    {% set RUN_CURRENT_Y = printer.configfile.settings['tmc2209 stepper_y'].run_current|float %}
    {% set HOME_CURRENT = 0.4 %}
    SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT}
    SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT}

    # Home
    G28 X
    # Move away
    G91
    G1 X-10 F1200

    # Wait just a second… (give StallGuard registers time to clear)
    G4 P1000
    # Set current during print
    SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X}
    SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y}

[gcode_macro _HOME_Y]
gcode:
    # Set current for sensorless homing
    {% set RUN_CURRENT_X = printer.configfile.settings['tmc2209 stepper_x'].run_current|float %}
    {% set RUN_CURRENT_Y = printer.configfile.settings['tmc2209 stepper_y'].run_current|float %}
    {% set HOME_CURRENT = 0.4 %}
    SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT}
    SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT}

    # Home
    G28 Y
    # Move away
    G91
    G1 Y-10 F1200

    # Wait just a second… (give StallGuard registers time to clear)
    G4 P1000
    # Set current during print
    SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X}
    SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y}
seanmccully commented 1 year ago

Comparing DUMP_TMC with and without autotune enabled, I see a few differences.

AutoTune

========== Write-only registers ==========
10:01 PM
SLAVECONF: 00000200 senddelay=2
10:01 PM
IHOLD_IRUN: 000c1c1c ihold=28 irun=28 iholddelay=12
10:01 PM
TPWMTHRS: 000000ff tpwmthrs=255
10:01 PM
TPOWERDOWN: 00000014 tpowerdown=20
10:01 PM
SGTHRS: 00000050 sgthrs=80
10:01 PM
TCOOLTHRS: 00000125 tcoolthrs=293
10:01 PM
COOLCONF: 00002264 semin=4 seup=3 semax=2 sedn=1

No AutoTune

========== Write-only registers ==========
9:57 PM
SLAVECONF: 00000200 senddelay=2
9:57 PM
IHOLD_IRUN: 00081c1c ihold=28 irun=28 iholddelay=8
9:57 PM
TPWMTHRS: 000fffff tpwmthrs=1048575
9:57 PM
TPOWERDOWN: 00000014 tpowerdown=20
9:57 PM
SGTHRS: 0000002d sgthrs=45
andrewmcgr commented 1 year ago

Ok, can you update to the current version and try again?

seanmccully commented 1 year ago

Tried with latest commits with stealth enabled and disabled, but still not able to get senseless homing working.

locki-cz commented 1 year ago

tryed but it doesnt work: driver_SGTHRS: 90 is for TMC2209 driver_SGT: is for TMC2130/TMC2660/TMC5160

added to sensorles homing macro values for x and y:

SET_TMC_FIELD FIELD=SGTHRS STEPPER=stepper_x VALUE=90

SET_TMC_FIELD FIELD=SGTHRS STEPPER=stepper_y VALUE=90

and it works :)

if there will be some fix let me know!

SinisterRj commented 1 year ago

Same problem here, even typing SET_TMC_FIELD STEPPER=stepper_x FIELD=SGTHRS VALUE=255 on the console before the G28 X0, the toolhead crashes. I'm using 2209 with moons-ms14hs5p4150:

Here is my configuration:

[autotune_tmc stepper_x] motor: moons-ms14hs5p4150 sg4_thrs: 255

and the voron homming macro:

[gcode_macro _HOME_X] gcode:

Always use consistent run_current on A/B steppers during sensorless homing

{% set RUN_CURRENT_X = printer.configfile.settings['tmc2209 stepper_x'].run_current|float %}
{% set RUN_CURRENT_Y = printer.configfile.settings['tmc2209 stepper_y'].run_current|float %}
{% set HOME_CURRENT = 0.7 %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT}

# Home
G28 X
# Move away
G91
G1 X-10 F1200

# Wait just a second… (give StallGuard registers time to clear)
G4 P1000
# Set current during print
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y}

[gcode_macro _HOME_Y] gcode:

Set current for sensorless homing

{% set RUN_CURRENT_X = printer.configfile.settings['tmc2209 stepper_x'].run_current|float %}
{% set RUN_CURRENT_Y = printer.configfile.settings['tmc2209 stepper_y'].run_current|float %}
{% set HOME_CURRENT = 0.7 %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT}

# Home
G28 Y
# Move away
G91
G1 Y-10 F1200

# Wait just a second… (give StallGuard registers time to clear)
G4 P1000
# Set current during print
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y}
Disttrack commented 1 year ago

I have the same problem with tmc2209

[motor_constants stepperOnline-17ME15-1504S]
# Coil resistance, Ohms
resistance: 2.00
# Coil inductance, Henries
inductance: 0.0025
# Holding torque, Nm
holding_torque: 0.30
# Nominal rated current, Amps
max_current: 1.5
# Steps per revolution (1.8deg motors use 200, 0.9deg motors use 400)
steps_per_revolution: 400

[autotune_tmc stepper_x]
motor: stepperOnline-17ME15-1504S
sg4_thrs: 130

[autotune_tmc stepper_y]
motor: stepperOnline-17ME15-1504S
sg4_thrs: 130
headmeister commented 1 year ago

Had the same issue. When optimized by the script, the TMC drivers either generate less EMF so it does not detect stall at all or it has issues. In order to resolve this I had to ensure two things:

With threshold of 160 for X and Y motors I was finally able to home.

crazy-daddy commented 1 year ago

Can confirm it as well.

[tmc2209 stepper_x]
run_current: 1.1
driver_SGTHRS: 60

works, but

[motor_constants siboor-35sth52-1204a]
#Siboor BOM Voron 0.2 steppers
resistance: 2.3
inductance: 0.035
holding_torque: 0.36
max_current: 1.2
steps_per_revolution: 200

[tmc2209 stepper_x]
run_current: 1.1

[autotune_tmc stepper_x]
motor: siboor-35sth52-1204a
sgt: 63
sg4_thrs: 0

or any other sgt/sg4 combination (tried both just because) crash the toolhead.

SinisterRj commented 1 year ago

Can confirm it as well.

[tmc2209 stepper_x]
run_current: 1.1
driver_SGTHRS: 60

works, but

[motor_constants siboor-35sth52-1204a]
#Siboor BOM Voron 0.2 steppers
resistance: 2.3
inductance: 0.035
holding_torque: 0.36
max_current: 1.2
steps_per_revolution: 200

[tmc2209 stepper_x]
run_current: 1.1

[autotune_tmc stepper_x]
motor: siboor-35sth52-1204a
sgt: 63
sg4_thrs: 0

or any other sgt/sg4 combination (tried both just because) crash the toolhead.

My understanding is that you should use sg4_thrs parameter, not sgt with tmc2209 drivers. And when you define it to 0 it is the lowest sensibility, so the toolhead will crash. Try using 255 and normally the tool head will not move, so decrease this value to find the best setting.

Dorrin93 commented 1 year ago

I was able to avoid crashing by increasing speed to 50, but still can't make it work.

I have tmc2209 and ldo-42sth48-2004ac if that matters.

Riconec commented 1 year ago

so what is supposed way to tuning stallguard for 2209? I have driver_SGTHRS: 90 in usual tmc2209 settings. Should I remove it and use sg4_thrs in autotune section instead? not clear from readme

wdclub commented 1 year ago

This module could not work with the TMC2209 at all because the TMC2209 does not support SGT nor SG4_THRS.

xand3r40r93 commented 1 year ago

I have the solution - just disable CoolStep for homing.

  set_tmc_field stepper=stepper_x field=tcoolthrs value=1048575
  set_tmc_field stepper=stepper_y field=tcoolthrs value=1048575
dderg commented 1 year ago

for me increasing the homing speed helped

locki-cz commented 1 year ago

How it works for me on TMC2240 on 36V, moons motors from formbot kit:

CrispyBearcon commented 11 months ago

I have the solution - just disable CoolStep for homing.

  set_tmc_field stepper=stepper_x field=tcoolthrs value=1048575
  set_tmc_field stepper=stepper_y field=tcoolthrs value=1048575

do i need to reactivate coolstep again or is it automatically?

xand3r40r93 commented 11 months ago

I have the solution - just disable CoolStep for homing.

  set_tmc_field stepper=stepper_x field=tcoolthrs value=1048575
  set_tmc_field stepper=stepper_y field=tcoolthrs value=1048575

do i need to reactivate coolstep again or is it automatically?

of course!

CrispyBearcon commented 11 months ago

i found that the default value fo rtcoolthrs is 2000 is that correct?

WaschBaer0395 commented 8 months ago

i found that the default value fo rtcoolthrs is 2000 is that correct?

would like an answer to this too ... you read that coolstep should be disabled during homing yet nobody and nowhere is an info on what the default value is or how to even disable/enable it in a macro ...

pixel-shock commented 8 months ago

Same for me ... TMC2209 with Moons "moons-ms17hd6p420I-04"

No matter what I do ... my toolhead crashes into the gantry ... currently it's not usable for me 😞

[autotune_tmc stepper_x]
motor: moons-ms17hd6p420I-04
tuning_goal: performance
sg4_thrs: 82

[autotune_tmc stepper_y]
motor: moons-ms17hd6p420I-04
tuning_goal: performance
sg4_thrs: 75

[autotune_tmc stepper_z]
motor: moons-ms17hd6p420I-04
tuning_goal: performance

[autotune_tmc stepper_z1]
motor: moons-ms17hd6p420I-04
tuning_goal: performance

[autotune_tmc stepper_z2]
motor: moons-ms17hd6p420I-04
tuning_goal: performance

[autotune_tmc stepper_z3]
motor: moons-ms17hd6p420I-04
tuning_goal: performance

[autotune_tmc extruder]
motor: ldo-36sth20-1004ahg
tuning_goal: performance

[gcode_macro TMC_AUTOTUNE_DISABLE_COOLSTEP_BEFORE_HOMING]
gcode:
    set_tmc_field stepper=stepper_x field=tcoolthrs value=1048575
    set_tmc_field stepper=stepper_y field=tcoolthrs value=1048575

[gcode_macro TMC_AUTOTUNE_ENABLE_COOLSTEP_AFTER_HOMING]
gcode:
    set_tmc_field stepper=stepper_x field=tcoolthrs value=2000
    set_tmc_field stepper=stepper_y field=tcoolthrs value=2000
OscarCid commented 7 months ago

For

for me increasing the homing speed helped

For me this was the best solution, I increase the home speed to 60 and magic, I get the best sensorless Homming possible

yebo29 commented 4 months ago

I don't understand it, but homing speed update from 40 to 60 for x and y worked (for now). Wish I knew why.

hreality commented 2 months ago

Seems I was having a similar sensorless issue with 2209 after an install yest. I was running stock homing speeds (25) and changed to 45 and things started to behave.

selrahc13 commented 2 months ago

Thank you for this. I wonder if increasing the homing speed disables CoolStep, allowing sensorless to work? 60mm/s homing speed allowed it to work with my 2209.