Overhauled state machine. New safety door feature.

- Overhauled the state machine and cleaned up its overall operation.
This involved creating a new ‘suspend’ state for what all external
commands, except real-time commands, are ignored. All hold type states
enter this suspend state.

- Removed ‘auto cycle start’ setting from Grbl. This was not used by
users in its intended way and is somewhat redundant, as GUI manage the
cycle start by streaming. It also muddled up how Grbl should interpret
how and when to execute a g-code block. Removing it made everything
much much simpler.

- Fixed a program pause bug when used with other buffer_sync commands.

- New safety door feature for OEMs. Immediately forces a feed hold and
then de-energizes the machine. Resuming is blocked until the door is
closed. When it is, it re-energizes the system and then resumes on the
normal toolpath.

- Safety door input pin is optional and uses the feed hold pin on A1.
Enabled by config.h define.

- Spindle and coolant re-energizing upon a safety door resume has a
programmable delay time to allow for complete spin up to rpm and
turning on the coolant before resuming motion.

- Safety door-style feed holds can be used instead of regular feed hold
(doesn’t de-energize the machine) with a ‘@‘ character. If the safety
door input pin is not enabled, the system can be resumed at any time.
This commit is contained in:
Sonny Jeon
2015-02-11 21:19:00 -07:00
parent 20c7750dab
commit 4bdc20ffb9
16 changed files with 237 additions and 92 deletions

View File

@ -48,15 +48,35 @@ ISR(CONTROL_INT_vect)
if (pin) {
if (bit_istrue(pin,bit(RESET_BIT))) {
mc_reset();
} else if (bit_istrue(pin,bit(FEED_HOLD_BIT))) {
bit_true(sys.rt_exec_state, EXEC_FEED_HOLD);
} else if (bit_istrue(pin,bit(CYCLE_START_BIT))) {
bit_true(sys.rt_exec_state, EXEC_CYCLE_START);
#ifndef ENABLE_SAFETY_DOOR_INPUT_PIN
} else if (bit_istrue(pin,bit(FEED_HOLD_BIT))) {
bit_true(sys.rt_exec_state, EXEC_FEED_HOLD);
#else
} else if (bit_istrue(pin,bit(SAFETY_DOOR_BIT))) {
bit_true(sys.rt_exec_state, EXEC_SAFETY_DOOR);
#endif
}
}
}
// Returns if safety door is ajar(T) or closed(F), based on pin state.
uint8_t system_check_safety_door_ajar()
{
#ifdef ENABLE_SAFETY_DOOR_INPUT_PIN
#ifdef INVERT_CONTROL_PIN
return(bit_istrue(CONTROL_PIN,bit(SAFETY_DOOR_BIT)));
#else
return(bit_isfalse(CONTROL_PIN,bit(SAFETY_DOOR_BIT)));
#endif
#else
return(false); // Input pin not enabled, so just return that it's closed.
#endif
}
// Executes user startup script, if stored.
void system_execute_startup(char *line)
{
@ -95,6 +115,7 @@ uint8_t system_execute_line(char *line)
else { report_grbl_settings(); }
break;
case 'G' : // Prints gcode parser state
// TODO: Move this to realtime commands for GUIs to request this data during suspend-state.
if ( line[++char_counter] != 0 ) { return(STATUS_INVALID_STATEMENT); }
else { report_gcode_modes(); }
break;
@ -118,6 +139,10 @@ uint8_t system_execute_line(char *line)
report_feedback_message(MESSAGE_ALARM_UNLOCK);
sys.state = STATE_IDLE;
// Don't run startup script. Prevents stored moves in startup from causing accidents.
if (system_check_safety_door_ajar()) { // Check safety door switch before returning.
bit_true(sys.rt_exec_state, EXEC_SAFETY_DOOR);
protocol_execute_realtime(); // Enter safety door mode.
}
} // Otherwise, no effect.
break;
// case 'J' : break; // Jogging methods
@ -144,6 +169,14 @@ uint8_t system_execute_line(char *line)
if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) {
sys.state = STATE_HOMING; // Set system state variable
// Only perform homing if Grbl is idle or lost.
// TODO: Likely not required.
if (system_check_safety_door_ajar()) { // Check safety door switch before homing.
bit_true(sys.rt_exec_state, EXEC_SAFETY_DOOR);
protocol_execute_realtime(); // Enter safety door mode.
}
mc_homing_cycle();
if (!sys.abort) { // Execute startup scripts after successful homing.
sys.state = STATE_IDLE; // Set to IDLE when complete.