Troubleshooting
Hard limit alarms on a GRBL controller: why debounce cannot clear them
Short answer
A GRBL hard limit alarm with hard limits enabled (setting 21) is latched by design: motion stops and the controller refuses further moves until reset and unlock. The debounce window (setting 26) and a capacitor across the switch only filter electrical bounce; neither clears the alarm nor backs the axis off. Clear the switch, reset, unlock, then home again to restore trustworthy machine coordinates.
On this page
- Why does a tripped limit switch stop the whole machine and raise an alarm?
- Can the debounce setting clear a hard limit alarm?
- Does a capacitor across the switch make the axis recover by itself?
- How do you recover from a hard limit alarm?
- Which GRBL settings govern limits, homing and recovery?
- Why does the input still read active when the switch is released?
- What is the decision for each case?
- Questions asked
A tripped limit switch on a GRBL machine stops motion and latches an alarm on purpose, and no debounce value or capacitor can clear it. The debounce setting (GRBL setting 26) filters contact bounce on the input wire; it cannot back the axis off the switch, reset the alarm state, or restore machine coordinates. The documented recovery is always the same sequence: stop sending motion, clear the switch, reset and unlock the controller, then run homing so the machine's position is known again. This article separates the three functions that get confused here — input filtering, alarm recovery and re-homing — then walks the checks for a machine whose alarm keeps coming back.
Why does a tripped limit switch stop the whole machine and raise an alarm? #
With hard limits enabled (GRBL setting 21 at 1 in this setup), the controller treats any active limit input outside a homing cycle as a fault: motion halts at once and the controller refuses further moves until it is reset and unlocked, because the machine has reached a stop it must not pass.
Homing is the exception. During a homing cycle (setting 22 at 1 here) the switches are the inputs the cycle is looking for, and finding one is success, not a fault. Trip a switch in any other state and the machine has to be re-homed before position-dependent motion resumes: the stored coordinates describe a machine that has stopped somewhere the program never intended, possibly with steps lost.
One safety point belongs here. That latching is the protection working: a hard limit stops overtravel and crashes. Treat the alarm as a stop, not a nuisance, and never disable hard limits or wire around the switches to make it go away.
Can the debounce setting clear a hard limit alarm? #
No — setting 26 is a time filter on the input, reported as 250 milliseconds in this setup: it requires a switch transition to hold steady before the controller trusts it, and it issues no motion and clears no alarm.
Debounce exists because a mechanical contact does not close once. The blades bounce during the transition, so the raw pin can toggle several times; the firmware's debounce routine waits out that window and accepts the state it reads afterwards. That is input filtering, and it is all the setting does.
Worked example — what the window costs at speed (calculated example for these inputs, not a measured result). Take the values this setup reports: Z-axis rate (setting 112) at 1500 mm/min, X and Y rates (settings 110 and 111) at 3000 mm/min, and the debounce window (setting 26) at 250 ms. The rate settings read in millimeters per minute in the standard configuration, and a trip must hold through the window before the controller acts on it. At full rapid:
- Z: 1500 mm/min ÷ 60 = 25 mm/s; one full window costs 25 mm/s × 0.25 s = 6.25 mm of travel before the stop can begin.
- X and Y: 3000 mm/min ÷ 60 = 50 mm/s; the same window costs 50 mm/s × 0.25 s = 12.5 mm.
A longer debounce therefore delays every genuine trip by up to the whole window — it buys bounce immunity at the price of stopping travel. How far the axis then coasts after the trip is a separate sizing question; what an upper Z-axis limit switch needs for stopping clearance works that arithmetic for a Z axis.
Now compare the window with real bounce. Small mechanical switches commonly settle within a few milliseconds (rule of thumb), so the reported window is far more than bounce needs. If alarms still appear with it in place, the input is not bouncing — it is being held active or re-triggered, which moves the problem from settings to wiring.
Does a capacitor across the switch make the axis recover by itself? #
No — a capacitor only reshapes the electrical edge at the input, slowing its rise so that brief spikes can fail to register; the alarm lives in the controller's logic, which no passive part can reset, and no capacitor ever commands a reverse move.
That matches what this setup saw: a capacitor was fitted across the switch hoping for an automatic retreat and a self-clearing alarm, and the machine still stopped dead and stayed in alarm — a reported symptom, not a setting you can tune away. Filtering the edge and ending the alarm are different layers. The alarm is the firmware's decision that travel hit a stop, and only the documented recovery sequence ends it.
A capacitor can even get in the way. It slows every edge, including the fast switch pass and retreat that homing depends on, so a heavily filtered input can smear the short active window a seeking axis produces. If RC parts are fitted from an earlier attempt, remove or isolate them for a comparison and confirm the input still registers each press and release cleanly.
The behavior you actually want — the machine backing off the switch on its own — is motion, and an alarmed controller accepts none until it has been reset and unlocked. A direction-aware retreat off a tripped limit is a feature of machine controls that implement it deliberately; it is not something a passive part or a longer debounce can create.
How do you recover from a hard limit alarm? #
The documented path is always the same: stop the motion source, clear the switch, reset and unlock the controller, and run homing again — in that order, because the controller refuses motion while the alarm is latched and its coordinates are not trustworthy until homing finishes.
- Stop the motion source. The Python script talking over USB serial must halt its queue the moment it reads an alarm response; everything sent afterwards is refused, and a sender that mistakes the alarm for a completed move keeps pushing coordinates into the void.
- Clear the switch. Wind the carriage off the pressed switch — by hand with power off, or by jog once the sender allows motion again — and check every axis, because homing seeks all of them and one resting switch can fail the whole cycle.
- Reset and unlock the controller. GRBL consoles surface both as reset and unlock controls beside the status readout the moment an alarm appears; use them in that order rather than power-cycling and hoping.
- Home the machine (setting 22 at 1 enables the cycle) with the travel area clear. Each axis should find its switch and finish the pull-off retreat (setting 27 at 1.0 mm here) with the input released. The retreat follows the direction the homing settings define, so confirm it carries the carriage off the switch into free travel — a retreat toward the interior re-trips the switch and fails the cycle. If an axis overshoots its sensor during the seek instead of stopping on it, why a servo axis keeps moving past the home sensor is the closer diagnosis.
- Verify before resuming. Run a small, slow move near home, then press each switch deliberately at low speed and confirm motion still stops. Only then restart the program.
Which GRBL settings govern limits, homing and recovery? #
Six settings decide this behavior on this machine: setting 21 enables the hard limits that latch the alarm, setting 22 enables homing, setting 23 sets the homing seek direction, setting 5 sets limit input polarity for the normally-open switches, setting 26 sets the debounce window and setting 27 sets the pull-off retreat.
| Setting | Reported here | What it decides |
|---|---|---|
| Setting 21 | 1 | Hard limits enabled: an active limit outside homing halts motion and latches the alarm |
| Setting 22 | 1 | Homing enabled: the cycle that restores machine coordinates after recovery |
| Setting 23 | 0 | Homing seek direction, which also fixes the direction the pull-off retreat follows |
| Setting 5 | 1 | Limit input polarity inversion, matched to the normally-open switch wiring |
| Setting 26 | 250 | Debounce window in milliseconds: how long a switch transition must hold to be trusted |
| Setting 27 | 1.0 | Pull-off retreat in millimeters, so the homing cycle ends with the input released |
None of the six makes the controller move on its own. Motion after an alarm happens only through the recovery sequence above, and no combination of them turns a limit switch into an automatic reset.
Why does the input still read active when the switch is released? #
Order the checks from cheapest: confirm no carriage is physically resting on its switch, then watch the input state while operating each switch by hand, then flex the cables — because a held-active input from wiring or noise, not bounce, is what keeps an alarm returning.
The symptom that opens this article is the alarm returning after every recovery, or a trip with no carriage near an end of travel. Work the causes in order and confirm each before changing anything:
- Carriage parked on its switch. After a trip the machine rests exactly where the alarm caught it, often with a switch still pressed. Confirm: with motion disabled, watch the input status and move the axis off — the input should release with the carriage.
- Wiring or connector fault. A chafed cable, a loose terminal or a damaged lead holds an input active or makes it chatter. Confirm: operate each switch by hand and watch its state change once and hold; then flex the cable near the switch and at the controller and watch for flicker. An input that will not sit still has the same roots as the case in why a proximity switch turns on and off intermittently.
- Polarity mismatch. Setting 5 must match the switch wiring; with the inversion wrong, an input can read asserted at rest or never assert. Confirm: parked mid-travel with motion disabled, every limit input should read inactive — any input reading active at rest points at polarity or wiring before anything else.
- Electrical noise. Long unshielded switch runs routed beside motor cables, or a noisy USB link, can create transitions no debounce fully rejects. Confirm: check whether trips correlate with a spindle or drive starting; noise-driven false inputs share a failure pattern with the write-up on resolving GRBL Z-axis lost steps and USB noise.
- A capacitor smearing the edge. The filtered input can trail the real contact by enough to confuse homing's short active window. Confirm: compare the input status with the capacitor in circuit and removed; the raw input should track each press and release promptly.
Whatever the cause, the fix ends the same way: get the input reading inactive at rest, then reset, unlock and home. Debounce is tuned last, if at all — it treats measured bounce, not wiring.
What is the decision for each case? #
Keep hard limits enabled and treat the alarm as a stop-and-re-home event: recover with reset, unlock and homing; use debounce only to reject measured bounce; fix wiring, polarity or noise when inputs misread; and never expect a capacitor to move an axis.
- Genuine overtravel trip: let the alarm stand, clear the switch, reset, unlock, home — then find out why the program drove to the end of travel, because the limit did its job.
- Alarm re-trips right after recovery: a held or noisy input. Work the checks above in order, cheapest first.
- Want automatic recovery: build it into the sender as the supervised version of the documented sequence — stop on the alarm response, reset, unlock, jog clear, home — and never as an unattended retry against a physical stop.
- A capacitor or a longer debounce as the fix: take it off the plan. It filters an edge and nothing more.
Keep the limits on, fix the input, and recover by the documented sequence — that combination is what lets the machine stop safely and start again on coordinates you can trust.
Questions asked
Can my Python sender automate the reset and unlock after a limit alarm?
It can, and that is the right place for it: the sender should stop queueing motion when it sees the alarm response, perform the same documented reset and unlock, jog the axis clear only with the travel area confirmed, and run homing before sending program moves again. Keep hard limits enabled, and never let the script retry into a stop unattended.
What does the pull-off setting do during homing?
Setting 27 sets the short retreat after an axis finds its switch, so the homing cycle ends with the input released rather than held. With 1.0 mm reported here, a carriage that re-trips its switch right after homing may need a slightly longer retreat or a check of the seek direction, because the retreat follows the direction the homing settings define.
Are normally-open limit switches a good choice for hard limits?
They work with the matching polarity setting, as in this setup, but on a normally-open circuit a broken wire reads the same as a healthy, unpressed switch, so the fault hides. Normally-closed wiring makes a broken circuit read as a tripped limit, which is why it is the usual choice for a stop function. Either way, verify the idle input reads inactive.
How long should the debounce delay be for a mechanical limit switch?
Set it just above the bounce you actually need to reject. Small mechanical switches commonly settle within a few milliseconds (rule of thumb), so a short window usually filters them; the 250 ms reported in this setup is generous and mainly adds delay to genuine trips, up to the full window of stopping travel shown in the worked example.
Why must the machine be homed again after a hard limit alarm?
An alarm can stop the axes mid-move with steps lost or skipped, so the controller's stored machine coordinates may no longer match where the machine physically is. Homing re-establishes machine position from the switches and the pull-off retreats. Treat any coordinate that survived a hard limit trip as unproven until homing has run and finished cleanly.

