stat_t status = STAT_OK;
mach_set_model_line(mach.gn.line);
- EXEC_FUNC(mach_set_feed_rate_mode, feed_rate_mode);
+ EXEC_FUNC(mach_set_feed_mode, feed_mode);
EXEC_FUNC(mach_set_feed_rate, feed_rate);
EXEC_FUNC(mach_feed_override_factor, feed_override_factor);
EXEC_FUNC(mach_set_spindle_speed, spindle_speed);
RITORNO(mach_dwell(mach.gn.parameter));
EXEC_FUNC(mach_set_plane, plane);
- EXEC_FUNC(mach_set_units_mode, units_mode);
+ EXEC_FUNC(mach_set_units, units);
//--> cutter radius compensation goes here
//--> cutter length compensation goes here
EXEC_FUNC(mach_set_coord_system, coord_system);
- EXEC_FUNC(mach_set_path_control, path_control);
+ EXEC_FUNC(mach_set_path_mode, path_mode);
EXEC_FUNC(mach_set_distance_mode, distance_mode);
//--> set retract mode goes here
case 17: SET_MODAL(MODAL_GROUP_G2, plane, PLANE_XY);
case 18: SET_MODAL(MODAL_GROUP_G2, plane, PLANE_XZ);
case 19: SET_MODAL(MODAL_GROUP_G2, plane, PLANE_YZ);
- case 20: SET_MODAL(MODAL_GROUP_G6, units_mode, INCHES);
- case 21: SET_MODAL(MODAL_GROUP_G6, units_mode, MILLIMETERS);
+ case 20: SET_MODAL(MODAL_GROUP_G6, units, INCHES);
+ case 21: SET_MODAL(MODAL_GROUP_G6, units, MILLIMETERS);
case 28:
switch (_point(value)) {
case 0:
case 59: SET_MODAL(MODAL_GROUP_G12, coord_system, G59);
case 61:
switch (_point(value)) {
- case 0: SET_MODAL(MODAL_GROUP_G13, path_control, PATH_EXACT_PATH);
- case 1: SET_MODAL(MODAL_GROUP_G13, path_control, PATH_EXACT_STOP);
+ case 0: SET_MODAL(MODAL_GROUP_G13, path_mode, PATH_EXACT_PATH);
+ case 1: SET_MODAL(MODAL_GROUP_G13, path_mode, PATH_EXACT_STOP);
default: status = STAT_GCODE_COMMAND_UNSUPPORTED;
}
break;
- case 64: SET_MODAL(MODAL_GROUP_G13,path_control, PATH_CONTINUOUS);
+ case 64: SET_MODAL(MODAL_GROUP_G13,path_mode, PATH_CONTINUOUS);
case 80: SET_MODAL(MODAL_GROUP_G1, motion_mode,
MOTION_MODE_CANCEL_MOTION_MODE);
// case 90: SET_MODAL(MODAL_GROUP_G3, distance_mode, ABSOLUTE_MODE);
}
break;
- case 93: SET_MODAL(MODAL_GROUP_G5, feed_rate_mode, INVERSE_TIME_MODE);
- case 94: SET_MODAL(MODAL_GROUP_G5, feed_rate_mode, UNITS_PER_MINUTE_MODE);
+ case 93: SET_MODAL(MODAL_GROUP_G5, feed_mode, INVERSE_TIME_MODE);
+ case 94: SET_MODAL(MODAL_GROUP_G5, feed_mode, UNITS_PER_MINUTE_MODE);
// case 95:
- // SET_MODAL(MODAL_GROUP_G5, feed_rate_mode, UNITS_PER_REVOLUTION_MODE);
+ // SET_MODAL(MODAL_GROUP_G5, feed_mode, UNITS_PER_REVOLUTION_MODE);
default: status = STAT_GCODE_COMMAND_UNSUPPORTED;
}
break;
float max_clear_backoff;
// state saved from gcode model
- uint8_t saved_units_mode; // G20,G21 global setting
+ uint8_t saved_units; // G20,G21 global setting
uint8_t saved_coord_system; // G54 - G59 setting
uint8_t saved_distance_mode; // G90,G91 global setting
- uint8_t saved_feed_rate_mode; // G93,G94 global setting
+ uint8_t saved_feed_mode; // G93,G94 global setting
float saved_feed_rate; // F setting
float saved_jerk; // saved and restored for each axis homed
} homing_t;
// Restore saved machine state
mach_set_coord_system(hm.saved_coord_system);
- mach_set_units_mode(hm.saved_units_mode);
+ mach_set_units(hm.saved_units);
mach_set_distance_mode(hm.saved_distance_mode);
- mach_set_feed_rate_mode(hm.saved_feed_rate_mode);
+ mach_set_feed_mode(hm.saved_feed_mode);
mach.gm.feed_rate = hm.saved_feed_rate;
mach_set_motion_mode(MOTION_MODE_CANCEL_MOTION_MODE);
}
/// G28.2 homing cycle using limit switches
void mach_homing_cycle_start() {
// save relevant non-axis parameters from Gcode model
- hm.saved_units_mode = mach_get_units_mode();
+ hm.saved_units = mach_get_units();
hm.saved_coord_system = mach_get_coord_system();
hm.saved_distance_mode = mach_get_distance_mode();
- hm.saved_feed_rate_mode = mach_get_feed_rate_mode();
+ hm.saved_feed_mode = mach_get_feed_mode();
hm.saved_feed_rate = mach_get_feed_rate();
// set working values
- mach_set_units_mode(MILLIMETERS);
+ mach_set_units(MILLIMETERS);
mach_set_distance_mode(INCREMENTAL_MODE);
mach_set_coord_system(ABSOLUTE_COORDS); // in machine coordinates
- mach_set_feed_rate_mode(UNITS_PER_MINUTE_MODE);
+ mach_set_feed_mode(UNITS_PER_MINUTE_MODE);
hm.set_coordinates = true;
hm.axis = -1; // set to retrieve initial axis
*
* Synchronizing command execution:
*
- * "Synchronous commands" are commands that affect the runtime need to be
+ * "Synchronous commands" are commands that affect the runtime and need to be
* synchronized with movement. Examples include G4 dwells, program stops and
* ends, and most M commands. These are queued into the planner queue and
* execute from the queue. Synchronous commands work like this:
uint32_t mach_get_line() {return mach.gm.line;}
motion_mode_t mach_get_motion_mode() {return mach.gm.motion_mode;}
coord_system_t mach_get_coord_system() {return mach.gm.coord_system;}
-units_mode_t mach_get_units_mode() {return mach.gm.units_mode;}
+units_t mach_get_units() {return mach.gm.units;}
plane_t mach_get_plane() {return mach.gm.plane;}
-path_mode_t mach_get_path_control() {return mach.gm.path_control;}
+path_mode_t mach_get_path_mode() {return mach.gm.path_mode;}
distance_mode_t mach_get_distance_mode() {return mach.gm.distance_mode;}
-feed_rate_mode_t mach_get_feed_rate_mode() {return mach.gm.feed_rate_mode;}
+feed_mode_t mach_get_feed_mode() {return mach.gm.feed_mode;}
uint8_t mach_get_tool() {return mach.gm.tool;}
float mach_get_feed_rate() {return mach.gm.feed_rate;}
-PGM_P mp_get_units_mode_pgmstr(units_mode_t mode) {
+PGM_P mp_get_units_pgmstr(units_t mode) {
switch (mode) {
case INCHES: return PSTR("IN");
case MILLIMETERS: return PSTR("MM");
}
-PGM_P mp_get_feed_rate_mode_pgmstr(feed_rate_mode_t mode) {
+PGM_P mp_get_feed_mode_pgmstr(feed_mode_t mode) {
switch (mode) {
case INVERSE_TIME_MODE: return PSTR("INVERSE TIME");
case UNITS_PER_MINUTE_MODE: return PSTR("PER MIN");
// Compute times for feed motion
if (mach.gm.motion_mode != MOTION_MODE_RAPID) {
- if (mach.gm.feed_rate_mode == INVERSE_TIME_MODE)
+ if (mach.gm.feed_mode == INVERSE_TIME_MODE)
// Feed rate was un-inverted to minutes by mach_set_feed_rate()
max_time = mach.gm.feed_rate;
mach_set_axis_jerk(axis, mach.a[axis].jerk_max);
// Set gcode defaults
- mach_set_units_mode(GCODE_DEFAULT_UNITS);
+ mach_set_units(GCODE_DEFAULT_UNITS);
mach_set_coord_system(GCODE_DEFAULT_COORD_SYSTEM);
mach_set_plane(GCODE_DEFAULT_PLANE);
- mach_set_path_control(GCODE_DEFAULT_PATH_CONTROL);
+ mach_set_path_mode(GCODE_DEFAULT_PATH_CONTROL);
mach_set_distance_mode(GCODE_DEFAULT_DISTANCE_MODE);
- mach_set_feed_rate_mode(UNITS_PER_MINUTE_MODE); // always the default
+ mach_set_feed_mode(UNITS_PER_MINUTE_MODE); // always the default
// Sub-system inits
spindle_init();
/// G20, G21
-void mach_set_units_mode(units_mode_t mode) {mach.gm.units_mode = mode;}
+void mach_set_units(units_t mode) {mach.gm.units = mode;}
/// G90, G91
/// F parameter
/// Normalize feed rate to mm/min or to minutes if in inverse time mode
void mach_set_feed_rate(float feed_rate) {
- if (mach.gm.feed_rate_mode == INVERSE_TIME_MODE)
+ if (mach.gm.feed_mode == INVERSE_TIME_MODE)
// normalize to minutes (active for this gcode block only)
mach.gm.feed_rate = feed_rate ? 1 / feed_rate : 0; // Avoid div by zero
/// G93, G94
-void mach_set_feed_rate_mode(feed_rate_mode_t mode) {
- if (mach.gm.feed_rate_mode == mode) return;
+void mach_set_feed_mode(feed_mode_t mode) {
+ if (mach.gm.feed_mode == mode) return;
mach.gm.feed_rate = 0; // Force setting feed rate after changing modes
- mach.gm.feed_rate_mode = mode;
+ mach.gm.feed_mode = mode;
}
/// G61, G61.1, G64
-void mach_set_path_control(path_mode_t mode) {
- mach.gm.path_control = mode;
+void mach_set_path_mode(path_mode_t mode) {
+ mach.gm.path_mode = mode;
}
stat_t mach_feed(float target[], float flags[]) {
// trap zero feed rate condition
if (fp_ZERO(mach.gm.feed_rate) ||
- (mach.gm.feed_rate_mode == INVERSE_TIME_MODE && !mach.gf.feed_rate))
+ (mach.gm.feed_mode == INVERSE_TIME_MODE && !mach.gf.feed_rate))
return STAT_GCODE_FEEDRATE_NOT_SPECIFIED;
mach.gm.motion_mode = MOTION_MODE_FEED;
mach.gm.spindle_mode = SPINDLE_OFF;
spindle_set(SPINDLE_OFF, 0);
mach_flood_coolant_control(false); // M9
- mach_set_feed_rate_mode(UNITS_PER_MINUTE_MODE); // G94
+ mach_set_feed_mode(UNITS_PER_MINUTE_MODE); // G94
mach_set_motion_mode(MOTION_MODE_CANCEL_MOTION_MODE);
}
#include <stdbool.h>
-#define TO_MILLIMETERS(a) (mach.gm.units_mode == INCHES ? (a) * MM_PER_INCH : a)
+#define TO_MILLIMETERS(a) (mach.gm.units == INCHES ? (a) * MM_PER_INCH : a)
/* The difference between next_action_t and motion_mode_t is that
INCHES, // G20
MILLIMETERS, // G21
DEGREES, // ABC axes (this value used for displays only)
-} units_mode_t;
+} units_t;
typedef enum {
/// G Modal Group 13
typedef enum {
- /// G61 - hits corners but does not stop if it does not need to.
- PATH_EXACT_PATH,
- PATH_EXACT_STOP, // G61.1 - stops at all corners
+ PATH_EXACT_PATH, // G61 hits corners but stops only if needed
+ PATH_EXACT_STOP, // G61.1 stops at all corners
PATH_CONTINUOUS, // G64 and typically the default mode
} path_mode_t;
INVERSE_TIME_MODE, // G93
UNITS_PER_MINUTE_MODE, // G94
UNITS_PER_REVOLUTION_MODE, // G95 (unimplemented)
-} feed_rate_mode_t;
+} feed_mode_t;
typedef enum {
uint8_t tool_select; // T - sets this value
float feed_rate; // F - in mm/min or inverse time mode
- feed_rate_mode_t feed_rate_mode;
+ feed_mode_t feed_mode;
float feed_override_factor; // 1.0000 x F feed rate
bool feed_override_enable; // M48, M49
motion_mode_t motion_mode; // Group 1 modal motion
plane_t plane; // G17, G18, G19
- units_mode_t units_mode; // G20, G21
+ units_t units; // G20, G21
coord_system_t coord_system; // G54-G59 - select coordinate system 1-9
bool absolute_mode; // G53 true = move in machine coordinates
- path_mode_t path_control; // G61
+ path_mode_t path_mode; // G61
distance_mode_t distance_mode; // G91
distance_mode_t arc_distance_mode; // G91.1
uint32_t mach_get_line();
motion_mode_t mach_get_motion_mode();
coord_system_t mach_get_coord_system();
-units_mode_t mach_get_units_mode();
+units_t mach_get_units();
plane_t mach_get_plane();
-path_mode_t mach_get_path_control();
+path_mode_t mach_get_path_mode();
distance_mode_t mach_get_distance_mode();
-feed_rate_mode_t mach_get_feed_rate_mode();
+feed_mode_t mach_get_feed_mode();
uint8_t mach_get_tool();
float mach_get_feed_rate();
-PGM_P mp_get_units_mode_pgmstr(units_mode_t mode);
-PGM_P mp_get_feed_rate_mode_pgmstr(feed_rate_mode_t mode);
+PGM_P mp_get_units_pgmstr(units_t mode);
+PGM_P mp_get_feed_mode_pgmstr(feed_mode_t mode);
PGM_P mp_get_plane_pgmstr(plane_t plane);
PGM_P mp_get_coord_system_pgmstr(coord_system_t cs);
PGM_P mp_get_path_mode_pgmstr(path_mode_t mode);
// Representation (4.3.3)
void mach_set_plane(plane_t plane);
-void mach_set_units_mode(units_mode_t mode);
+void mach_set_units(units_t mode);
void mach_set_distance_mode(distance_mode_t mode);
void mach_set_coord_offsets(coord_system_t coord_system, float offset[],
float flag[]);
// Machining Attributes (4.3.5)
void mach_set_feed_rate(float feed_rate);
-void mach_set_feed_rate_mode(feed_rate_mode_t mode);
-void mach_set_path_control(path_mode_t mode);
+void mach_set_feed_mode(feed_mode_t mode);
+void mach_set_path_mode(path_mode_t mode);
// Machining Functions (4.3.6)
stat_t mach_feed(float target[], float flags[]);
float planar_travel) {
// Determine move time at requested feed rate
// Inverse feed rate is normalized to minutes
- float time = mach.gm.feed_rate_mode == INVERSE_TIME_MODE ?
+ float time = mach.gm.feed_mode == INVERSE_TIME_MODE ?
mach.gm.feed_rate : length / mach.gm.feed_rate;
// Downgrade the time if there is a rate-limiting axis
uint8_t motion_mode) { // defined motion mode
// trap missing feed rate
if (fp_ZERO(mach.gm.feed_rate) ||
- (mach.gm.feed_rate_mode == INVERSE_TIME_MODE && !mach.gf.feed_rate))
+ (mach.gm.feed_mode == INVERSE_TIME_MODE && !mach.gf.feed_rate))
return STAT_GCODE_FEEDRATE_NOT_SPECIFIED;
// set radius mode flag and do simple test(s)
bf->braking_velocity = bf->delta_vmax;
// Zero out exact stop cases
- if (mach_get_path_control() == PATH_EXACT_STOP)
+ if (mach_get_path_mode() == PATH_EXACT_STOP)
bf->entry_vmax = bf->exit_vmax = 0;
else bf->replannable = true;
}
typedef struct {
int32_t line; // Current move GCode line number
+
uint8_t tool;
float feed;
- feed_rate_mode_t feed_rate_mode;
+ feed_mode_t feed_mode;
float feed_override;
-
- float speed;
- spindle_mode_t spindle_mode;
float spindle_override;
- motion_mode_t motion_mode;
plane_t plane;
- units_mode_t units_mode;
+ units_t units;
coord_system_t coord_system;
bool absolute_mode;
- path_mode_t path_control;
+ path_mode_t path_mode;
distance_mode_t distance_mode;
distance_mode_t arc_distance_mode;
- bool mist_coolant;
- bool flood_coolant;
-
} mach_state_t;
/// G38.2 homing cycle using limit switches
stat_t mach_probe(float target[], float flags[]) {
// trap zero feed rate condition
- if (mach.gm.feed_rate_mode != INVERSE_TIME_MODE && fp_ZERO(mach.gm.feed_rate))
+ if (mach.gm.feed_mode != INVERSE_TIME_MODE && fp_ZERO(mach.gm.feed_rate))
return STAT_GCODE_FEEDRATE_NOT_SPECIFIED;
// trap no axes specified
// GCode
int32_t get_line() {return mp_runtime_get_line();}
-PGM_P get_unit() {return mp_get_units_mode_pgmstr(mach_get_units_mode());}
+PGM_P get_unit() {return mp_get_units_pgmstr(mach_get_units());}
float get_speed() {return spindle_get_speed();}
float get_feed() {return mach_get_feed_rate();}
uint8_t get_tool() {return mach_get_tool();}
-PGM_P get_feed_rate_mode() {
- return mp_get_feed_rate_mode_pgmstr(mach.gm.feed_rate_mode);
+PGM_P get_feed_mode() {
+ return mp_get_feed_mode_pgmstr(mach.gm.feed_mode);
}
bool get_abs_override() {return mach.gm.absolute_mode;}
-PGM_P get_path_control() {return mp_get_path_mode_pgmstr(mach.gm.path_control);}
+PGM_P get_path_mode() {return mp_get_path_mode_pgmstr(mach.gm.path_mode);}
PGM_P get_distance_mode() {
VAR(speed, "s", float, 0, 0, 0, "Current spindle speed")
VAR(feed, "f", float, 0, 0, 0, "Current feed rate")
VAR(tool, "t", uint8_t, 0, 0, 0, "Current tool")
-VAR(feed_rate_mode, "fm", pstring, 0, 0, 0, "Current feed rate mode")
+VAR(feed_mode, "fm", pstring, 0, 0, 0, "Current feed rate mode")
VAR(plane, "pa", pstring, 0, 0, 0, "Current plane")
VAR(coord_system, "cs", pstring, 0, 0, 0, "Current coordinate system")
VAR(abs_override, "ao", bool, 0, 0, 0, "Absolute override enabled")
-VAR(path_control, "pc", pstring, 0, 0, 0, "Current path control mode")
+VAR(path_mode, "pc", pstring, 0, 0, 0, "Current path control mode")
VAR(distance_mode, "dm", pstring, 0, 0, 0, "Current distance mode")
VAR(arc_dist_mode, "ad", pstring, 0, 0, 0, "Current arc distance mode")
VAR(mist_coolant, "mc", bool, 0, 0, 0, "Mist coolant enabled")