@@ -95,29 +95,46 @@ uint8_t limits_get_state()
9595// homing cycles and will not respond correctly. Upon user request or need, there may be a
9696// special pinout for an e-stop, but it is generally recommended to just directly connect
9797// your e-stop switch to the Arduino reset pin, since it is the most correct way to do this.
98- ISR (LIMIT_INT_vect ) // DEFAULT: Limit pin change interrupt process.
99- {
100- // Ignore limit switches if already in an alarm state or in-process of executing an alarm.
101- // When in the alarm state, Grbl should have been reset or will force a reset, so any pending
102- // moves in the planner and serial buffers are all cleared and newly sent blocks will be
103- // locked out until a homing cycle or a kill lock command. Allows the user to disable the hard
104- // limit setting if their limits are constantly triggering after a reset and move their axes.
105- if (sys .state != STATE_ALARM ) {
106- if (!(sys_rt_exec_alarm )) {
107- #ifdef HARD_LIMIT_FORCE_STATE_CHECK
108- // Check limit pin state.
98+ #ifndef ENABLE_SOFTWARE_DEBOUNCE
99+ ISR (LIMIT_INT_vect ) // DEFAULT: Limit pin change interrupt process.
100+ {
101+ // Ignore limit switches if already in an alarm state or in-process of executing an alarm.
102+ // When in the alarm state, Grbl should have been reset or will force a reset, so any pending
103+ // moves in the planner and serial buffers are all cleared and newly sent blocks will be
104+ // locked out until a homing cycle or a kill lock command. Allows the user to disable the hard
105+ // limit setting if their limits are constantly triggering after a reset and move their axes.
106+ if (sys .state != STATE_ALARM ) {
107+ if (!(sys_rt_exec_alarm )) {
108+ #ifdef HARD_LIMIT_FORCE_STATE_CHECK
109+ // Check limit pin state.
110+ if (limits_get_state ()) {
111+ mc_reset (); // Initiate system kill.
112+ system_set_exec_alarm (EXEC_ALARM_HARD_LIMIT ); // Indicate hard limit critical event
113+ }
114+ #else
115+ mc_reset (); // Initiate system kill.
116+ system_set_exec_alarm (EXEC_ALARM_HARD_LIMIT ); // Indicate hard limit critical event
117+ #endif
118+ }
119+ }
120+ }
121+ #else // OPTIONAL: Software debounce limit pin routine.
122+ // Upon limit pin change, enable watchdog timer to create a short delay.
123+ ISR (LIMIT_INT_vect ) { if (!(WDTCSR & (1 <<WDIE ))) { WDTCSR |= (1 <<WDIE ); } }
124+ ISR (WDT_vect ) // Watchdog timer ISR
125+ {
126+ WDTCSR &= ~(1 <<WDIE ); // Disable watchdog timer.
127+ if (sys .state != STATE_ALARM ) { // Ignore if already in alarm state.
128+ if (!(sys_rt_exec_alarm )) {
129+ // Check limit pin state.
109130 if (limits_get_state ()) {
110131 mc_reset (); // Initiate system kill.
111132 system_set_exec_alarm (EXEC_ALARM_HARD_LIMIT ); // Indicate hard limit critical event
112133 }
113- #else
114- mc_reset (); // Initiate system kill.
115- system_set_exec_alarm (EXEC_ALARM_HARD_LIMIT ); // Indicate hard limit critical event
116- #endif
134+ }
117135 }
118136 }
119- }
120-
137+ #endif
121138
122139// Homes the specified cycle axes, sets the machine position, and performs a pull-off motion after
123140// completing. Homing is a special motion case, which involves rapid uncontrolled stops to locate
0 commit comments