SorterOS — Operate
StallGuard
How-to guideStop the machine when the chute or the classification channel stalls, and set how sensitive that check is. Record the motor running freely and held back, save the threshold the page works out, then check it.
AI-generated first draft. Written from SorterOS's own source, not from a running machine. It has no screenshots yet, and the wording on the page may have drifted since it was written.
StallGuard is the stall check built into each stepper motor's driver chip. The driver measures how hard the motor is working and reports it as a number called SG_RESULT. A free-running motor reads high, a motor that is loaded reads lower, and a motor held still reads near 0. When the reading falls to the trip level, the driver raises a stall, the firmware stops the motor, and SorterOS halts the machine with a stall incident. The hardware side is in Stall detection.
The StallGuard pages are where you set the trip level for one motor, so a real stall trips it and normal running does not.
Open it
There are two StallGuard pages, one under each motor:
- Settings, Chute, then StallGuard: the Chute StallGuard page.
- Settings, Classification channel, then StallGuard: the Classification channel StallGuard page. It tunes the classification channel's stepper.
The older address /settings/stepper-stallguard goes to the chute's page. The other channel steppers have no StallGuard page. The machine.toml reference lists the defaults a motor starts with and where they are saved.
The two pages are the same except for what only the chute has: Automatic tuning, a speed filled in from its operating speed, the random go-to-angle motion, and a link to its stress test.
Read the numbers
- Threshold (SGTHRS): a number from 0 to 255. A stall is reported when SG_RESULT is at or below twice this number. The page prints that line as "Trips when SG_RESULT is N or less". A higher threshold trips on a lighter load, so it is more sensitive. A lower one trips only on a heavier load.
- Speed floor (TCOOLTHRS): a number in TSTEP units, the time the driver takes for one 1/256 microstep. A smaller TSTEP is a faster motor. The driver checks for a stall only while TSTEP is at or under the speed floor, which is to say only above a certain speed. The page shows that speed as Checks above, in µsteps/s.
A motor that cruises slower than the speed floor allows is never checked. The page tells you so with Can't trip at this speed yet or StallGuard can't trip at this speed, and what speed it needs.
Automatic tuning (chute only)
Automatic tuning keeps the chute's threshold and speed floor set for you. While it is on, it learns how the chute reads in normal running, at the speed the chute runs at, and sets the trip level far under that and far over a stall. It learns again when the speed, the run current, the microstepping or the chopper mode changes.
- Tune automatically is the switch. It is disabled when StallGuard is off on this machine, and the panel says Not running: StallGuard is off on this machine.
- The badge shows the state: Off, Learning with a count of readings so far out of the readings needed, Tuned, Paused for a recording, or Working harder.
- When it is on, the panel lists Trips at, Normal running (a reading of "N or higher", or Still learning), Speed floor, Learned from a number of readings, and the Last change.
- Working harder than it did means normal running now reads lower than it used to. Check that the chute turns freely, then press Learn again. Learn again is also at the foot of the panel while tuning is on.
- Normal running is close to a stall means normal running reads so near the trip level that a stall still trips it but with little room.
A threshold or speed floor saved by hand turns automatic tuning off. So does Save and turn on StallGuard in step 4 below, which says so beside the button.
Tune it by hand
The Tune StallGuard panel takes five steps. It has a badge, Step N of 5, which turns to Tuned when the settings are saved. The steps follow what the machine has recorded, not what you clicked, so a reload (or another browser) shows the same step open. A finished step has a button to open it again (Change, Record again or Review).
Two steps move the motor. Steps 2 and 5 show Moves the motor. Keep clear. Step 3 asks you to hold the motor back by hand, with Hold only the part that turns. Let go if anything feels wrong. Nothing on these pages checks that the sorter is paused. They refuse only while the hardware is homing or a power stress test is running, and when that motor is busy. The sorter must also have started its hardware.
- Check the speed. Type the speed the motor runs at, in µsteps/s, in Speed. The chute fills this in with its operating speed (marked Operating speed, or press Use the operating speed). The classification channel starts at 1500, so type the speed it really runs at. A message under it says whether the saved settings Can trip at this speed, Can't trip at this speed yet (steps 2 to 4 fix it) or that StallGuard is off (step 4 turns it on). Press Tune at followed by your speed.
- Record the motor running freely. It runs normally with nothing holding it back. Press Record it running freely. It takes about the duration shown (4 s unless you change it). The step then reads, for example, "Running freely it reads N or higher."
- Record a stall. Press Record a stall, then hold the motor back until it stops, for the whole recording. While it records the page says Hold it now, until it stops. A real stall reads near 0. The step then reads "Held back, it dips to N." If the last recording could not be used, the step says why. Record it again.
- Review and save. The page shows the Threshold (SGTHRS) and Speed floor (TCOOLTHRS) it suggests, and for each says Saved or what it is now. Under them: Running freely (N or higher), Stall (N or lower), Trips at (N or lower) and Checks above. Press Save and turn on StallGuard. The trip level sits between the free-running floor and the stall dip, and the speed floor is set from the speed the motor actually reached in the recordings. If the page shows Not reliable at that speed, normal moves dip close to the trip line and it would false-trip. The button then reads Save anyway, and Record the stall again is offered. If the stall only dipped to a high reading, the page says to hold the motor until it stops.
- Check it (optional). Press Record a check for one more free run, compared against the saved settings. It reports Nothing would have tripped with the lowest reading and the trip level, or It would have stopped the machine with how many readings were at or under the trip level (record the stall again, or lower the threshold below), or Nothing to check if the motor never ran above the speed floor. On the chute, Open the stress test goes to the chute settings page for a test with detection on.
Only recordings made at the speed you are tuning, and with the motor's current run current, microstepping and chopper mode, count toward a suggestion. Change the speed and the steps look again at what is recorded for the new one. While a recording runs, stall detection is off for that motor, and is put back after.
The load curve
Below the steps, Load curve draws one recording as SG_RESULT over time, with the trigger line and the part of the recording where the driver would be checking. Lower means more load.
- Recording picks which one to show. It opens on the latest, and shows a new one the moment it is made. Each entry has a time, the kind (Free running or Stall), a label and a speed.
- Above the chart are the facts of the recording: motor, speed, direction, duration, mean SG, run current (IRUN), acceleration, microsteps, chopper (StealthChop or SpreadCycle), whether it was loaded, and the cruise TSTEP.
- CS_ACTUAL and TSTEP add those readings to the chart (TSTEP is on by default).
- Threshold suggestion lists the numbers behind step 4: Unloaded floor, Loaded dip, Trigger at or below, SGTHRS, Measured cruise TSTEP, Gate TCOOLTHRS and Real-motion floor. With no stall recorded at the speed yet, it says the numbers are provisional.
Stall detection
The Stall detection panel is the form the steps fill in. You can also use it directly.
- Tick StallGuard stall detection to halt the machine if this motor stalls, on every move, while it is on. The two fields below appear once it is ticked.
- Set Threshold (SGTHRS) (a slider, or type 0 to 255) and Speed floor (TCOOLTHRS). The line under them shows the trip level and the TSTEP limit those give.
- Press Save. The page confirms with Stall detection saved., and adds that it applies at the next start if the hardware is not running.
When Automatic tuning is on, the two numbers are not editable: the panel says they are set by automatic tuning, and Save changes only whether detection is on. Saving a different threshold or speed floor turns Automatic tuning off.
Expert tools
- Sweep options changes how steps 2, 3 and 5 move the motor. Motion is Constant spin, Pulsed with jitter, or on the chute Chute: random go-to-angle. Then Direction (Clockwise or Counterclockwise), Duration in seconds, and an optional Label. Random go-to-angle adds Min angle, Max angle and Min angle change. It homes the chute first if needed and stays within the chute's safe travel. Pulsed adds Pulse size, Dwell and Jitter every (0 turns jitter off). Cruise TSTEP sets which readings count as cruising, and when empty it follows the speed. A checkbox makes Enter start the recording of the open step. Each step shows what it will do and has Change how it moves to get here. The chute defaults to random moves between 10° and 340°. The classification channel defaults to short pulses.
- Past recordings lists every recording for this motor, newest first. Press a row to show it in the load curve. The Delete run button beside it asks Delete the run? and deletes the recording and its readings. The list shows the latest 8, and Show all shows the rest.
- Recorded readings gives the totals for this motor: Samples and when the last was taken, SG min, SG mean and SG max.
After a real stall
When the check trips in use, the motor stops and the machine halts. The motor's own page (the chute's page, or its channel's) shows an alert, stalled, with Clear the stall. Clear the jam first, then press it. A stall drops the motor's home position, so home it again before precise moves. The top bar's resume button stays disabled while a stall is unresolved, labeled Clear the motor stall before resuming. After a chute stall it stays disabled, labeled Re-home the chute before resuming, until the chute is homed again.