From 39e11b696f3f67904e595e379b89b9734999c374 Mon Sep 17 00:00:00 2001 From: Sonny Jeon Date: Thu, 18 Oct 2012 21:29:07 -0600 Subject: [PATCH] Hard limits code minor updates. - Fixed a bug that would not disable the steppers if a user issues a system abort during a homing cycle. - Updated the hard limit interrupt to be more correct and to issue a shutdown for the right situations when the switch has been triggered. - Added a status message to indicate to the user what happened and what to do upon a hard limit trigger. --- config.h | 6 +++--- limits.c | 27 +++++++++++++++++---------- motion_control.c | 2 +- nuts_bolts.h | 2 -- protocol.c | 3 +++ protocol.h | 1 + serial.c | 2 +- 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/config.h b/config.h index 73c4533..e5cc760 100755 --- a/config.h +++ b/config.h @@ -46,9 +46,9 @@ #define X_LIMIT_BIT 1 // Uno Digital Pin 9 #define Y_LIMIT_BIT 2 // Uno Digital Pin 10 #define Z_LIMIT_BIT 3 // Uno Digital Pin 11 -#define LIMIT_INT PCIE0 // Pin change interrupt settings -#define LIMIT_INT_vect PCINT0_vect -#define LIMIT_PCMSK PCMSK0 +#define LIMIT_INT PCIE0 // Pin change interrupt enable pin +#define LIMIT_INT_vect PCINT0_vect +#define LIMIT_PCMSK PCMSK0 // Pin change interrupt register #define SPINDLE_ENABLE_DDR DDRB #define SPINDLE_ENABLE_PORT PORTB diff --git a/limits.c b/limits.c index 0785fa5..8e0fa56 100755 --- a/limits.c +++ b/limits.c @@ -39,27 +39,34 @@ void limits_init() LIMIT_DDR &= ~(LIMIT_MASK); // Set as input pins LIMIT_PORT |= (LIMIT_MASK); // Enable internal pull-up resistors. Normal high operation. - if bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE) { - MCUCR = (1<\r\n")); break; default: printInteger(status_code); printPgmString(PSTR("\r\n")); @@ -141,6 +143,7 @@ void protocol_execute_runtime() // System alarm. Something has gone wrong. Disable everything until system reset. if (rt_exec & EXEC_ALARM) { + protocol_status_message(STATUS_HARD_LIMIT); while (bit_isfalse(sys.execute,EXEC_RESET)) { sleep_mode(); } bit_false(sys.execute,EXEC_ALARM); } diff --git a/protocol.h b/protocol.h index 559560c..82dc74c 100755 --- a/protocol.h +++ b/protocol.h @@ -29,6 +29,7 @@ #define STATUS_MODAL_GROUP_VIOLATION 5 #define STATUS_INVALID_COMMAND 6 #define STATUS_SETTING_DISABLED 7 +#define STATUS_HARD_LIMIT 8 #define LINE_BUFFER_SIZE 50 diff --git a/serial.c b/serial.c index a346cd3..a9a214e 100755 --- a/serial.c +++ b/serial.c @@ -166,7 +166,7 @@ ISR(USART_RX_vect) case CMD_CYCLE_START: sys.execute |= EXEC_CYCLE_START; break; // Set as true case CMD_FEED_HOLD: sys.execute |= EXEC_FEED_HOLD; break; // Set as true case CMD_RESET: - sys.alarm |= EXEC_ALARM; // Set alarm to allow subsystem disable for certain settings. + sys.execute |= EXEC_ALARM; // Set alarm to allow subsystem disable for certain settings. // TODO: When Grbl system status is installed, set position lost state if the cycle is active.