From 664854b9dfc50da847b73cd96e64450b4bfee518 Mon Sep 17 00:00:00 2001 From: Sonny Jeon Date: Sun, 17 May 2015 13:25:36 -0600 Subject: [PATCH] Critical M0/2/30 fix. Homing updates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Critical fix for M0 program pause. Due to its recent change, it would cause Grbl to suspend but wouldn’t notify the user of why Grbl was not doing anything. The state would show IDLE and a cycle start would resume it. Grbl now enters a HOLD state to better indicate the state change. - Critical fix for M2 and M30 program end. As with M0, the state previously would show IDLE while suspended. Grbl now does not suspend upon program end and leaves job control to the GUI. Grbl simply reports a `[Pgm End]` as a feedback message and resets certain g-code modes. - M2/30 g-code reseting fix. Previously Grbl would soft-reset after an M2/30, but this was not complaint to the (linuxcnc) g-code standard. It simply resets [G1,G17,G90,G94,G40,G54,M5,M9,M48] and keeps all other modes the same. - M0/M2/M30 check-mode fix. It now does not suspend the machine during check-mode. - Minor bug fix related to commands similar to G90.1, but not G90.1, not reporting an unsupported command. - Homing cycle refactoring. To help reduce the chance of users misunderstanding their limit switch wiring, Grbl only moves a short distance for the locate cycles only. In addition, the homing cycle pulls-off the limit switch by the pull-off distance to re-engage and locate home. This should improve its accuracy. - HOMING_FORCE_ORIGIN now sets the origin to the pull-off location, rather than where the limit switch was triggered. - Updated default junction deviation to 0.01mm. Recent tests showed that this improves Grbl’s cornering behavior a bit. - Added the ShapeOko3 defaults. - Added new feedback message `[Pgm End]` for M2/30 notification. - Limit pin reporting is now a $10 status report option. Requested by OEMs to help simplify support troubleshooting. --- doc/log/commit_log_v0.9i.txt | 26 ++++++ grbl/config.h | 2 +- grbl/defaults.h | 53 ++++++++--- grbl/gcode.c | 45 +++++++--- grbl/grbl.h | 2 +- grbl/limits.c | 166 ++++++++++++++++------------------- grbl/report.c | 29 +++--- grbl/report.h | 1 + grbl/settings.h | 1 + grbl/stepper.c | 5 +- grbl/system.h | 2 +- 11 files changed, 201 insertions(+), 131 deletions(-) diff --git a/doc/log/commit_log_v0.9i.txt b/doc/log/commit_log_v0.9i.txt index 49aba2c..db7df62 100644 --- a/doc/log/commit_log_v0.9i.txt +++ b/doc/log/commit_log_v0.9i.txt @@ -1,3 +1,29 @@ +---------------- +Date: 2015-03-29 +Author: Sonny Jeon +Subject: Fix for limit pin reporting compile-option + +- The limit pin reporting wasn’t working correctly due to calling the +wrong similarly-named function. Verified to be working now. + + +---------------- +Date: 2015-03-29 +Author: Sonny Jeon +Subject: Commit history, logo license, full-arc fix. + +- Commit history added to repo, as an easier way for people to see view +the changes over time. + +- Grbl logo copyright license added. All rights reserved with regards +to the Grbl logo. + +- G2/3 full circles would sometime not execute. The problem was due to +numerical round-off of a trig calculation. Added a machine epsilon +define to help detect and correct for this problem. Tested and should +not effect general operation of arcs. + + ---------------- Date: 2015-03-27 Author: Sungeun Jeon diff --git a/grbl/config.h b/grbl/config.h index 878b341..3375e5c 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -79,7 +79,7 @@ // Number of homing cycles performed after when the machine initially jogs to limit switches. // This help in preventing overshoot and should improve repeatability. This value should be one or // greater. -#define N_HOMING_LOCATE_CYCLE 2 // Integer (1-128) +#define N_HOMING_LOCATE_CYCLE 1 // Integer (1-128) // After homing, Grbl will set by default the entire machine space into negative space, as is typical // for professional CNC machines, regardless of where the limit switches are located. Uncomment this diff --git a/grbl/defaults.h b/grbl/defaults.h index f21b31e..41bcf0f 100644 --- a/grbl/defaults.h +++ b/grbl/defaults.h @@ -49,7 +49,6 @@ #define DEFAULT_JUNCTION_DEVIATION 0.02 // mm #define DEFAULT_ARC_TOLERANCE 0.002 // mm #define DEFAULT_REPORT_INCHES 0 // false - #define DEFAULT_AUTO_START 1 // true #define DEFAULT_INVERT_ST_ENABLE 0 // false #define DEFAULT_INVERT_LIMIT_PINS 0 // false #define DEFAULT_SOFT_LIMIT_ENABLE 0 // false @@ -87,10 +86,9 @@ #define DEFAULT_DIRECTION_INVERT_MASK ((1< diff --git a/grbl/limits.c b/grbl/limits.c index 83d93d9..4df6f1e 100644 --- a/grbl/limits.c +++ b/grbl/limits.c @@ -22,9 +22,13 @@ #include "grbl.h" -// Homing axis search distance multiplier. Computed by this value times the axis max travel. -#define HOMING_AXIS_SEARCH_SCALAR 1.5 // Must be > 1 to ensure limit switch will be engaged. - +// Homing axis search distance multiplier. Computed by this value times the cycle travel. +#ifndef HOMING_AXIS_SEARCH_SCALAR + #define HOMING_AXIS_SEARCH_SCALAR 1.5 // Must be > 1 to ensure limit switch will be engaged. +#endif +#ifndef HOMING_AXIS_LOCATE_SCALAR + #define HOMING_AXIS_LOCATE_SCALAR 5.0 // Must be > 1 to ensure limit switch is cleared. +#endif void limits_init() { @@ -126,16 +130,12 @@ void limits_go_home(uint8_t cycle_mask) { if (sys.abort) { return; } // Block if system reset has been issued. - // Initialize homing in search mode to quickly engage the specified cycle_mask limit switches. - bool approach = true; - float homing_rate = settings.homing_seek_rate; - uint8_t invert_pin, idx; + // Initialize uint8_t n_cycle = (2*N_HOMING_LOCATE_CYCLE+1); - float target[N_AXIS]; - uint8_t limit_pin[N_AXIS], step_pin[N_AXIS]; - + float target[N_AXIS]; float max_travel = 0.0; + uint8_t idx; for (idx=0; idx 0); @@ -242,13 +260,16 @@ void limits_go_home(uint8_t cycle_mask) for (idx=0; idx 0.0) { - for (idx=0; idxstep_event_count >> 1); - st.counter_y = st.counter_x; - st.counter_z = st.counter_x; + st.counter_x = st.counter_y = st.counter_z = (st.exec_block->step_event_count >> 1); } - st.dir_outbits = st.exec_block->direction_bits ^ dir_port_invert_mask; #ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING diff --git a/grbl/system.h b/grbl/system.h index a74f029..94f2143 100644 --- a/grbl/system.h +++ b/grbl/system.h @@ -71,7 +71,7 @@ typedef struct { uint8_t abort; // System abort flag. Forces exit back to main loop for reset. uint8_t state; // Tracks the current state of Grbl. - uint8_t suspend; // System suspend flag. Allows only realtime commands. Used primarily for holds. + uint8_t suspend; // System suspend bitflag variable that manages holds, cancels, and safety door. volatile uint8_t rt_exec_state; // Global realtime executor bitflag variable for state management. See EXEC bitmasks. volatile uint8_t rt_exec_alarm; // Global realtime executor bitflag variable for setting various alarms.