Skip to content

StallGuard Setup and Tuning

bdring edited this page Aug 16, 2021 · 14 revisions

StallGuard Setup and Tuning

Overview

Trinamic drivers have 2 basic modes. SteathChop is the super quiet mode and CoolStep is a mode where the driver can dynamically increase the current when the motor is under load. Since CoolStep can determine the load, in many cases it can sense when the motor is about to stall or has already stalled. For further reading, Trinamic has an app note about StallGuard.

It does this by measuring the ratio of energy sent to the motor and energy returned. As the load on a motor increases, less energy is returned. When the returned energy falls to a certain point, the driver will indicate a stall. Since there are many sources of power loss, like wiring and motor design, the driver allows you to set the level where the stall is indicated.

The method does not work at very low and very high speeds. You must test your system to determine a good speed to for stall detection to avoid missed stalls or false indications.

Is StallGuard right for you? At best it is accurate to about 1-2 full steps. Most basic switches will be more accurate. The accuracy may be fine for X and Y on a 3D printer or pen plotter, but probably not for a router or laser engraver. Due to it not working well at low and and high speeds, it is not recommended for use with hard limits (full time limit detection). It has not been tested with dual motor axes.

Setup

Grbl_ESP32 will setup the drivers to send the stall signal to the Diag1 pin on the drivers. You must make a connection from that pin to the limit switch input. Remove any physical switches on that circuit to prevent short circuiting the drivers circuit.

Some controllers like the 6 Pack have jumpers that connect the StallGuard signal from the driver to the switches. You will need to need to install the jumpers for the axes you are using. See more on the 6 Pack here.

Be sure your drivers have the pins install to mate with the 2 pin socket along the top of the stepper driver sockets.

The drivers must be in StallGuard mode during homing. Make sure you have this in your machine definition.

#define TRINAMIC_HOMING_MODE TrinamicMode :: StallGuard

Testing and Tuning

Turn on the display of StallGuard data with $Report/StallGuard=X. This will cause StallGuard data to be output to the USB/Serial port. It must use the serial port for best speed and timing of the data. The data will look like this. These are 4 readings directly before a stall was detected. Note: Only use this reporting when tuning. Turn off the reporting when running normal gcode.

[MSG:X  Axis SG_Val: 0168   Rate: 00400 mm/min SG_Setting:16]
[MSG:X  Axis SG_Val: 0087   Rate: 00400 mm/min SG_Setting:16]
[MSG:X  Axis SG_Val: 0070   Rate: 00400 mm/min SG_Setting:16]
[MSG:X  Axis SG_Val: 0000   Rate: 01000 mm/min SG_Setting:16]

This is what the values mean...

  • X Axis This is the axis being displayed
  • SG_Val: 0168 This is the current value of the StallGuard sensor. You want to get this to 0000
  • Rate: 00400 mm/min This is the current step rate Grbl_ESP32 is producing. This should be close to your $HomingSeek value, but will rise and lower due to acceleration and deceleration
  • SG_Setting:16 This is the current $xStallGuard setting.

Set the $HomingSeek and $Homing/Feed to a mid range value like 400mm/min. They should be set the same when using StallGuard.

Set the $StallGuardTuning to a typical value of 10.

Home using $HX. Add a load to the motor close to stalling it. Watch the values.

You want SG_Val: to drop to 0.

Try different speeds and $xStallGuard values.

Lower values = $xStallGuard lower make it more sensitive.

Try adjusting $xStallGuard up and down until you get a the best sensitivity without false triggers. Record your result.

Try different homing speed values with the same process.

Use the best combination of values you find.

Clone this wiki locally