How to tune Stall Detection?

  • I am currently trying to tune stall detection on my cartesian printer.

    So I started by adding [c]M915 X Y Z S0 F0 R1[/c] to the config.g

    First thing I learned is that stall detection obviously does not work when moving the axis via Web Control. It seems to be only enabled when printing a g-code file. Is this correct? If so, why? This makes tuning the values very difficult.

    So I did some prints and changed the S value for each axis each time a stall detection was thrown. I suppose driver 0 is X, driver 1 is Y and 2 is Z.
    Btw: Is there a way toch see the axis for each driver number?
    I ended up with S12 for X and S16 for Y. But Z will never throw a false, even with S-10 which is supposed to be the lowest suggested value.

    So what is best practice to tune these values and get the correct values for all three axes?


  • administrators

    Stall detection is only enabled when printing a GCode file. It's not really possible to test it any other way, because you need the variety of moves that you get in a print to test it properly.

    The mapping of axes to drivers is determined by the M584 command. Send M584 with no parameters to show the existing parameters.

    If your Z axis never trigger stall detection, it probably means that your Z axis speed is configured such the the back emf of the motor is greater than the driver supply voltage at that speed. See (there is a link to a spreadsheet at the end).

  • So this means, Z is simply to fast?

  • administrators

    Use the link in my previous post to work out whether Z is too fast for stall detection to work, or not.

  • Unfortunately I do not know all the required information because there is no chart with all specifications available for my stepper motors. These are Anet 42SHDC3025-24B motors.
    Phase inductance is the one that is missing.

    I entered all values I know (left phase inductance as it was) and got these results:
    [c]Speed at which torque starts to drop (mm/sec), low slip angle 22,3
    Step pulse frequency at this speed and x16 microstepping 8,9
    Speed at which torque starts to drop (mm/sec), high slip angle 29,7
    Step pulse frequency at this speed and x16 microstepping 11,9

    So the maximum speed for stall detection should be 22,3 mm/s, right?
    My Z axis speed is 16.7mm/s but I never got a false stall detection with M915 Z S-10 F0 R1.
    Is this possible? I would like to make sure it works.

  • administrators

    You really do need the phase inductance. To estimate it, search a good range of stepper motors (e.g. the ones at for another Nema 17 motor with the same length and a similar phase resistance and rated current.

  • Well I tried to find similar stepper motors or other sources for the required information. After several hours I gave up now. I wrote the Anet support an email but to be honest, I do net expect to get a useful answer.

    So I could reduce the speed and try to find a speed where I get false stall reports, reduce the speed even more (additional -2mm/s or so) and tune the S value again. Would this work to give me precise stall detection?

  • What I did now is:
    I switched to using two stepper drivers (Z and E1) for my Z axis.
    I added axes U and V for Z1 and Z2. I zero them when Z is homed so homing does not throw errors.
    Changed [c]M915 Z S-10 F0 R1[/c] to [c]M915 P2:4 S-10 F0 R1[/c] just to be sure.

    What I expected:
    Using two drivers instead of one with the motors cinnected in series should double the maximum speed for stall detection. Is this correct?

    The result:
    Even at the very low speed of 5mm/s no false stall detections occur.

    I am stuck now 😕

    Now I wrote a gcode script that moves Z up and down with 5mm/s over and over again.
    No stalls detected.
    When I reduce the current of the motors to 20mA, it stopps moving up (obviously), but still no stalls are detected.
    M950 S was -50 during this test!

  • Well, no other suggestions?
    I need to make this work!

  • administrators

    Are you definitely running 1.20 or 1.21RC series firmware, on a Duet WiFi or Duet Ethernet?

  • Sure!

  • administrators

    What are your Z steps/mm?

  • It's 400 steps/mm

  • administrators

    From comparing other motors, I estimate the inductance of that motor to be about 8 to 10mH. What maximum Z speed at full torque does that give?

  • I am not 100% sure, if all the other values I have are correct.
    I took them from this site:

    I suppose by "maximum Z speed at full torque" you mean "Speed at which torque starts to drop (mm/sec), high slip angle".

    For 8mH this gives me 32,7mm/s and for 10mH it is 27,9mm/s.

  • No additional suggestions?
    This feature was one of the main reasons for buying the Duet 😕

  • administrators

    Is it just the Z motor that you can't get stall detection working on? Does it work on the X and Y motors? How about U?

  • It works on X and Y. I tuned the values until I got no more false detections. S22 seems to be the value to go on these axes.

    I tried [c]M915 Z S-50 F0 R1[/c] and [c]M915 P2:4 S-50 F0 R1[/c] for Z but never got stall detections on drives other than 0 and 1 (X and Y).

  • administrators

    I have added this to my list of pending investigations. I should get to it before the end of this coming week.

  • Great, thank you!

  • Any news on this already?

  • 😞

  • administrators

    Do you have one Z motor or two? If you have two, how are they connected?

  • administrators

    If you run M915 without parameters, what stall detect configurations does it report for drivers 2 and 4?

Log in to reply