Fixed homing fail alarm handling. Re-integrated software debouncing.

- [bug] Fixed a homing fail issue, where the alarm was not being set
right, not cleared correctly. It would report the wrong code and enter
an infinite alarm loop. This was due to how alarm codes were altered a
while back. Now updated and fixed to show the right codes.

- [feature] Re-installed optional software debouncing for hard limit
switches. By request.
This commit is contained in:
Sonny Jeon 2016-12-19 22:18:23 -07:00
parent d5ed3bdb81
commit 864d1306b9
11 changed files with 66 additions and 28 deletions

View File

@ -1,3 +1,15 @@
----------------
Date: 2016-12-18
Author: Sonny Jeon
Subject: Addressed optional PWM min value issue. Updated docs.
- [fix] Spindle PWM minimum value had some typos. Fixed the macros to
compile correctly. Only effects users that enable SPINDLE_MINIMUM_PWM.
The name changed to SPINDLE_PWM_MIN_VALUE for consistency sake.
- Updated the laser documentation.
----------------
Date: 2016-12-12
Author: Sonny Jeon

View File

@ -454,6 +454,15 @@
// #define RX_BUFFER_SIZE 128 // (1-254) Uncomment to override defaults in serial.h
// #define TX_BUFFER_SIZE 100 // (1-254)
// A simple software debouncing feature for hard limit switches. When enabled, the interrupt
// monitoring the hard limit switch pins will enable the Arduino's watchdog timer to re-check
// the limit pin state after a delay of about 32msec. This can help with CNC machines with
// problematic false triggering of their hard limit switches, but it WILL NOT fix issues with
// electrical interference on the signal cables from external sources. It's recommended to first
// use shielded signal cables with their shielding connected to ground (old USB/computer cables
// work well and are cheap to find) and wire in a low-pass circuit into each limit pin.
// #define ENABLE_SOFTWARE_DEBOUNCE // Default disabled. Uncomment to enable.
// Configures the position after a probing cycle during Grbl's check mode. Disabled sets
// the position to the probe target, when enabled sets the position to the start position.
// #define SET_CHECK_MODE_PROBE_TO_START // Default disabled. Uncomment to enable.

View File

@ -23,7 +23,7 @@
// Grbl versioning system
#define GRBL_VERSION "1.1e"
#define GRBL_VERSION_BUILD "20161218"
#define GRBL_VERSION_BUILD "20161219"
// Define standard libraries used by Grbl.
#include <avr/io.h>

View File

@ -95,6 +95,7 @@ uint8_t limits_get_state()
// homing cycles and will not respond correctly. Upon user request or need, there may be a
// special pinout for an e-stop, but it is generally recommended to just directly connect
// your e-stop switch to the Arduino reset pin, since it is the most correct way to do this.
#ifndef ENABLE_SOFTWARE_DEBOUNCE
ISR(LIMIT_INT_vect) // DEFAULT: Limit pin change interrupt process.
{
// Ignore limit switches if already in an alarm state or in-process of executing an alarm.
@ -117,7 +118,23 @@ ISR(LIMIT_INT_vect) // DEFAULT: Limit pin change interrupt process.
}
}
}
#else // OPTIONAL: Software debounce limit pin routine.
// Upon limit pin change, enable watchdog timer to create a short delay.
ISR(LIMIT_INT_vect) { if (!(WDTCSR & (1<<WDIE))) { WDTCSR |= (1<<WDIE); } }
ISR(WDT_vect) // Watchdog timer ISR
{
WDTCSR &= ~(1<<WDIE); // Disable watchdog timer.
if (sys.state != STATE_ALARM) { // Ignore if already in alarm state.
if (!(sys_rt_exec_alarm)) {
// Check limit pin state.
if (limits_get_state()) {
mc_reset(); // Initiate system kill.
system_set_exec_alarm(EXEC_ALARM_HARD_LIMIT); // Indicate hard limit critical event
}
}
}
}
#endif
// Homes the specified cycle axes, sets the machine position, and performs a pull-off motion after
// completing. Homing is a special motion case, which involves rapid uncontrolled stops to locate

View File

@ -359,8 +359,9 @@ void mc_reset()
// violated, by which, all bets are off.
if ((sys.state & (STATE_CYCLE | STATE_HOMING | STATE_JOG)) ||
(sys.step_control & (STEP_CONTROL_EXECUTE_HOLD | STEP_CONTROL_EXECUTE_SYS_MOTION))) {
if (sys.state == STATE_HOMING) { system_set_exec_alarm(EXEC_ALARM_HOMING_FAIL_RESET); }
else { system_set_exec_alarm(EXEC_ALARM_ABORT_CYCLE); }
if (sys.state == STATE_HOMING) {
if (!sys_rt_exec_alarm) {system_set_exec_alarm(EXEC_ALARM_HOMING_FAIL_RESET); }
} else { system_set_exec_alarm(EXEC_ALARM_ABORT_CYCLE); }
st_go_idle(); // Force kill steppers. Position has likely been lost.
}
}

View File

@ -234,7 +234,7 @@ void protocol_exec_rt_system()
// lost, continued streaming could cause a serious crash if by chance it gets executed.
} while (bit_isfalse(sys_rt_exec_state,EXEC_RESET));
}
system_clear_exec_alarm_flag(0xFF); // Clear all alarm flags
system_clear_exec_alarm(); // Clear alarm
}
rt_exec = sys_rt_exec_state; // Copy volatile sys_rt_exec_state.

View File

@ -109,7 +109,6 @@ static void report_util_float_setting(uint8_t n, float val, uint8_t n_decimal) {
// operation. Errors events can originate from the g-code parser, settings module, or asynchronously
// from a critical error, such as a triggered hard limit. Interface should always monitor for these
// responses.
// NOTE: In REPORT_GUI_MODE, all error codes are greater than zero.
void report_status_message(uint8_t status_code)
{
switch(status_code) {
@ -123,7 +122,7 @@ void report_status_message(uint8_t status_code)
}
// Prints alarm messages.
void report_alarm_message(int8_t alarm_code)
void report_alarm_message(uint8_t alarm_code)
{
printPgmString(PSTR("ALARM:"));
print_uint8_base10(alarm_code);

View File

@ -86,7 +86,7 @@
void report_status_message(uint8_t status_code);
// Prints system alarm messages.
void report_alarm_message(int8_t alarm_code);
void report_alarm_message(uint8_t alarm_code);
// Prints miscellaneous feedback messages.
void report_feedback_message(uint8_t message_code);

View File

@ -371,10 +371,10 @@ void system_set_exec_alarm(uint8_t code) {
SREG = sreg;
}
void system_clear_exec_alarm_flag(uint8_t mask) {
void system_clear_exec_alarm() {
uint8_t sreg = SREG;
cli();
sys_rt_exec_alarm &= ~(mask);
sys_rt_exec_alarm = 0;
SREG = sreg;
}

View File

@ -195,7 +195,7 @@ uint8_t system_check_travel_limits(float *target);
void system_set_exec_state_flag(uint8_t mask);
void system_clear_exec_state_flag(uint8_t mask);
void system_set_exec_alarm(uint8_t code);
void system_clear_exec_alarm_flag(uint8_t mask);
void system_clear_exec_alarm();
void system_set_exec_motion_override_flag(uint8_t mask);
void system_set_exec_accessory_override_flag(uint8_t mask);
void system_clear_exec_motion_overrides();