Skip to content

Commit

Permalink
Tidying up parking override control implementation
Browse files Browse the repository at this point in the history
[new] Added a default configuration for the parking override control
upon a reset or power-up. By default, parking is enabled, but this may
be disabled via a config.h option.

[fix] Parking override control should be checking if the command word
is passed, rather than the value.
  • Loading branch information
chamnit committed Jan 29, 2017
1 parent e455764 commit beaa405
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 11 deletions.
53 changes: 53 additions & 0 deletions doc/log/commit_log_v1.1.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
----------------
Date: 2017-01-28
Author: chamnit
Subject: v1.1f. Parking override control. Spindle enable pin option.

[ver] v1.1f update due to tweaks to interface from new parking override
control.

[new] Parking motion override control via new `M56 P0` and `M56 P1`
command, which disables and enables the parking motion, respectively.
Requires ENABLE_PARKING_OVERRIDE_CONTROL and PARKING_ENABLE enabled in
config.h. Primarily for OEMs.

[new] `M56` appears in the $G report when enabled.

[new] Five new build info identification letters. Some were missing and
a couple are new. Updated the CSV and documentation to reflect these
new items.

[new] Spindle enable pin configuration option to alter its behavior
based on how certain lasers work. By default, Grbl treats the enable
pin separately and leaves it on when S is 0. The new option turns the
enable pin on and off with S>0 and S=0. This only is in effect when a
user enables the USE_SPINDLE_DIR_AS_ENABLE_PIN option.

[fix] M4 is now allowed to work when USE_SPINDLE_DIR_AS_ENABLE_PIN is
enabled. Previously this was blocked and was problematic for laser
folks using M4.

[fix] Properly declared system variables as extern. Not sure how that
went unnoticed or why it worked up until now but it has.

[fix] EXTREMELY RARE. When AMASS is intentionally disabled and sent a
motion command that is _one step_ in length, Grbl would not actuate the
step due to numerical round-off. Applied a fix to prevent the round-off
issue.

[fix] Added a compile-time check for AMASS settings to make sure that
the numerical round-off issue doesn’t effect it. This would only happen
if someone set AMASS max levels to zero. It does not effect AMASS with
its current defaults.

[fix] Wrapped the mc_parking_motion() function in an ifdef for porting
purposes.

[fix] Fixed an issue when in inverse time mode and G0’s would require a
F word. This was not correct.

[fix] Added a note in the defaults.h file that MAX_TRAVEL values must
be positive. Some users were setting this negative and it was causing
issues.


----------------
Date: 2017-01-14
Author: Sonny Jeon
Expand Down
4 changes: 3 additions & 1 deletion grbl/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,10 @@
// These are controlled by `M56`, `M56 P1`, or `M56 Px` to enable and `M56 P0` to disable.
// The command is modal and will be set after a planner sync. Since it is g-code, it is
// executed in sync with g-code commands. It is not a real-time command.
// NOTE: PARKING_ENABLE is required.
// NOTE: PARKING_ENABLE is required. By default, M56 is active upon initialization. Use
// DEACTIVATE_PARKING_UPON_INIT to set M56 P0 as the power-up default.
// #define ENABLE_PARKING_OVERRIDE_CONTROL // Default disabled. Uncomment to enable
// #define DEACTIVATE_PARKING_UPON_INIT // Default disabled. Uncomment to enable.

// This option will automatically disable the laser during a feed hold by invoking a spindle stop
// override immediately after coming to a stop. However, this also means that the laser still may
Expand Down
12 changes: 9 additions & 3 deletions grbl/gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ uint8_t gc_execute_line(char *line)
// [8. Coolant control ]: N/A
// [9. Override control ]: Not supported except for a Grbl-only parking motion override control.
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
if (gc_block.modal.override == OVERRIDE_PARKING_MOTION) {
if (bit_istrue(command_words,bit(MODAL_GROUP_M9))) { // Already set as enabled in parser.
if (bit_istrue(value_words,bit(WORD_P))) {
if (gc_block.values.p == 0.0) { gc_block.modal.override = OVERRIDE_DISABLED; }
bit_false(value_words,bit(WORD_P));
Expand Down Expand Up @@ -1102,7 +1102,13 @@ uint8_t gc_execute_line(char *line)
gc_state.modal.coord_select = 0; // G54
gc_state.modal.spindle = SPINDLE_DISABLE;
gc_state.modal.coolant = COOLANT_DISABLE;
// gc_state.modal.override = OVERRIDE_DISABLE; // Not supported.
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
#ifdef DEACTIVATE_PARKING_UPON_INIT
gc_state.modal.override = OVERRIDE_DISABLED;
#else
gc_state.modal.override = OVERRIDE_PARKING_MOTION;
#endif
#endif

#ifdef RESTORE_OVERRIDES_AFTER_PROGRAM_END
sys.f_override = DEFAULT_FEED_OVERRIDE;
Expand Down Expand Up @@ -1148,7 +1154,7 @@ uint8_t gc_execute_line(char *line)
group 7 = {G41, G42} cutter radius compensation (G40 is supported)
group 8 = {G43} tool length offset (G43.1/G49 are supported)
group 8 = {M7*} enable mist coolant (* Compile-option)
group 9 = {M48, M49} enable/disable feed and speed override switches
group 9 = {M48, M49, M56*} enable/disable override switches (* Compile-option)
group 10 = {G98, G99} return mode canned cycles
group 13 = {G61.1, G64} path control mode (G61 is supported)
*/
9 changes: 7 additions & 2 deletions grbl/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@
#define TOOL_LENGTH_OFFSET_ENABLE_DYNAMIC 1 // G43.1

// Modal Group M9: Override control
#define OVERRIDE_DISABLED 0 // None (Default: Must be zero)
#define OVERRIDE_PARKING_MOTION 1 // G56 (Default: Must be zero)
#ifdef DEACTIVATE_PARKING_UPON_INIT
#define OVERRIDE_DISABLED 0 // (Default: Must be zero)
#define OVERRIDE_PARKING_MOTION 1 // M56
#else
#define OVERRIDE_PARKING_MOTION 0 // M56 (Default: Must be zero)
#define OVERRIDE_DISABLED 1 // Parking disabled.
#endif

// Modal Group G12: Active work coordinate system
// N/A: Stores coordinate system value (54-59) to change to.
Expand Down
2 changes: 1 addition & 1 deletion grbl/grbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// Grbl versioning system
#define GRBL_VERSION "1.1f"
#define GRBL_VERSION_BUILD "20170128"
#define GRBL_VERSION_BUILD "20170129"

// Define standard libraries used by Grbl.
#include <avr/io.h>
Expand Down
6 changes: 3 additions & 3 deletions grbl/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ static void protocol_exec_rt_suspend()
if ((bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) &&
(parking_target[PARKING_AXIS] < PARKING_TARGET) &&
bit_isfalse(settings.flags,BITFLAG_LASER_MODE) &&
!sys.override_ctrl) {
(sys.override_ctrl == OVERRIDE_PARKING_MOTION)) {
#else
if ((bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) &&
(parking_target[PARKING_AXIS] < PARKING_TARGET) &&
Expand Down Expand Up @@ -650,7 +650,7 @@ static void protocol_exec_rt_suspend()
// NOTE: State is will remain DOOR, until the de-energizing and retract is complete.
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
if (((settings.flags & (BITFLAG_HOMING_ENABLE|BITFLAG_LASER_MODE)) == BITFLAG_HOMING_ENABLE) &&
!sys.override_ctrl) {
(sys.override_ctrl == OVERRIDE_PARKING_MOTION)) {
#else
if ((settings.flags & (BITFLAG_HOMING_ENABLE|BITFLAG_LASER_MODE)) == BITFLAG_HOMING_ENABLE) {
#endif
Expand Down Expand Up @@ -689,7 +689,7 @@ static void protocol_exec_rt_suspend()
// Execute slow plunge motion from pull-out position to resume position.
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
if (((settings.flags & (BITFLAG_HOMING_ENABLE|BITFLAG_LASER_MODE)) == BITFLAG_HOMING_ENABLE) &&
!sys.override_ctrl) {
(sys.override_ctrl == OVERRIDE_PARKING_MOTION)) {
#else
if ((settings.flags & (BITFLAG_HOMING_ENABLE|BITFLAG_LASER_MODE)) == BITFLAG_HOMING_ENABLE) {
#endif
Expand Down
2 changes: 1 addition & 1 deletion grbl/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void report_gcode_modes()
#endif

#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
if (sys.override_ctrl) {
if (sys.override_ctrl == OVERRIDE_PARKING_MOTION) {
report_util_gcode_modes_M();
print_uint8_base10(56);
}
Expand Down

0 comments on commit beaa405

Please sign in to comment.