From 4f68edbba2312c9a4b8f9fe28ef508dd50f3f35b Mon Sep 17 00:00:00 2001 From: ashelly Date: Mon, 8 Sep 2014 22:10:59 -0400 Subject: [PATCH 1/2] Alarm if limits engaged on homing --- motion_control.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/motion_control.c b/motion_control.c index 66633d1..3b0b171 100644 --- a/motion_control.c +++ b/motion_control.c @@ -240,6 +240,18 @@ void mc_dwell(float seconds) // executing the homing cycle. This prevents incorrect buffered plans after homing. void mc_homing_cycle() { + uint8_t limits_on; + if (bit_istrue(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) { + limits_on = (LIMIT_PIN ^ LIMIT_MASK); + } else { + limits_on = (LIMIT_PIN & LIMIT_MASK); + } + if (limits_on) { + mc_reset(); // Issue system reset and ensure spindle and coolant are shutdown. + bit_true_atomic(sys.execute, (EXEC_ALARM | EXEC_CRIT_EVENT)); // Indicate homing limit critical event + return; + } + sys.state = STATE_HOMING; // Set system state variable limits_disable(); // Disable hard limits pin change register for cycle duration From 5b97a79b6d74fa99fe32246f20ce5f275e1279c4 Mon Sep 17 00:00:00 2001 From: ashelly Date: Wed, 17 Sep 2014 23:41:52 -0400 Subject: [PATCH 2/2] No false alarm if other bits in port are set. --- motion_control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motion_control.c b/motion_control.c index 3b0b171..2208a93 100644 --- a/motion_control.c +++ b/motion_control.c @@ -242,7 +242,7 @@ void mc_homing_cycle() { uint8_t limits_on; if (bit_istrue(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) { - limits_on = (LIMIT_PIN ^ LIMIT_MASK); + limits_on = ((~LIMIT_PIN) & LIMIT_MASK); } else { limits_on = (LIMIT_PIN & LIMIT_MASK); }