Sensorless homing - Leviathan v1.2 - TMC5160 - won't work

Basic Information:

Printer Model: Voron 2.4
MCU / Printerboard: Leviathan v1.2
Host / SBC: Nitehawk-SB
klippy.log

klippy(1).log (1.1 MB)

Describe your issue:

Hi all!

I’m in a bit of a pickle here. I was trying to setup sensorless homing and I tried several variations, but nothing seems to work. My gantry is already at the very top and I can’t seem to land on the right combo.

The LDO kit’s template already had a pin setup: diag0_pin: ^!*PG1, when that didn’t work I tried other variations:

#diag0_pin: PG1
#*diag1_pin: ^!PG1
*#*diag1_pin: ^!PG1

Nothing seems to work.

I was expecting: ”*SET_TMC_FIELD STEPPER=stepper_x FIELD=sgt VALUE=-64” + “G28 X0” to not even move because it was set to the maximum sensitivity… but every time it moved and I had to cancel out of that.

I also tried visualizing it through a .html file I found on this forum, but that didn’t work either:

I don’t know what else to do, please advise.

PS: I was following Klipper docs for sensorless homing, checked my Leviathan v1.2 pinout, and watched some videos.

Edit No2: waiiit… waiiit… I think I got it… Well, I don’t have it working yet, but I think I know what the issue is. It’s TMC auto tune. It has settings I need to tweak around, right?

[tmc5160 stepper_x]
cs_pin: PE15
spi_bus: spi4
diag0_pin: ^!PG1
interpolate: true
run_current: 0.8
sense_resistor: 0.075
stealthchop_threshold: 0
#driver_SGT: -64 # -64 is most sensitive value, 63 is least sensitive

[autotune_tmc stepper_x]
motor: ldo-42sth48-2004mah
tuning_goal: auto
extra_hysteresis: 0
tbl: 2
toff: 1
sgt: -64 # -64 is most sensitive value, 63 is least sensitive
sg4_thrs: 10 # CoolStep current regulation threshold
voltage: 2.9
overvoltage_vth: 0.0

Guess something like this? Idk. Gotta read this “Coolstep current” thing.

Hi @kawabunga ,

You need to set the endstop pin in your steppers to use sensorless homing.

[stepper_x]
endstop_pin: tmc5160_stepper_x:virtual_endstop

and do the same for Y.

I wouldn’t use TMC autotune while you’re tuning sensorless homing. Also, I found on my LDO Voron 2.4 that the stock microswitch homing was much more reliable than sensorless.

Sorry. Tunnel vision. I didn’t include that code snippet, but It was configured earlier on.

This is my full config as of now:

##################################################################################

B/A Stepper Settings

##################################################################################

|  Stepper  | Signal      | EN  | STEP | DIR  | DIAG | UART | CS   | SCK  | MOSI | MISO | SPI  |

|-----------|-------------|-----|------|------|------|------|------|------|------|------|------|

|     X     | HV_Stepper0 | PG0 | PB10 | PB11 | PG1  |      | PE15 | PE12 | PE14 | PE13 | spi4 |

|     Y     | HV_Stepper1 | PE9 | PF15 | PF14 | PE10 |      | PE11 | PE12 | PE14 | PE13 | spi4 |

##---------------------------------------------------------------------------------------

B Stepper - Left

Connected to HV STEPPER 0

Endstop connected to X-ENDSTOP

B/A MOTORS = LDO-42STH48-2004MAH(VRN) - NEMA 17, 0.9° Step Angle, 400 steps, 2 Amp

these motors are connected to the Leviathan v1.2 through 2x TMC5160 stepper drivers

##--------------------------------------------------------------------------------

## Stepper motor

[stepper_x]
step_pin: PB10
dir_pin: !PB11
enable_pin: !PG0
rotation_distance: 40
microsteps: 32
full_steps_per_rotation:400  #set to 200 for 1.8 degree stepper
endstop_pin: tmc5160_stepper_x:virtual_endstop
position_min: 0
position_endstop: 300
position_max: 300
homing_speed: 20   #Max 100
homing_retract_dist: 0 # was 5
homing_positive_dir: true

## Stepper driver

[tmc5160 stepper_x]
cs_pin: PE15
spi_bus: spi4
diag0_pin: ^!PG1
interpolate: true
run_current: 0.8
sense_resistor: 0.075
stealthchop_threshold: 0
#driver_SGT: -64 # -64 is most sensitive value, 63 is least sensitive

## TMC Auto tune

[autotune_tmc stepper_x]
motor: ldo-42sth48-2004mah
tuning_goal: auto
extra_hysteresis: 0
tbl: 2
toff: 1
sgt: -64 # -64 is most sensitive value, 63 is least sensitive
sg4_thrs: 10 # CoolStep current regulation threshold
voltage: 2.9
overvoltage_vth: 0.0

Also figured out I had to use: AUTOTUNE_TMC STEPPER=stepper_x sgt=-64 and confirmed it was working through DUMP_TMC STEPPER=stepper_x.

Just now I was testing with diag0_pin: PG1 and I’m now reverting to what LDO stock config has diag0_pin: ^!PG1.

Sorry my head / thoughts are a bit scrambled with this. It’s a 160+ page manual with a lot of new words and concepts and to complicate things even further I had TMC auto tuned installed which changed the default command to what I mentioned earlier on.

 09:17:38  $ G28 X0
09:17:42  $ M112
09:17:42  // Klipper state: Shutdown
09:17:43  !! Homing failed due to printer shutdown
09:17:51  $ FIRMWARE_RESTART
09:17:51  // Klipper state: Disconnect
09:18:00  $ DUMP_TMC STEPPER=stepper_x
09:18:00  // ========== Write-only registers ==========
09:18:00  // GLOBALSCALER: 00000043 globalscaler=67
09:18:00  // IHOLD_IRUN: 000c1f1f ihold=31 irun=31 iholddelay=12
09:18:00  // MSLUT0:     aaaab554 mslut0=2863314260
09:18:00  // MSLUT1:     4a9554aa mslut1=1251300522
09:18:00  // MSLUT2:     24492929 mslut2=608774441
09:18:00  // MSLUT3:     10104222 mslut3=269500962
09:18:00  // MSLUT4:     fbffffff mslut4=4227858431
09:18:00  // MSLUT5:     b5bb777d mslut5=3048961917
09:18:00  // MSLUT6:     49295556 mslut6=1227445590
09:18:01  // MSLUT7:     00404222 mslut7=4211234
09:18:01  // MSLUTSEL:   ffff8056 w0=2 w1=1 w2=1 w3=1 x1=128 x2=255 x3=255
09:18:01  // MSLUTSTART: 00f70000 start_sin90=247
09:18:01  // TPWMTHRS:   000fffff tpwmthrs=1048575
09:18:01  // TCOOLTHRS:  0000009c tcoolthrs=156
09:18:01  // THIGH:      00000011 thigh=17
09:18:01  // COOLCONF:   0040c462 semin=2 seup=3 semax=4 sedn=2 seimin=1 sgt=-64
09:18:01  // DRV_CONF:   00000400 bbmclks=4
09:18:01  // PWMCONF:    4f0e2991 pwm_ofs=145 pwm_grad=41 pwm_freq=2 pwm_autoscale=1 pwm_autograd=1 pwm_reg=15 pwm_lim=4
09:18:01  // TPOWERDOWN: 0000000a tpowerdown=10
09:18:01  // ========== Queried registers ==========
09:18:01  // GCONF:      00000008 multistep_filt=1
09:18:01  // CHOPCONF:   33110001 toff=1 tbl=2 tpfd=1 mres=3(32usteps) intpol=1 dedge=1
09:18:01  // GSTAT:      00000000
09:18:01  // DRV_STATUS: 811f0000 cs_actual=31 stallguard=1 stst=1
09:18:01  // FACTORY_CONF: 0000000f factory_conf=15
09:18:01  // IOIN:       30000050 drv_enn=1 sd_mode=1 version=0x30
09:18:01  // LOST_STEPS: 00000000
09:18:01  // MSCNT:      00000344 mscnt=836
09:18:01  // MSCURACT:   0064011e cur_a=-226 cur_b=100
09:18:01  // OTP_READ:   0000000f otp_fclktrim=15
09:18:01  // PWM_SCALE:  0000001d pwm_scale_sum=29
09:18:01  // PWM_AUTO:   0029001d pwm_ofs_auto=29 pwm_grad_auto=41
09:18:01  // TSTEP:      000fffff tstep=1048575

Sigh. Nothing. I don’t know what else to do.

I’ll stop testing now and allow y’all to help me with the latest info in hand.

The result of this G28 X0 at -64 sensitivity was the toolhead moved (bad) and didn’t stop with my finger (even worst). I stopped the printer (m112) and avoided damage.

Also… note the command is being applied: 09:18:01 // COOLCONF: 0040c462 semin=2 seup=3 semax=4 sedn=2 seimin=1 sgt=-64

Please advise.

According to your klippy.log, stepper_y still doesn’t have the virtual endstop configured. On CoreXY, you need both X and Y configured:

[stepper_y]
endstop_pin = PC2 # Change to tmc5160_stepper_y:virtual_endstop

facepalm! here I thought I was being extra careful configuring and testing just the X axis. Derp. I’ll do that. One sec.

1 Like
  1. BAstepper.cfg: ################################################################################ - Pastebin.com
  2. klippy.log (273.4 KB)

Same result as before

Sensorless homing on a core XY isn’t reliable.

Honestly, all I care about is the X axis.

Let me explain…

This little hook looking thing is were the drag chain attaches. Well, I’ve discovered that it’s the reason for several issues:

  1. Friction. Pushes drag chain outwards until the drag chain is touching the acrylic panel.
  2. Friction. This piece rubs against the drag chain and you can literally see white dust.
  3. Racking. While in use I can feel a hint of racking, it’s like the dragchain + hook thing exerts enough stress to the X axis that one of the two front idlers will be slightly racked (One or the other will have a slight play and some times not crash at all).

Sorry, It’s kind of hard to explain for me.

Seeing all the issues it was causing I figured I should just forgo the endstop switch and go sensorless homing.

What I find weird is that it’s not “unreliable” it’s not working at all.

Should I uninstall TMC auto tune? You think there is some issue there nobody is able to identify in my settings / klippy.log?

Investigating possible under amperage setting… currently running with 0.8, but the motors are rated for 2.0 amps.

 11:03:59  $ FIRMWARE_RESTART
11:04:00  // Klipper state: Disconnect
11:04:20  $ AUTOTUNE_TMC STEPPER=stepper_x sgt=-62
11:04:29  $ G28 X0
11:04:35  // Klipper state: Shutdown
11:04:36  !! Homing failed due to printer shutdown
11:05:53  $ FIRMWARE_RESTART
11:05:53  // Klipper state: Disconnect

Increased from run_current: 1.5 (last test) to run_current: 2.0 (this test)

11:06:29  $ AUTOTUNE_TMC STEPPER=stepper_x sgt=-60
11:06:35  $ G28 X0
11:06:39  // Klipper state: Shutdown
11:06:40  !! Homing failed due to printer shutdown

Same results. One day: https://www.youtube.com/watch?v=E0MoquKmN_M

???

Why do you say that? I’ve got five printers here that disagrees with you.

Now, I haven’t worked with TMC5160s but I’ve never had an issue with sensorless homing on CoreXY (or Cartesian) architectures.

EUREKA! Got working! One moment please.

What did I do? Disable TMC Auto tune.

No movement:

11:24:21  $ G28 X0
11:24:34  $ SET_TMC_FIELD STEPPER=stepper_x FIELD=sgt VALUE=-64
11:24:37  $ G28 X0

No movement:

11:24:21  $ G28 X0
11:24:34  $ SET_TMC_FIELD STEPPER=stepper_x FIELD=sgt VALUE=-40
11:24:37  $ G28 X0

Movement !!!

11:25:05  $ SET_TMC_FIELD STEPPER=stepper_x FIELD=sgt VALUE=-20
11:25:07  $ G28 X0

Movement, but unstoppable with my finger…

11:25:17  $ SET_TMC_FIELD STEPPER=stepper_x FIELD=sgt VALUE=20
11:25:20  $ G28 X0
11:25:30  $ m112
11:25:30  // Klipper state: Shutdown
11:25:31  !! Homing failed due to printer shutdown

I know, I know, this is just a bandaid fix. I will still need to dig into the auto tune settings when I get to re-enable it… but for now, this will allow me to work with the printer find the value and then make the switch.

UPDATE: Looks like the value is somewhere between 4 and 5. That’s a bit odd. Maybe there’s a setting somewhere in there that will allow for some granularity or maybe I need to add more parameters to the configuration file? Idk. Kinda lost. Help still needed.

Uploading my latest XY stepper config: stepper_ba.cfg (3.3 KB)

EDIT: I remember a youtuber saying something about slow speed. IIRCC it was something like a speed + stallguard balance. So I need to check for 3 sweet spots? Speed / StallGuard / Amps? Idk, testing this now.

from run_current: 0.8 <===> run_current: 2.0
from homing_speed: 20 <===>homing_speed: 100

Test No. 1
run_current: 1.4
homing_speed: 20

driver_SGT: -10 = no movement.
driver_SGT: 1 = slight movement, then stalls.
driver_SGT: 2 = unstoppable movement, had to halt the printer.

Test No. 2
run_current: 0.8
homing_speed: 20

driver_SGT: -10 = slight movement, then stalls..
driver_SGT: 0 = slight movement, then stalls..
driver_SGT: 1 = movement stops when it collides with my finger. :index_pointing_up:
driver_SGT: 2 = unstoppable movement, had to halt the printer.

Think we have a winner for the X (B) axis? Now for the Y axis…

Test No. 2
run_current: 0.8
homing_speed: 20

driver_SGT: -64 = slight movement, then stalls..
driver_SGT: -34 = slight movement, then stalls..
driver_SGT: -10 = slight movement, then stalls..
driver_SGT: 1 = movement stops when it collides with my finger. :index_pointing_up:
driver_SGT: 2 = unstoppable movement, had to halt the printer.

Okay. I think I found it? Not sure. Then If I need to increase the speed / current, I’ll have to tinker some more. If this is it let me know. I’ll keep testing until the BA motors are running with the spec sheet recommended of 2.0 Amps and I tune it to a higher speed.

It looks like you’re going about getting the threshold values for sensorless homing the correct way.

Dropping the current to 1/2 or less than the run current will allow you to select threshold values the way you are doing it there. You might want to try 0.6A to see if you get a larger range of driver_SGT values. Again, I haven’t worked with TMC5160s but with other Trinamic drivers I try to get a range of threshold values in which StallGuard works and then pick the middle one for reliability.

Personally, I keep the homing speed and current fairly low as I don’t want the carriage/toolhead ramming into the printer’s frame at full speed/force.

Thank you for replying. The low threshold was killing my confidence. I was feeling uneasy like I did something wrong. With your feedback I know I just have to keep pushing and tune it further. As it stands now, it homes.

This allows me to remove so may parts:

… and just having 2 cables (Stealthburner Nitehawk-SB usb cable + BA motor cable) really helps a lot when it comes to tuning the machine. You know… one less thing muddying up the waters.

Sorry but i have to raise my finger here. :nerd_face:

A too low homing speed and/or motor current can prevent the motor to create a proper back EMF that the TMC driver can sense.
That means you won’t have a good stall signal and trouble setting up sensorless homing.
I’m homing with normal motor current and higher speeds without issues.
During my first attempts I changed the motor current to 50% and used “normal” homing speeds but that was not working properly.

So not to have you home with 300 mm/s now but just to highlight it, that less is not always better!

Sorry, I should have been more explicit on that.

When doing Sensorless homing, I use 40%-50% of running current with 25mm/s homing speed (1"/s).

I just want to point out that running faster with more current can mechanically damage the printer.

Hysteresis. The physics of 2 motors, 2 belts, 3 linear rails, 10 or 12 belt pulleys. Stalling the motors always puts 0,0 on one corner of the hysteresis range. When printing the nozzle will be nearer (typically very near) the center of the range.

If your printer is well tuned you’ll be okay with senseless.