From 87e5f6d76f26a6ec645c38cf2e676a205e8f58b1 Mon Sep 17 00:00:00 2001 From: David Guerizec Date: Wed, 8 Mar 2017 14:43:57 +0100 Subject: [PATCH 1/5] Additions for optional ABC axes Adapted from https://github.com/electrokean/grbl/commit/b3e6d6a089b6620314d426a0e299aa9ac01872e6 --- grbl/config.h | 4 +++ grbl/cpu_map.h | 15 ++++++++--- grbl/defaults.h | 17 ++++++++++++ grbl/gcode.c | 12 ++++++++- grbl/gcode.h | 6 ++++- grbl/motion_control.c | 9 +++++++ grbl/nuts_bolts.h | 6 +++-- grbl/report.c | 9 +++++++ grbl/settings.c | 60 ++++++++++++++++++++++++++++++++++++++++- grbl/stepper.c | 63 ++++++++++++++++++++++++++++++++++++++++++- 10 files changed, 192 insertions(+), 9 deletions(-) diff --git a/grbl/config.h b/grbl/config.h index 941da5ba7..823ffc06d 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -35,6 +35,7 @@ // one configuration file by placing their specific defaults and pin map at the bottom of this file. // If doing so, simply comment out these two defines and see instructions below. #define DEFAULTS_GENERIC +#define DEFAULTS_ABC_AXIS #define CPU_MAP_2560_INITIAL // Serial baud rate @@ -105,6 +106,9 @@ #define HOMING_CYCLE_0 (1<steps[X_AXIS] >> st.exec_segment->amass_level; st.steps[Y_AXIS] = st.exec_block->steps[Y_AXIS] >> st.exec_segment->amass_level; st.steps[Z_AXIS] = st.exec_block->steps[Z_AXIS] >> st.exec_segment->amass_level; +#ifdef A_AXIS + st.steps[A_AXIS] = st.exec_block->steps[A_AXIS] >> st.exec_segment->amass_level; +#endif +#ifdef B_AXIS + st.steps[B_AXIS] = st.exec_block->steps[B_AXIS] >> st.exec_segment->amass_level; +#endif +#ifdef C_AXIS + st.steps[C_AXIS] = st.exec_block->steps[C_AXIS] >> st.exec_segment->amass_level; +#endif + #endif // Set real-time spindle output as segment is loaded, just prior to the first step. @@ -404,6 +425,46 @@ ISR(TIMER1_COMPA_vect) else { sys_position[Z_AXIS]++; } } +#ifdef A_AXIS + #ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING + st.counter_a += st.steps[A_AXIS]; + #else + st.counter_a += st.exec_block->steps[A_AXIS]; + #endif + if (st.counter_a > st.exec_block->step_event_count) { + st.step_outbits |= (1<step_event_count; + if (st.exec_block->direction_bits & (1<steps[B_AXIS]; + #endif + if (st.counter_b > st.exec_block->step_event_count) { + st.step_outbits |= (1<step_event_count; + if (st.exec_block->direction_bits & (1<steps[C_AXIS]; + #endif + if (st.counter_c > st.exec_block->step_event_count) { + st.step_outbits |= (1<step_event_count; + if (st.exec_block->direction_bits & (1< Date: Wed, 8 Mar 2017 15:04:36 +0100 Subject: [PATCH 2/5] Ignore soft limit on axes with zero max-travel Adapted from https://github.com/electrokean/grbl/commit/bdc784c98cf073e6d67aabee0be501e13802ec65 --- grbl/system.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/grbl/system.c b/grbl/system.c index 59790ebfc..6e2580dc1 100644 --- a/grbl/system.c +++ b/grbl/system.c @@ -324,19 +324,22 @@ uint8_t system_check_travel_limits(float *target) { uint8_t idx; for (idx=0; idx -settings.max_travel[idx]) { return(true); } - } else { + // allow disabling soft limit per axis by setting max travel to zero + if (settings.max_travel[idx]) { + #ifdef HOMING_FORCE_SET_ORIGIN + // When homing forced set origin is enabled, soft limits checks need to account for directionality. + // NOTE: max_travel is stored as negative + if (bit_istrue(settings.homing_dir_mask,bit(idx))) { + if (target[idx] < 0 || target[idx] > -settings.max_travel[idx]) { return(true); } + } else { + if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { return(true); } + } + #else + // NOTE: max_travel is stored as negative if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { return(true); } - } - #else - // NOTE: max_travel is stored as negative - if (target[idx] > 0 || target[idx] < settings.max_travel[idx]) { return(true); } #endif } + } return(false); } From bf7f2462b32dab7845e49a924d002ef89766094c Mon Sep 17 00:00:00 2001 From: David Guerizec Date: Tue, 14 Mar 2017 01:34:50 +0100 Subject: [PATCH 3/5] Restrain to 4 axis for now --- grbl/nuts_bolts.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grbl/nuts_bolts.h b/grbl/nuts_bolts.h index e0388b264..c86941786 100644 --- a/grbl/nuts_bolts.h +++ b/grbl/nuts_bolts.h @@ -28,13 +28,13 @@ #define SOME_LARGE_VALUE 1.0E+38 // Axis array index values. Must start with 0 and be continuous. -#define N_AXIS 6 // Number of axes +#define N_AXIS 4 // Number of axes #define X_AXIS 0 // Axis indexing value. #define Y_AXIS 1 #define Z_AXIS 2 #define A_AXIS 3 -#define B_AXIS 4 -#define C_AXIS 5 +//#define B_AXIS 4 +//#define C_AXIS 5 // CoreXY motor assignments. DO NOT ALTER. // NOTE: If the A and B motor axis bindings are changed, this effects the CoreXY equations. From 7e10c437c469b35f642de9d318494c3ccad15882 Mon Sep 17 00:00:00 2001 From: David Guerizec Date: Thu, 16 Mar 2017 00:08:39 +0100 Subject: [PATCH 4/5] Fix G10 for 4th axis A --- grbl/gcode.c | 1 + grbl/gcode.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/grbl/gcode.c b/grbl/gcode.c index 3778ee48a..810fc6ee5 100644 --- a/grbl/gcode.c +++ b/grbl/gcode.c @@ -528,6 +528,7 @@ uint8_t gc_execute_line(char *line) else { coord_select = gc_block.modal.coord_select; } // Index P0 as the active coordinate system // NOTE: Store parameter data in IJK values. By rule, they are not in use with this command. + // FIXME: Instead of IJK, we'd better use: float vector[N_AXIS]; // [DG] if (!settings_read_coord_data(coord_select,gc_block.values.ijk)) { FAIL(STATUS_SETTING_READ_FAIL); } // [EEPROM read fail] // Pre-calculate the coordinate data changes. diff --git a/grbl/gcode.h b/grbl/gcode.h index 0215c8861..897bca228 100644 --- a/grbl/gcode.h +++ b/grbl/gcode.h @@ -195,7 +195,7 @@ typedef struct { typedef struct { float f; // Feed - float ijk[3]; // I,J,K Axis arc offsets + float ijk[N_AXIS]; // I,J,K Axis arc offsets uint8_t l; // G10 or canned cycles parameters int32_t n; // Line number float p; // G10 or dwell parameters From 0046fa9d386b0c5fa219a0cede47b5c339ea9cc8 Mon Sep 17 00:00:00 2001 From: David Guerizec Date: Fri, 19 May 2017 18:40:24 +0200 Subject: [PATCH 5/5] Fixed the step jumping problem on A axis See: https://github.com/gnea/grbl-Mega/issues/15 --- grbl/stepper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grbl/stepper.c b/grbl/stepper.c index 792b083ce..dd20a9e66 100644 --- a/grbl/stepper.c +++ b/grbl/stepper.c @@ -350,6 +350,9 @@ ISR(TIMER1_COMPA_vect) // Initialize Bresenham line and distance counters st.counter_x = st.counter_y = st.counter_z = (st.exec_block->step_event_count >> 1); +#ifdef A_AXIS + st.counter_a = st.counter_x; +#endif } st.dir_outbits = st.exec_block->direction_bits ^ dir_port_invert_mask;