Skip to content

Commit

Permalink
Changed safety door/parking handling to be compliant with legacy Grbl.
Browse files Browse the repository at this point in the history
Added $384 setting for controlling G92 offset persistence.
Improved $help command output and handling.
Moved the optional tool table in non-volatile storage.
Added gcode parameter support and optional expression support.
  • Loading branch information
terjeio committed Sep 29, 2021
1 parent 11640ad commit 71dc5ac
Show file tree
Hide file tree
Showing 30 changed files with 2,480 additions and 410 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ target_sources(grbl INTERFACE
${CMAKE_CURRENT_LIST_DIR}/tool_change.c
${CMAKE_CURRENT_LIST_DIR}/alarms.c
${CMAKE_CURRENT_LIST_DIR}/errors.c
${CMAKE_CURRENT_LIST_DIR}/ngc_params.c
${CMAKE_CURRENT_LIST_DIR}/ngc_expr.c
${CMAKE_CURRENT_LIST_DIR}/regex.c
)

target_include_directories(grbl INTERFACE ${CMAKE_CURRENT_LIST_DIR})
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It has been written to complement grblHAL and has features such as proper keyboa

---

Latest build date is 20210907, see the [changelog](changelog.md) for details.
Latest build date is 20210928, see the [changelog](changelog.md) for details.
__NOTE:__ Drivers built with more than three axes configured \(`N_AXIS` > `3`\) will force a settings reset when upgraded. Backup and restore of settings is recommended for these.

---
Expand Down Expand Up @@ -68,7 +68,7 @@ List of Supported G-Codes:
- Coolant Control: M7, M8, M9
- Spindle Control: M3, M4, M5
- Tool Change: M6* (Two modes possible: manual** - supports jogging, ATC), M61
- Switches: M49, M50, M51, M53
- Switches: M48, M49, M50, M51, M53
- Output control***: M62, M63, M64, M65, M66, M67, M68
- Valid Non-Command Words: A*, B*, C*, F, H*, I, J, K, L, N, P, Q*, R, S, T, X, Y, Z
Expand All @@ -80,4 +80,4 @@ List of Supported G-Codes:
Some [plugins](https://github.com/grblHAL/plugins) implements additional M-codes.

---
2021-09-08
2021-09-28
21 changes: 21 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
## grblHAL changelog

Build 20210928:

Core:
* Changed safety door/parking handling to be compliant with legacy Grbl - now a cycle start command has to be issued to resume after the door is closed.
* Added `$384` setting for controlling G92 offset persistence, set to `1` to disable persistence across a reboot, `0` to enable. Only available if [compatibility level](https://github.com/grblHAL/core/wiki/Compatibility-level) is < 2, default value is `0`.
* Improved `$help` command output and handling, added description to `$$=<n>` output.
* Moved the optional tool table in non-volatile storage \(typically EEPROM\) to above the core area. This allows a larger number of tools \(max. 16\) to be defined.
__NOTE:__ If you have tool table support enabled before upgrading the current table will be lost and possibly also all other settings. Backup and restore!
* Added gcode parameter support. All [NIST RS274NGC version 3](https://www.nist.gov/publications/nist-rs274ngc-interpreter-version-3) parameters (see section 3.2.1) and most [LinuxCNC](http://www.linuxcnc.org/docs/html/gcode/overview.html#_parameters) parameters are supported.
The `$#=<n>` or `$#=<name>` commands can be used to output a parameter value. Replace `<n>` with a parameter number, `<name>` with a parameter name.
__NOTE 1:__ Named parameters and parameters in the range 1 to 5160 are volatile and will not persist across a reboot.
__NOTE 2:__ Space for the volatile parameters is allocated at run-time, available memory \(heap\) sets a limit to how many can be set.
__NOTE 3:__ Maximum name length is 20 characters, maximum number of parameters that can be set in a block \(line\) is 10.
* Added gcode [expression](http://www.linuxcnc.org/docs/html/gcode/overview.html#gcode:expressions) support. This has to be enabled in [grbl/config.h](./config.h) by uncommenting `//#define NGC_EXPRESSIONS_ENABLE 1`. _Experimental_.
__NOTE:__ Processors with limited memory may not compile with this enabled.

Drivers & plugins:

* Added [WebUI plugin](https://github.com/grblHAL/Plugin_WebUI) support for some networking capable boards.
* Updated some drivers for internal API changes. Some minor bug fixes.

Build 20210907:

Core:
Expand Down
24 changes: 21 additions & 3 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ __NOTE:__ if switching to a level > 1 please reset non-volatile storage with \a
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
// previous tool path, as if nothing happened.
// #define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
//#define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.

// After the safety door switch has been toggled and restored, this setting sets the power-up delay
// between restoring the spindle and coolant and resuming the cycle.
Expand Down Expand Up @@ -472,9 +472,24 @@ __NOTE:__ these definitions are only referenced in this file. Do __NOT__ change!
//#define DEFAULT_REPORT_PARSER_STATE
//#define DEFAULT_REPORT_ALARM_SUBSTATE

// G92 offsets is by default stored to non-volatile storage (NVS) on changes and restored on startup
// if COMPATIBILITY_LEVEL is <= 1. If COMPATIBILITY_LEVEL is <= 1 then setting $384 can be used to change this at run-time.
// To allow store/restore of the G92 offset when COMPATIBILITY_LEVEL > 1 uncomment the line below and reset settings with $RST=*.
//#define DISABLE_G92_PERSISTENCE 0

#if COMPATIBILITY_LEVEL == 0
// Number of tools in ATC tool table, comment out to disable
// #define N_TOOLS 8
// Number of tools in tool table, uncomment and edit if neccesary to enable (max. 16 allowed)
//#define N_TOOLS 8
#endif

// Sanity checks - N_TOOLS may have been defined on the compiler command line.
#if defined(N_TOOLS) && N_TOOLS == 0
#undef N_TOOLS
#endif

#if defined(N_TOOLS) && N_TOOLS > 16
#undef N_TOOLS
#define N_TOOLS 16
#endif

// Max number of entries in log for PID data reporting, to be used for tuning
Expand Down Expand Up @@ -624,4 +639,7 @@ __NOTE:__ these definitions are only referenced in this file. Do __NOT__ change!

#endif // DEFAULT_HOMING_ENABLE

// Uncomment to enable experimental support for parameters and expressions
//#define NGC_EXPRESSIONS_ENABLE 1

#endif
14 changes: 14 additions & 0 deletions defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
// Note: DEFAULT_ACCELERATION is only referenced in this file
#define DEFAULT_ACCELERATION (10.0f * 60.0f * 60.0f) // 10*60*60 mm/min^2 = 10 mm/sec^2

#ifndef DISABLE_G92_PERSISTENCE
#if COMPATIBILITY_LEVEL <= 1
#define DISABLE_G92_PERSISTENCE 0
#else
#define DISABLE_G92_PERSISTENCE 1
#endif
#endif

#ifdef DEFAULT_REPORT_MACHINE_POSITION
#undef DEFAULT_REPORT_MACHINE_POSITION
#define DEFAULT_REPORT_MACHINE_POSITION 1
Expand Down Expand Up @@ -609,6 +617,12 @@
#define INVERT_COOLANT_MIST_PIN 0
#endif

#ifndef NGC_EXPRESSIONS_ENABLE
#define NGC_EXPRESSIONS_ENABLE 0
#else
#define NGC_N_ASSIGN_PARAMETERS_PER_BLOCK 10
#endif

// ---------------------------------------------------------------------------------------
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:

Expand Down
2 changes: 1 addition & 1 deletion driver_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
#if NETWORK_IPMODE < 0 || NETWORK_IPMODE > 2
#error "Invalid IP mode selected!"
#endif
#if NETWORK_WEBSOCKET_PORT == NETWORK_HTTP_PORT
#if HTTP_ENABLE && NETWORK_WEBSOCKET_PORT == NETWORK_HTTP_PORT
#warning "HTTP and WebSocket protocols cannot share the same port!"
#endif
#endif
Expand Down
10 changes: 9 additions & 1 deletion errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ PROGMEM static const status_detail_t status_detail[] = {
{ Status_MotorFault, "Motor fault", "Motor fault." },
{ Status_SettingValueOutOfRange, "Value out of range.", "Setting value is out of range." },
{ Status_SettingDisabled, "Setting disabled", "Setting is not available, possibly due to limited driver support." },
{ Status_GcodeInvalidRetractPosition, "Invalid gcode ID:54", "Retract position is less than drill depth." }
{ Status_GcodeInvalidRetractPosition, "Invalid gcode ID:54", "Retract position is less than drill depth." },
#if NGC_EXPRESSIONS_ENABLE
{ Status_ExpressionUknownOp, "Unknown operation found in expression", "Unknown operation found in expression." },
{ Status_ExpressionDivideByZero, "Divide by zero in expression", "Divide by zero in expression attempted." },
{ Status_ExpressionArgumentOutOfRange, "Expression argument out of range", "Too large or too small argrument provided." },
{ Status_ExpressionInvalidArgument, "Invalid expression argument", "Argument is not valid for the operation" },
{ Status_ExpressionSyntaxError, "Syntax error in expression", "Expression is not valid." },
{ Status_ExpressionInvalidResult, "Invalid result returned from expression", "Either NAN (not a number) or infinity was returned from expression." }
#endif
};

static error_details_t details = {
Expand Down
9 changes: 9 additions & 0 deletions errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ typedef enum {
Status_SDFileEmpty = 64,

Status_BTInitError = 70,

//
Status_ExpressionUknownOp = 71,
Status_ExpressionDivideByZero = 72,
Status_ExpressionArgumentOutOfRange = 73,
Status_ExpressionInvalidArgument = 74,
Status_ExpressionSyntaxError = 75,
Status_ExpressionInvalidResult = 76,

Status_Unhandled, // For internal use only
Status_StatusMax = Status_Unhandled
} status_code_t;
Expand Down
Loading

0 comments on commit 71dc5ac

Please sign in to comment.