This document is relevant to: Duet 2 WiFi / Ethernet, Duet 3 MB6HC and Duet 3 Mini 5+
Firmware versions: RepRapFirmware 1.2 and later (Duet 2 only), RepRapFirmware 3.1.1 and later
The TMC5160/2160 drivers (Duet 3 MB6HC and Duet 3 EB3HC), TMC2209 drivers (Duet 3 Mini 5+) and Trinamic TMC2660 drivers (Duet 2 WiFi / Ethernet) support the stallGuardTM feature. This feature allows the driver to detect motor stalls under some circumstances. Stall detection may be useful for detecting when a motor has skipped steps due to the nozzle hitting an obstruction, and for homing the printer without using endstop switches. RepRapFirmware 1.20 and later provides facilities for configuring and using stall detection.
The TMC2224 drivers on the Duet Maestro do not support stall detection.
Currently (RRF 3.2), stall detection on Duet 3 tool boards (Duet 3 TOOL1LC) and expansion boards (Duet 3 EB3HC) are not yet reported and cannot be used for homing. See Duet 3 with CAN expansion firmware configuration limitations.
|Board||Driver chip and Datasheet link||Microstep Interpolation||stealthChop||spreadCycle||stallGuard||coolStep|
|Duet 3 MB6HC / Duet 3 EB3HC||TMC2160 or TMC5160||Y||Y (SC2)||Y||Y (SG2)||Y|
|Duet 3 Mini 5+||TMC2209||Y||Y (SC2)||Y||Y (SG4)||Y|
|Duet 3 Toolboard||TMC2209||Y||Y (SC2)||Y||Y (SG4)||Y|
|Duet 2 WiFi and Ethernet||TMC2660||16x only||N||Y||Y (SG2)||Y|
|Duet 2 Maestro||TMC2224||Y||Y (SC2)||Y||N||N|
A rough figure for the minimum speed in full steps per second (M915 H parameter) for which you should be able to get reliable stall detection is given by this formula:
where full_steps_per_rev is 200 or 400 (for 1.8 or 0.9deg motors), currents are in amps, and holding torque is in Nm. From this it can be seen that stall detection at low speeds is easier at lower motor currents. This is one reason why motor current is often reduced during stall-detect homing.
Attempt to keep the speed above 40mm/s.
Stall detection is configured using the M915 command, The parameters are:
Additionally, the TMC2209 stepper driver used in Duet 3 Mini 5+ (and Duet 3 Tool board TOOL1LC once stallGuard is implemented in firmware), features stallGuard 4. This is optimised for operation with stealthChop, while its predecessor stallGuard 2 (TMC5160 and TMC2260) works with spreadCycle. You will need to adjust the speed at which stealthChop changes over to spreadCycle. This is set by M569 V parameter. The default is 2000.
Sensorless homing means not using endstop switches, but instead detecting the stall when the axis reaches the limit of its travel. Configuring sensorless homing requires some trial and error, as there are multiple variables to adjust and tune in. Prior to beginning this, open the Gcodes to better understand the commands being used.
M574 X1 S3and
M574 Y1 S3sets the X and Y endstops to sensorless homing at the axes low end. This is required.
M915 X Y R0 F0. This sets up the last main command needed for sensorless homing. Save your changes. Do not press "yes" for restart. There are other changes that must still be made.
The next step is to change your homing files for X and Y ("homex.g" and "homey.g", and portions of "home all" if X and Y of your ""homeall.g" is configured in such a manner. Sensorless homing requires the use of the M913 command. M913 allows one to control the miliamps (mA) from the maximum (100%) of the M906 command found in config.g. M906 controls the motor currents, while M913 controls the percent of that motor current that is running.
Your homex.g should look something like this:
M400 ; Wait for current moves to finish M913 X70 Y70 ; drop motor current to 70% M400 G91 ; relative positioning G1 H2 Z10 F12000 ; lift Z relative to current position G1 H1 X-320.5 F10000 ; move quickly to X axis endstop and stop there (first pass) G1 H2 X5 F12000 ; go back a few mm G1 H1 X-320.5 F7000 ; move slowly to X axis endstop once more (second pass) G1 H2 Z-10 F6000 ; lower Z again G90 ; absolute positioning M400 M913 X100 Y100 ; return current to 100% M400
Your "homey.g" should look the same as this, just with Y variables instead of X. For "homeall.g" be sure to include the M400 M913 M400 at the beginning and end of the X and Y portions of "homeall.g."
For another example, M913 X40 Y70 would command 40% and 70% of the total power found in the M906 command in config.g respective of X and Y.
In the example in step 2, the F parameters of the G1 commands for X and Y are quite high. This is because for sensorless homing, your printer must obtain a minimum required speed. Keep F above 3600 (3600mm/min or 60mm/sec). Save your changes.
Motor stalls are more easily identified by the firmware and quieter if the motor current is low. Using your existing motor current setting (M906 in config.g), configure your motor current reduction using the first M913 in the homing files. This is done through editing X and Y values which set the motor current to use during homing as a percentage of the M906 setting. Try to use as low a current as possible, such that the axis still moves with other settings (eg acceleration, jerk) set normally. For example, if your X and Y motors were set to 1000mA in M906, try M913 X40 Y40 for 400mA on each axis. Save your changes.
At this point, restart your Duet board.
The homing files that you change should be X and Y or "home all" and X and Y
At this point if you are getting a "crash" you should dial down the F parameter in the G1 commands or reduce the percentage of current that is used for sensorless homing (M913). Test and retest until satisfied.
Stall detection works in a very similar manner to Sensorless Homing, though tuning stall detection to work at normal motor current is much harder than stall detection at the reduced current used for sensorless homing.
If you are going to use sensorless homing AND stall detection, move the M915 command that you use for sensorless homing to the start of each homing macro, and add a second M915 command at the end of each homing macro that reverts the setting to stall detection. Put the M915 command for stall detection in config.g, as outlined below
This include the necessary changes for config.g, rehome.g, and your slicer of choice
M915 is a powerful command. It controls a dynamic system with many parameters. It is imperative to understand it. For a testing baseline, set your rehome.g M915 command to M915 X Y S3 R1 F1. This parameter combination sets up the M915 command to report the stall detections and to do nothing. Save changes.
This step requires the same M915 command that is in your rehome.g file be at the END of your STARTING gcode script in your slicer of choice. Place it at the end of your start script gcode commands.
This step is really finishing the work in Step 2. This tells the slicer and gcode file to set the M915 command back to sensorless homing instead of using stall detection. This is important because otherwise your printer will crash into the axes limits without detecting a stall when X and/or Y home at the end of a print.
This step requires that you make quite a few test prints. I recommend something like the benchy. Make sure your print speed is set high enough, or stall detection will not work. Try and stay above 40mm/s. Keep first layer slow for adhesion purposes.
This is where it gets a little difficult. Stall detection can be a little tricky to calibrate.
This is not a one and done procedure, as each printer is a little different. There are five different variables to be concerned about at this point:
A baseline range for these commands (all found in your config.g) can be found below.:
M906 X300-500 Y300-500
M201 X300-500 Y300-500
M566 X300-800 Y300-800
These commands may also be changed from the terminal, which I highly recommend you do during your test prints. I have found my best results with stall detection with the above ranges.
Step 4 starts by making sure your M915 command in your rehome.g and slicer is M915 X Y S3 R1 F1. Start off by making sure the above listed commands are at the highend of the range. Once your print is going and stall detection is flashing in the console, start lowering each variable one at a time by 100. If you reach the bottom of the range and your stall detection is still triggering frequently, you need to lower your sensitivity.
Sensitivity is lowered by adjusted the M915 S parameter. A bigger number means less sensitivity. I recommend jumping from M915 S3 to M915 S7. When changing M915, remember, you must change it in your rehome.g file and your slicer.
NOTE 1: If you are at the bottom of the above range and you are still getting lots of false stall reports in the Duet Web Control's console, you need to decrease the sensitivity. Remember, a larger M915 Sn in your slicer and rehome.g file are required to test the change in sensitivity.
NOTE 2: When checking the console for false stall reports, motors will be listed as numbers, not traditional axis letters. This means Drive 0 is X, Drive 1 is Y, Drive 2 is Z, Drive 3 is E0, Drive 4 is E1.
Do not change your belt tension if it is not too tight. Once you have increased these parameters, run the last test print with the same sensitivity settings in M915 Sn. This will help fine tune your stall detection. If you are not getting any false stalls at this point, increase your sensitivity by one unit (remember, that means M915 Sn is smaller) and run a new test print with this new sensitivity. If you get no false stalls, continue decreasing the sensitivity until you trigger false stalls, and begin with Step 4 again.
A hard stall is when the print carriage or the print bed "crashes" or "jolts," resulting in a the print continuing, just in the wrong place. To mimick a hard stall, use a gloved hand (be super careful to not burn yourself! always safety) to jerk the print bed in another direction. If your print is moving fast enough, and your stall detection settings are dialed in, you will see a stall detection report regarding the axis you mimicked a hard stall on.
If you have no detection of the hard stall, be sure to go back to step 4, and also make sure to increase your print speed at this point. If 40mm/s is too slow for you, jump to 50mm/s.
Once you are satisfied, there is one more change to make. You must now change the Rn parameter of M915. M915 R1 must be changed to R2 or R3. M915 Sn R2 will pause the print and wait for you to press resume. M915 R3 will pause your print, rehome, and then resume. This must be changed in rehome.g and in your beginning slicer gcode script.
In firmware 1.20 and later you can use extruder motor stall detection to feed filament into the hot end until resistance is encountered. Here's how.
If you try to push filament too fast through the hot end, or when the hot end is cold. Your normal extruder motor current may already be suitable, but you may want to use a lower one.
Find the speed that causes motor stall to be reported when you extrude fast and resistance is encountered, but that is not triggered during normal acceleration at the start of a filament feeding move.
It may be helpful to use M122 to look at the SG min or SG max value when you send a large extrusion move and resistance is not encountered, and when resistance is encountered and the motor skips steps. The lower the reported SG value, the higher the load; and vice versa. The relationship between the SG value and the M913 S parameter depends on the driver chip:
Use M915 and the stall detection threshold you found.
Here is an example file:
; Load T0 with PLA G10 P0 S200 R160 ; set temperatures for PLA T0 ; select tool M116 ; wait for temperatures to be reached G1 E-0.3 F300 ; retract a little filament M400 ; wait for move to finish before changing current M915 E0 S3 ; set stall sensitivity M913 E30 ; motor current to 30% M83 ; relative extrusion G1 H1 E800 F6000 ; feed up to 800mm until stall M913 E100 ; restore normal motor current G1 E50 F120 ; extrude 50mm @ 2mm/sec
Known bug in firmware 1.20 and 1.21: if you send a G1 H1 E command on a delta machine and the printer is in absolute XYZ coordinate mode, it will fail with error "G0/G1: attempt to move delta motors to absolute positions". This is fixed in firmware version 2.0 and later. The workaround is to use G91 to set relative motion before doing the G1 H1 E command. Don't forget to use G90 to set it back to absolute afterwards if your macro subsequently does any XYZ movement commands!