Sensorless Homing on Manta M4P not working

Basic Information:

Printer Model: Ender 3 Pro
MCU / Printerboard: BTT Manta M4P
Host / SBC: BTT CB1
klippy (2).log (100.7 KB)

Describe your issue:

Hello, im setting up a Manta m4p on my ender 3 pro with sensorless homing,
For some reason its not working everytime the stepper motor gets to the home position it wont stop moving and grind against the limit.

I had to configure the diag_pin: ^!PC0 negated, otherwise the virtual endstop is always triggered.

Here how i configured my printer stepper motor:

 [stepper_x]
step_pin: PC6
dir_pin: PA14
enable_pin: !PC7
microsteps: 16
rotation_distance: 40
#endstop_pin: ^PC0
endstop_pin: tmc2209_stepper_x:virtual_endstop
position_endstop: 0
position_max: 235
homing_speed: 50
homing_retract_dist: 0

[tmc2209 stepper_x]
uart_pin: PB12
run_current: 0.700
stealthchop_threshold: 999999
diag_pin: ^!PC0
driver_SGTHRS: 255

I followed BTT docs and added the jumpers to the J23 , J31, and J40 pins, removed the physical limit switch connectors and put the 2209 drivers in UART mode.

Unless its an hardware fault, i really don’t know how to debug this problem.
I don’t know if it would help but the physical switches works fine.

You need to adjust your driver_SGTHRS value - having at at 255 is much too high.

The value is generally unique to the situation (ie dependent on motor, current setting, pulley diameter, etc.). Start at 128 and change the value by 10 or so until you get good operation. It’s a bit of an art but with some patience you’ll get there.

Remember to restore your PC0 pin to the original value before changing driver_SGTHRS.

Resetting ^!PC0 to ^PC0 makes the endstop always triggered, so the printer wont home.
For the driver_sgthrs, i’ve tryed starting from 128 got as low as 20 and up to 200, the endstop is always triggered therefore no homing is performed by the printer.

Then i also tryed with ^!PC0 and starting from 128 got as low as 20 and up to 200 and nothing changed, now the homing works, but the stepper motor wont stop.

Edit:
Can my stepper motors wiring be the problem? the wiring is the stock from ender 3 pro stepper motors, maybe i need to check the connections??

Do you have the DIAG jumpers in place? You should not need the pull up enabled (the “^”).

Yes DIAG jumpers are in place, also removed the pullup from the pin nothing changes, same behaviour

I assume you have the correct ones:

Not only those for the stepper voltage:

I presume you mean you removed the pull up from the pin definition. You shouldn’t be modifying the board.

Please review what @EddyMI3D put in AND you might want to try lowering the current used during sensorless homing - I use 0.3A to 0.5A on my printers.

Yes , by removing pullup i intend removing the ^ from the pin definition in printer.cfg. I do not intend to modify the board as i dont have the knowledge to do so.

@EddyMI3D yes i did put the jumpers on the pins specified in BTT Wiki just above the voltages jumpers , the voltages jumpers where already in that position where i received the board, never touched them.

I will try to change the current of the steppers and give feedback

Hi everybody,

@mykepredko i lowered the voltages on the steppers, but no luck its not working

Here you can see the jumpers for the DIAG pins
(I removed my drivers for clearance)

You lowered “Voltage” or “Current”? It should be current.

Thank you for the image of the jumpers - they appear to be set correctly.

Could you explain the process you’re using to test sensorless homing as well as the values you’re using for the driver_SGTHRS and run_current parameters?

I would suggest that you just start with the X axis and go on to the Y axis when that is working.

I lowered the run_current on the printer cfg from 0.7 to 0.3.

To test the sensorless homing, i simply change the driver_SGTHRS starting from 128.
Lowering or raising the driver_SGTHRS does not make any difference the result is always the same:

The x axis will go to 0, and then the stepper wont stop, causing the toolhead to repeatedly hit the x axis limit switch (which is not connected to the motherboard and i plan to remove) so i must hit the emergency stop button on the web interface.

Now i tried not to stop to see what happens and the console gives me this:

No trigger on stepper_x after full movement

Just for reference i leave here my current x axis configuration:

[stepper_x]
step_pin: PC6
dir_pin: PA14
enable_pin: !PC7
microsteps: 16
rotation_distance: 40
#endstop_pin: ^PC0
endstop_pin: tmc2209_stepper_x:virtual_endstop
position_endstop: 0
position_max: 235
homing_speed: 50
homing_retract_dist: 0

[tmc2209 stepper_x]
uart_pin: PB12
run_current: 0.300
stealthchop_threshold: 999999
diag_pin: !PC0
driver_SGTHRS: 80

Pease attach a recent klippy.log to your next post.

How many values did you set driver_SGTHRS to?

In my post above, I wrote:

Again, the current and driver_SGTHRS values are unique to each situation. It takes a while and some experimentation to get it right.

When I do it, I set up a table to record the current and driver_SGTHRS settings that I’ve tried and use the results as clues as to figure out what values to try next.

Did you try setting it way up to 250? In that case the toolhead should not even start.

@bozzo yes i’ve tried , the toolhead moves to get to the zero position.

@mykepredko i started from 128 as suggested, doing -10 steps to until i got to around 28, same for +10 and i reached 228, i also tried 0 and 255 just in case.
Can you share any guide on how to tune this value? Anyway i thought that lowering would result in a less sensitive stepper and raising it should make the stepper more sensitive am i right?

@EddyMI3D klippy (3).log (61.3 KB) here my latest klippy log.

I don’t know if a can share links from google drive, but :

there you go, this a video i made yesterday.

Anyway thanks for the really fast answers and suggestions, never happened to me in a forum before. :slight_smile:

FWIW,
It could be tricky if done blindly and without at least knowing the motor characteristics.
Also, Klipper literally enables and disables diag pins on homing, which adds confusion on top of that.
And because it generally works, it is really hard to redo this thing, I suspect there will be no functional changes until homing is reimplemented in Klipper.

There is a PR with the Stallguard monitoring tool which could shine light on the actually SG values while motor is spinning.

From a configuration tuning perspective, it is more or less straightforward.
You first need to get the diag pin working, it could be hard, but it should start to at least trigger on high sensitivity, and it does not trigger on low.

Then, the only problem that you would have is literally the sensitivity configuration.
You generally want to have backEMF not zero, around 1V is already nice.

You generally want to understand how your SG value behaves.
Because, as stated in the PR and in the initial topic, it is tricky and speed-dependent, obviously.

Also, you have to be aware that Stallgurad4 used in TMC2209 is different to Stallguard2 used in TMC5160/2130, so they works and tunes slightly differently.

Also, because SG4 uses the StealthChop, there could be a minimum current limitation.
Like, with high probability, your low current settings have zero effect.

So, for example, with current defaults, where PWM_FREQ==0 (2/1024) and TBL == 2 (32).

Vm / VoHm * PWM_FREQ * TBL = Imin
24 / 2 * 2/1024 * 32 = 0.75A 

(I don’t know your motor parameters or supply voltages, so you could verify it for your installation).

Also, there is a trick, like with high motor inductance and high acceleration, the motor could trigger early. It could be workarounded by decreasing current, by setting the COOLSTEP threshold >20mm/s as is done on some Prusas.

Hope that helps a little.


BTW, it obviously should be generally easier to do on the Cartesian machines where the 1 motor drives one axis.

Just looking at your latest klippy.log - why are you inverting the DIAG pin:

[tmc2209 stepper_x]
uart_pin = PB12
run_current = 0.300
stealthchop_threshold = 999999
diag_pin = !PC0  # <=== Why is this inverted?  
driver_sgthrs = 120

You should just leave it as:

diag_pin = PC0  

I’ve watched your video - what happens if you start with the gantry in the middle position, not close to the end?

Finally, are you using TMC2209 chips on the Z Axis and Extruder? If you are, why don’t you specifiy the [tmc2209 statement?

@nefelim4ag thanks for the detailed infos, honestly i dont know much about 3d printers stuff just a beginner so it would take some time to understand everything you wrote anyway appreciated.

@mykepredko the DIAG pin is inverted because otherwise querying its status show that the x endstop is always triggered, and the result would be that when clicking the homing x button the current head position will become the new home position.

I am using tmc2209 on every axis and extruder, dont mind y,z and extruder because i am only testing on the X axis.

But i could try to complete the configuration on every axis and then test every axis, maybe the problem is isolated only on the x axis… i’ll test and give feedback in the next days.

EDIT:
this is my current x axis stepper motor:

on my y axis i have this:
https://electrowizard.net/bj42d15-26v10-stepper-motor-datasheet

and for z axis i need to unmount them from the frame, i dont have time right now.

So now that i have the datasheet i will try to check every wire to see if the pinout is correct compared to the manta m4p pinout for the stepper motors, just in case to exclude any hardware related problem. i’ll let you know in the next days

You can’t query it status from web or from console, like never.
Because for sensorless homing diag pin on the driver is only active while axis in homing.
Not before and not after.

This is the sort of confusion what I’ve talked about :slight_smile:

#diag_pin:
#   The micro-controller pin attached to the DIAG line of the TMC2209
#   chip. The pin is normally prefaced with "^" to enable a pullup.

As pointed in the config reference, there is no inversion on tmc2209.
That is it.

To make it clear, for TMC2209, your diag pin should look like that:

[tmc2209 stepper_x]
diag_pin: ^PC0

Ok , now i understand.

This was my initial config, which i copied from the klipper config, but seeing it not working i started to mess around with it. i will now keep it as ^PC0.