New G43.1/G49 gcodes. Not working yet!!
- Pushed this uncompleted code to merge a conflicting pull request. - New G43.1 and G49 g-codes to be installed. The beginnings of it are in place. These g-codes are intended to be used in conjunction with probing and allow GUIs to set tool length offsets without Grbl needing to store a tool table. - G43.1 is defined as a dynamic tool length offset that is not stored in memory. Rather, when commanded, these are applied to the work coordinates until a reset or disabled by G49. This works much like G92.
This commit is contained in:
parent
ed417220e1
commit
e455faaeef
21
gcode.c
21
gcode.c
@ -37,6 +37,7 @@
|
||||
#define AXIS_COMMAND_NONE 0
|
||||
#define AXIS_COMMAND_NON_MODAL 1
|
||||
#define AXIS_COMMAND_MOTION_MODE 2
|
||||
#define AXIS_COMMAND_TOOL_LENGTH_OFFSET 3 // *Undefined but required
|
||||
|
||||
// Declare gc extern struct
|
||||
parser_state_t gc_state;
|
||||
@ -148,6 +149,7 @@ uint8_t gc_execute_line(char *line)
|
||||
switch(int_value) {
|
||||
case 10: case 28: case 30: case 92:
|
||||
// Check for G10/28/30/92 being called with G0/1/2/3/38 on same block.
|
||||
// * G43.1 is also an axis command but is not explicitly defined this way.
|
||||
if (mantissa == 0) { // Ignore G28.1, G30.1, and G92.1
|
||||
if (axis_command) { FAIL(STATUS_GCODE_AXIS_COMMAND_CONFLICT); } // [Axis word/command conflict]
|
||||
axis_command = AXIS_COMMAND_NON_MODAL;
|
||||
@ -187,6 +189,7 @@ uint8_t gc_execute_line(char *line)
|
||||
break;
|
||||
case 0: case 1: case 2: case 3: case 38:
|
||||
// Check for G0/1/2/3/38 being called with G10/28/30/92 on same block.
|
||||
// * G43.1 is also an axis command but is not explicitly defined this way.
|
||||
if (axis_command) { FAIL(STATUS_GCODE_AXIS_COMMAND_CONFLICT); } // [Axis word/command conflict]
|
||||
axis_command = AXIS_COMMAND_MOTION_MODE;
|
||||
// No break. Continues to next line.
|
||||
@ -234,6 +237,18 @@ uint8_t gc_execute_line(char *line)
|
||||
if (int_value == 20) { gc_block.modal.units = UNITS_MODE_INCHES; } // G20
|
||||
else { gc_block.modal.units = UNITS_MODE_MM; } // G21
|
||||
break;
|
||||
case 43: case 49:
|
||||
word_bit = MODAL_GROUP_G8;
|
||||
if (int_value == 49) {
|
||||
gc_block.modal.tool_length = TOOL_LENGTH_OFFSET_CANCEL;
|
||||
// Else command is G43. Only G43.1 is supported. G43 is NOT.
|
||||
} else if (mantissa == 1) {
|
||||
// * G43.1 is requires an axis word to operate and cannot exist with other axis
|
||||
// commands in the same line. However, it's not explicitly defined this way.
|
||||
if (axis_command) { FAIL(STATUS_GCODE_AXIS_COMMAND_CONFLICT); } // [Axis word/command conflict] }
|
||||
axis_command = AXIS_COMMAND_TOOL_LENGTH_OFFSET;
|
||||
gc_block.modal.tool_length = TOOL_LENGTH_OFFSET_ENABLE_DYNAMIC;
|
||||
} else { FAIL(STATUS_GCODE_UNSUPPORTED_COMMAND); } // [Unsupported G43.x command]
|
||||
case 54: case 55: case 56: case 57: case 58: case 59:
|
||||
// NOTE: G59.x are not supported. (But their int_values would be 60, 61, and 62.)
|
||||
word_bit = MODAL_GROUP_G12;
|
||||
@ -422,7 +437,7 @@ uint8_t gc_execute_line(char *line)
|
||||
if (bit_isfalse(value_words,bit(WORD_S))) { gc_block.values.s = gc_state.spindle_speed; }
|
||||
// bit_false(value_words,bit(WORD_S)); // NOTE: Single-meaning value word. Set at end of error-checking.
|
||||
|
||||
// [5. Select tool ]: NOT SUPPORTED. T is negative (done.) Not an integer. Greater than max tool value.
|
||||
// [5. Select tool ]: NOT SUPPORTED. Only tracks value. T is negative (done.) Not an integer. Greater than max tool value.
|
||||
// bit_false(value_words,bit(WORD_T)); // NOTE: Single-meaning value word. Set at end of error-checking.
|
||||
|
||||
// [6. Change tool ]: N/A
|
||||
@ -466,7 +481,9 @@ uint8_t gc_execute_line(char *line)
|
||||
}
|
||||
|
||||
// [13. Cutter radius compensation ]: NOT SUPPORTED. Error, if G53 is active.
|
||||
// [14. Cutter length compensation ]: NOT SUPPORTED.
|
||||
|
||||
// [14. Cutter length compensation ]: G43 NOT SUPPORTED, but G43.1 and G49 are.
|
||||
// G43.1 Error with motion command in same line. (Already done by axis command checks in parser.)
|
||||
|
||||
// [15. Coordinate system selection ]: *N/A. Error, if cutter radius comp is active.
|
||||
// TODO: An EEPROM read of the coordinate data may require a buffer sync when the cycle
|
||||
|
57
gcode.h
57
gcode.h
@ -36,20 +36,21 @@
|
||||
#define MODAL_GROUP_G3 3 // [G90,G91] Distance mode
|
||||
#define MODAL_GROUP_G5 4 // [G93,G94] Feed rate mode
|
||||
#define MODAL_GROUP_G6 5 // [G20,G21] Units
|
||||
#define MODAL_GROUP_G12 6 // [G54,G55,G56,G57,G58,G59] Coordinate system selection
|
||||
#define MODAL_GROUP_G8 6 // [G43,G43.1,G49] Tool length offset
|
||||
#define MODAL_GROUP_G12 7 // [G54,G55,G56,G57,G58,G59] Coordinate system selection
|
||||
|
||||
#define MODAL_GROUP_M4 7 // [M0,M1,M2,M30] Stopping
|
||||
#define MODAL_GROUP_M7 8 // [M3,M4,M5] Spindle turning
|
||||
#define MODAL_GROUP_M8 9 // [M7,M8,M9] Coolant control
|
||||
#define MODAL_GROUP_M4 8 // [M0,M1,M2,M30] Stopping
|
||||
#define MODAL_GROUP_M7 9 // [M3,M4,M5] Spindle turning
|
||||
#define MODAL_GROUP_M8 10 // [M7,M8,M9] Coolant control
|
||||
|
||||
#define OTHER_INPUT_F 10
|
||||
#define OTHER_INPUT_S 11
|
||||
#define OTHER_INPUT_T 12
|
||||
#define OTHER_INPUT_F 11
|
||||
#define OTHER_INPUT_S 12
|
||||
#define OTHER_INPUT_T 13
|
||||
|
||||
// Define command actions for within execution-type modal groups (motion, stopping, non-modal). Used
|
||||
// internally by the parser to know which command to execute.
|
||||
|
||||
// Modal Group 0: Non-modal actions
|
||||
// Modal Group G0: Non-modal actions
|
||||
#define NON_MODAL_NO_ACTION 0 // (Default: Must be zero)
|
||||
#define NON_MODAL_DWELL 1 // G4
|
||||
#define NON_MODAL_SET_COORDINATE_DATA 2 // G10
|
||||
@ -61,7 +62,7 @@
|
||||
#define NON_MODAL_SET_COORDINATE_OFFSET 8 // G92
|
||||
#define NON_MODAL_RESET_COORDINATE_OFFSET 9 //G92.1
|
||||
|
||||
// Modal Group 1: Motion modes
|
||||
// Modal Group G1: Motion modes
|
||||
#define MOTION_MODE_SEEK 0 // G0 (Default: Must be zero)
|
||||
#define MOTION_MODE_LINEAR 1 // G1
|
||||
#define MOTION_MODE_CW_ARC 2 // G2
|
||||
@ -69,39 +70,43 @@
|
||||
#define MOTION_MODE_PROBE 4 // G38.2
|
||||
#define MOTION_MODE_NONE 5 // G80
|
||||
|
||||
// Modal Group 2: Plane select
|
||||
// Modal Group G2: Plane select
|
||||
#define PLANE_SELECT_XY 0 // G17 (Default: Must be zero)
|
||||
#define PLANE_SELECT_ZX 1 // G18
|
||||
#define PLANE_SELECT_YZ 2 // G19
|
||||
|
||||
// Modal Group 3: Distance mode
|
||||
// Modal Group G3: Distance mode
|
||||
#define DISTANCE_MODE_ABSOLUTE 0 // G90 (Default: Must be zero)
|
||||
#define DISTANCE_MODE_INCREMENTAL 1 // G91
|
||||
|
||||
// Modal Group 4: Program flow
|
||||
// Modal Group M4: Program flow
|
||||
#define PROGRAM_FLOW_RUNNING 0 // (Default: Must be zero)
|
||||
#define PROGRAM_FLOW_PAUSED 1 // M0, M1
|
||||
#define PROGRAM_FLOW_COMPLETED 2 // M2, M30
|
||||
|
||||
// Modal Group 5: Feed rate mode
|
||||
// Modal Group G5: Feed rate mode
|
||||
#define FEED_RATE_MODE_UNITS_PER_MIN 0 // G94 (Default: Must be zero)
|
||||
#define FEED_RATE_MODE_INVERSE_TIME 1 // G93
|
||||
|
||||
// Modal Group 6: Units mode
|
||||
// Modal Group G6: Units mode
|
||||
#define UNITS_MODE_MM 0 // G21 (Default: Must be zero)
|
||||
#define UNITS_MODE_INCHES 1 // G20
|
||||
|
||||
// Modal Group 7: Spindle control
|
||||
// Modal Group M7: Spindle control
|
||||
#define SPINDLE_DISABLE 0 // M5 (Default: Must be zero)
|
||||
#define SPINDLE_ENABLE_CW 1 // M3
|
||||
#define SPINDLE_ENABLE_CCW 2 // M4
|
||||
|
||||
// Modal Group 8: Coolant control
|
||||
// Modal Group M8: Coolant control
|
||||
#define COOLANT_DISABLE 0 // M9 (Default: Must be zero)
|
||||
#define COOLANT_MIST_ENABLE 1 // M7
|
||||
#define COOLANT_FLOOD_ENABLE 2 // M8
|
||||
|
||||
// Modal Group 12: Active work coordinate system
|
||||
// Modal Group G8: Tool length offset
|
||||
#define TOOL_LENGTH_OFFSET_CANCEL 0 // G49 (Default: Must be zero)
|
||||
#define TOOL_LENGTH_OFFSET_ENABLE_DYNAMIC 1 // G43.1
|
||||
|
||||
// Modal Group G12: Active work coordinate system
|
||||
// N/A: Stores coordinate system value (54-59) to change to.
|
||||
|
||||
#define WORD_F 0
|
||||
@ -128,6 +133,7 @@ typedef struct {
|
||||
uint8_t units; // {G20,G21}
|
||||
uint8_t distance; // {G90,G91}
|
||||
uint8_t plane_select; // {G17,G18,G19}
|
||||
uint8_t tool_length; // {G43.1,G49}
|
||||
uint8_t coord_select; // {G54,G55,G56,G57,G58,G59}
|
||||
uint8_t program_flow; // {M0,M1,M2,M30}
|
||||
uint8_t coolant; // {M7,M8,M9}
|
||||
@ -151,16 +157,17 @@ typedef struct {
|
||||
typedef struct {
|
||||
gc_modal_t modal;
|
||||
|
||||
float spindle_speed; // RPM
|
||||
float feed_rate; // Millimeters/min
|
||||
uint8_t tool;
|
||||
float spindle_speed; // RPM
|
||||
float feed_rate; // Millimeters/min
|
||||
uint8_t tool; // Tracks tool number. NOT USED.
|
||||
|
||||
float position[N_AXIS]; // Where the interpreter considers the tool to be at this point in the code
|
||||
float position[N_AXIS]; // Where the interpreter considers the tool to be at this point in the code
|
||||
|
||||
float coord_system[N_AXIS]; // Current work coordinate system (G54+). Stores offset from absolute machine
|
||||
// position in mm. Loaded from EEPROM when called.
|
||||
float coord_offset[N_AXIS]; // Retains the G92 coordinate offset (work coordinates) relative to
|
||||
// machine zero in mm. Non-persistent. Cleared upon reset and boot.
|
||||
float coord_system[N_AXIS]; // Current work coordinate system (G54+). Stores offset from absolute machine
|
||||
// position in mm. Loaded from EEPROM when called.
|
||||
float coord_offset[N_AXIS]; // Retains the G92 coordinate offset (work coordinates) relative to
|
||||
// machine zero in mm. Non-persistent. Cleared upon reset and boot.
|
||||
float tool_length_offset; // Tracks tool length offset value when enabled.
|
||||
} parser_state_t;
|
||||
extern parser_state_t gc_state;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user