From fb60b493b53005d2b7a96da678e153c2953c9feb Mon Sep 17 00:00:00 2001 From: Terje Io Date: Wed, 25 Jan 2023 21:11:21 +0100 Subject: [PATCH] Added settings, updated settings version to 22. See changelog for details. Merged defaults.h with config.h, deleted defaults.h and harmonized settings defines. --- README.md | 6 +- alarms.h | 40 +- changelog.md | 67 ++ config.h | 2313 ++++++++++++++++++++++++++++++++++----------- coolant_control.h | 1 + core_handlers.h | 13 +- corexy.c | 4 +- defaults.h | 650 ------------- driver_opts.h | 20 +- errors.c | 19 +- errors.h | 3 +- gcode.c | 75 +- gcode.h | 29 +- grbl.h | 79 +- grbllib.c | 42 +- hal.h | 12 +- ioports.h | 5 +- machine_limits.c | 20 +- maslow.c | 2 +- motion_control.c | 33 +- motion_control.h | 14 +- nuts_bolts.c | 72 +- nuts_bolts.h | 5 +- nvs.h | 8 +- nvs_buffer.c | 14 +- nvs_buffer.h | 4 +- planner.c | 123 ++- plugins_init.h | 7 +- protocol.c | 22 +- report.c | 64 +- settings.c | 196 ++-- settings.h | 50 +- spindle_control.c | 27 +- spindle_control.h | 14 + state_machine.c | 8 +- stepper.c | 29 +- stepper.h | 6 +- stream.h | 10 +- system.c | 18 +- system.h | 5 +- tool_change.c | 6 +- wall_plotter.c | 2 +- 42 files changed, 2472 insertions(+), 1665 deletions(-) delete mode 100644 defaults.h diff --git a/README.md b/README.md index 5aff7e8..0b60eaa 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ It has been written to complement grblHAL and has features such as proper keyboa --- -Latest build date is 20221115, see the [changelog](changelog.md) for details. -__NOTE:__ A settings reset will be performed on an update for versions earlier than 20211122. Backup and restore of settings is recommended. +Latest build date is 20230125, see the [changelog](changelog.md) for details. +__NOTE:__ A settings reset will be performed on an update. Backup and restore of settings is recommended. __IMPORTANT!__ A new setting has been introduced for ganged axes motors in version 20211121. I have only bench tested this for a couple of drivers, correct function should be verified after updating by those who have more than three motors configured. More details in the [changelog](changelog.md). @@ -87,4 +87,4 @@ List of Supported G-Codes: Some [plugins](https://github.com/grblHAL/plugins) implements additional M-codes. --- -2022-10-23 +2023-01-25 diff --git a/alarms.h b/alarms.h index fad3446..11d35a3 100644 --- a/alarms.h +++ b/alarms.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2021 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -26,25 +26,25 @@ // Alarm executor codes. Valid values (1-255). Zero is reserved. typedef enum { - Alarm_None = 0, - Alarm_HardLimit = 1, - Alarm_SoftLimit = 2, - Alarm_AbortCycle = 3, - Alarm_ProbeFailInitial = 4, - Alarm_ProbeFailContact = 5, - Alarm_HomingFailReset = 6, - Alarm_HomingFailDoor = 7, - Alarm_FailPulloff = 8, - Alarm_HomingFailApproach = 9, - Alarm_EStop = 10, - Alarm_HomingRequried = 11, - Alarm_LimitsEngaged = 12, - Alarm_ProbeProtect = 13, - Alarm_Spindle = 14, - Alarm_HomingFailAutoSquaringApproach = 15, - Alarm_SelftestFailed = 16, - Alarm_MotorFault = 17, - Alarm_HomingFail = 18, + Alarm_None = 0, //!< 0 + Alarm_HardLimit = 1, //!< 1 + Alarm_SoftLimit = 2, //!< 2 + Alarm_AbortCycle = 3, //!< 3 + Alarm_ProbeFailInitial = 4, //!< 4 + Alarm_ProbeFailContact = 5, //!< 5 + Alarm_HomingFailReset = 6, //!< 6 + Alarm_HomingFailDoor = 7, //!< 7 + Alarm_FailPulloff = 8, //!< 8 + Alarm_HomingFailApproach = 9, //!< 9 + Alarm_EStop = 10, //!< 10 + Alarm_HomingRequried = 11, //!< 11 + Alarm_LimitsEngaged = 12, //!< 12 + Alarm_ProbeProtect = 13, //!< 13 + Alarm_Spindle = 14, //!< 14 + Alarm_HomingFailAutoSquaringApproach = 15, //!< 15 + Alarm_SelftestFailed = 16, //!< 16 + Alarm_MotorFault = 17, //!< 17 + Alarm_HomingFail = 18, //!< 18 Alarm_AlarmMax = Alarm_HomingFail } alarm_code_t; diff --git a/changelog.md b/changelog.md index 65a5a2a..950f960 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,72 @@ ## grblHAL changelog +Build 20230125 + +Core: + +* Added settings, updated settings version to 22: +`$398` - _planner buffer blocks_, default value 35. +`$481` - auto real time report interval. Default value 0 \(auto reporting disabled\), range 100 - 1000 ms. +When enabled `|AR` is added to the full real time report \(requested by the real time command `0xA7`\). +New real time command `0x8C` can be used to toggle auto reporting on/off. +`$482` - timezone offset. To be implemented. + +* Added parsing of gcode words `O` and `$`. `O` is currently not used by the core, `$` value is for selecting the spindle to address for some gcode commands, +currently only `-1` or `0` is allowed. + +* Added _allow null_ flag \(0 for off, 1 for on\) to `$ES` and `$ESH` outputs. When set to 1 for range restricted values they can be set to an empty string or 0 depending on the data type. + +* Merged _defaults.h_ with [config.h](./config.h), deleted _defaults.h_. +Changed some symbol/macro names for consistency, e.g. all starting with `DEFAULT_` can be changed at run time with `$` commands. Reorganized file and added doxygen [documentation](http://svn.io-engineering.com/grblHAL/html/config_8h.html). + +* Fix for issue [#43](https://github.com/grblHAL/RP2040/issues/43), _Laser mode spindle enable after pause_. + +__Note:__ Backup and restore your settings as they will be reset to default values. + +Plugins: + +* Keypad: added macros plugin, up to 8 macros can be bound to pins and/or to keypad single character commands. Added jog support for A-axis to keypad plugin, extended programming interface. + +* Spindle: merged [#14](https://github.com/grblHAL/Plugins_spindle/pull/14) - fix typo on GS20 driver to set RPM correctly. + +* Fans: added setting `$483` for linking spindle enable signal to fan\(s\) enable. + +Drivers: + +* All: updated for settings version change. + +* ESP32: added board map for OpenBuilds BlackBox X32, fix for issue [#48](https://github.com/grblHAL/ESP32/issues/48), [#49](https://github.com/grblHAL/ESP32/issues/49), [#50](https://github.com/grblHAL/ESP32/issues/50), [#56](https://github.com/grblHAL/ESP32/issues/56) \(needs end user testing\) and [#58](https://github.com/grblHAL/ESP32/issues/58) plus some board map updates/fixes. + +* iMRX1062: now maps spindle enable and spindle direction signals as aux outputs if a single VFD spindle is configured. + +* RP2040: fix for motor plugin issue [#7](https://github.com/grblHAL/Plugins_motor/issues/7#issuecomment-1381331011). + +* SAM3X8E: added probe pin assignment for Ramps 1.6 board. + +* STM32F1xx: some bug fixes, added board map for MACH3 breakout board. + +* STM32F4xx: fixed IRQ conflict for BTT SKR v1 and v2 boards by reducing max number of allowed auto squared axes. + +* STM32F7xx: some bug fixes, merged PR [#11](https://github.com/grblHAL/STM32F7xx/pull/11) and [#12](https://github.com/grblHAL/STM32F7xx/pull/12). + +--- + +Build 20221101 + +Core: + +* Added single axis homing commands for U and V, remapping of ABC homing commands to UVW when configured. + +Plugins + +* WebUI and Networking: fixes for compiler warnings. + +Drivers: + +* ESP32: fix for Web Builder failing when networking was enabled. + +--- + Build 20221115 Core: diff --git a/config.h b/config.h index 67a72c5..98355a0 100644 --- a/config.h +++ b/config.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2020-2022 Terje Io + Copyright (c) 2020-2023 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,95 +19,757 @@ along with Grbl. If not, see . */ -// This file contains compile-time configurations for Grbl's internal system. For the most part, -// users will not need to directly modify these, but they are here for specific needs, i.e. -// performance tuning or adjusting to non-typical machines. - -// IMPORTANT: Any changes here requires a full re-compiling of the source code to propagate them. -// A reset of non-volatile storage with $RST=* after reflashing is also required as -// most are just default values for settings. +/*! \file +\brief This file contains compile-time and run-time configurations for grblHAL's internal system. +For the most part, users will not need to directly modify these, but they are here for +specific needs, i.e. performance tuning or adjusting to non-typical machines. +
__IMPORTANT:__ Symbol/macro names starting with `DEFAULT_` contains default values for run-time + configuarble settings that can be changed with `$=` commands. + Any changes to these requires a full re-compiling of the source code to propagate them. + A reset of non-volatile storage with `$RST=*` after reflashing is also required. +*/ #ifndef _GRBL_CONFIG_H_ #define _GRBL_CONFIG_H_ // Compile time only default configuration - -// Uncomment this line to enable $398 for configuring number of blocks in the planner buffer. -// NOTE: Changing this will usually reset the settings to default values. Backup and restore! -// NOTE: If the $398 value is set too high number of blocks will be reduced until -// a buffer can be allocated. Use $I to check if value was set too high. -// NOTE: this compile time option will be removed in a later version and dynamic allocation -// will become the default. -//#define BLOCK_BUFFER_DYNAMIC - +/*! \def N_AXIS +\brief Defines number of axes supported - minimum 3, maximum 8. +If more than 3 axes are configured a compliant driver and board map file is needed. + */ #ifndef N_AXIS -/*! Defines number of axes supported - minimum 3, maximum 8 - -If more than 3 axes are configured a compliant driver and map file is needed. -*/ #define N_AXIS 3 // Number of axes #endif -/*! Remap ABC axis letters to UVW - -Experimental: if more than 3 and less than 7 axes are configured the ABC axis letters can be remapped to UWV. +/*! \def AXIS_REMAP_ABC2UVW +\brief Remap `ABC` axis letters to `UVW` +
__NOTE:__ Experimental, if more than 3 and less than 7 axes are configured the `ABC` + axis letters can be remapped to `UWV`. */ -#if N_AXIS > 3 && N_AXIS < 7 -//#define AXIS_REMAP_ABC2UVW // Default disabled. Uncomment to enable. +#if (N_AXIS > 3 && N_AXIS < 7) || defined __DOXYGEN__ +#define AXIS_REMAP_ABC2UVW Off #endif -#ifndef N_SPINDLE -/*! Defines number of spindles supported - minimum 1, maximum 32 +/*! \def N_SPINDLE +\brief Defines number of spindles supported - minimum 1, maximum 32. */ +#if !defined N_SPINDLE || defined __DOXYGEN__ #define N_SPINDLE 1 #endif -#ifndef COMPATIBILITY_LEVEL -/*! Define compatibility level with the grbl 1.1 protocol. +/*! \def BUILD_INFO +\brief Defines string to be output as part of the `$I` or `$I+` command response. +*/ +#if !defined BUILD_INFO || defined __DOXYGEN__ +#define BUILD_INFO "" +#endif + +/*! \def COMPATIBILITY_LEVEL +\brief Define compatibility level with the legacy Grbl 1.1 protocol. Additional G- and M-codes are not disabled except when level is set to >= 10. -This does not apply to G- and M-codes dependent on driver and/or configuration settings disabled by setting level > 1. -
Set to 0 for reporting itself as "GrblHAL" with protocol extensions enabled. -
Set to 1 to disable some extensions, and for reporting itself as "Grbl". -
Set to 2 to disable new settings as well, use #define parameters for setting default values. +This does not apply to G- and M-codes dependent on driver and/or configuration +settings disabled by setting level > 1. +
Set to `0` for reporting itself as "GrblHAL" with protocol extensions enabled. +
Set to `1` to disable some extensions, and for reporting itself as "Grbl". +
Set to `2` to disable new settings as well, use \#define symbols/macros for setting default values.
These can be found in in this file and in defaults.h. -
Set to 10 to also disable new coordinate system offsets (G59.1 - G59.3) and some $# report extensions. +
Set to `10` to also disable new coordinate system offsets (G59.1 - G59.3) and some `$#` report extensions. -__NOTE:__ if switching to a level > 1 please reset non-volatile storage with \a $RST=* after reflashing! +__NOTE:__ if switching to a level > 1 please reset non-volatile storage with `$RST=*` after reflashing! */ +#if !defined COMPATIBILITY_LEVEL || defined __DOXYGEN__ #define COMPATIBILITY_LEVEL 0 #endif -//#define KINEMATICS_API // Remove comment to add HAL entry points for custom kinematics +#include "nuts_bolts.h" +//#define KINEMATICS_API // Uncomment to add HAL entry points for custom kinematics + +/*! \def MASLOW_ROUTER +\brief Enable Maslow router kinematics. +Experimental - testing required and homing needs to be worked out. +*/ +#if !defined MASLOW_ROUTER || defined __DOXYGEN__ // Enable Maslow router kinematics. // Experimental - testing required and homing needs to be worked out. -//#define MASLOW_ROUTER // Default disabled. Uncomment to enable. +#define MASLOW_ROUTER Off +#endif -// Enable wall plotter kinematics. -// Experimental - testing required and homing needs to be worked out. -//#define WALL_PLOTTER // Default disabled. Uncomment to enable. +/*! \def WALL_PLOTTER +\brief Enable wall plotter kinematics. +Experimental - testing required and homing needs to be worked out. +*/ +#if !defined WALL_PLOTTER || defined __DOXYGEN__ +#define WALL_PLOTTER Off +#endif -// Enable CoreXY kinematics. Use ONLY with CoreXY machines. -// IMPORTANT: If homing is enabled, you must reconfigure the homing cycle #defines above to -//#define HOMING_CYCLE_0 X_AXIS_BIT and #define HOMING_CYCLE_1 Y_AXIS_BIT -// NOTE: This configuration option alters the motion of the X and Y axes to principle of operation -// defined at (http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as -// described, if not, motions may move in strange directions. Grbl requires the CoreXY A and B motors -// have the same steps per mm internally. -//#define COREXY // Default disabled. Uncomment to enable. +/*! \def COREXY +\brief Enable CoreXY kinematics. Use ONLY with CoreXY machines. +
__IMPORTANT:__ If homing is enabled, you must reconfigure the homing cycle \#defines above to +\#define \ref DEFAULT_HOMING_CYCLE_1 `X_AXIS_BIT` and \#define \ref DEFAULT_HOMING_CYCLE_2 `Y_AXIS_BIT` +
__NOTE:__ This configuration option alters the motion of the X and Y axes to principle of operation +defined at [corexy.com](http://corexy.com/theory.html). Motors are assumed to positioned and wired exactly as +described, if not, motions may move in strange directions. grblHAL requires the CoreXY A and B motors +have the same steps per mm internally. +*/ +#if !defined COREXY || defined __DOXYGEN__ +#define COREXY Off +#endif -// Add a short delay for each block processed in Check Mode to -// avoid overwhelming the sender with fast reply messages. -// This is likely to happen when streaming is done via a protocol where -// the speed is not limited to 115200 baud. An example is native USB streaming. -//#define CHECK_MODE_DELAY 0 // ms +/*! \def CHECK_MODE_DELAY +\brief +Add a short delay for each block processed in Check Mode to +avoid overwhelming the sender with fast reply messages. +This is likely to happen when streaming is done via a protocol where +the speed is not limited to 115200 baud. An example is native USB streaming. +*/ +#if !defined CHECK_MODE_DELAY || defined __DOXYGEN__ +#define CHECK_MODE_DELAY 0 // ms +#endif -// 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. -//#define SAFETY_DOOR_SPINDLE_DELAY 4.0f // Float (seconds) -//#define SAFETY_DOOR_COOLANT_DELAY 1.0f // Float (seconds) +// --------------------------------------------------------------------------------------- +// ADVANCED CONFIGURATION OPTIONS: + +// Enables code for debugging purposes. Not for general use and always in constant flux. +//#define DEBUG // Uncomment to enable. Default disabled. +//#define DEBUGOUT 0 // Uncomment to claim serial port with given instance number and add HAL entry point for debug output. + +/*! @name Status report frequency +Some status report data isn't necessary for realtime, only intermittently, because the values don't +change often. The following macros configures how many times a status report needs to be called before +the associated data is refreshed and included in the status report. However, if one of these value +changes, grblHAL will automatically include this data in the next status report, regardless of what the +count is at the time. This helps reduce the communication overhead involved with high frequency reporting +and aggressive streaming. There is also a busy and an idle refresh count, which sets up grblHAL to send +refreshes more often when its not doing anything important. With a good GUI, this data doesn't need +to be refreshed very often, on the order of a several seconds. +
__NOTE:__ `WCO` refresh must be 2 or greater. `OVERRIDE` refresh must be 1 or greater. +*/ +///@{ +#if !defined REPORT_OVERRIDE_REFRESH_BUSY_COUNT || defined __DOXYGEN__ +#define REPORT_OVERRIDE_REFRESH_BUSY_COUNT 20 // (1-255) +#endif +#if !defined REPORT_OVERRIDE_REFRESH_IDLE_COUNT || defined __DOXYGEN__ +#define REPORT_OVERRIDE_REFRESH_IDLE_COUNT 10 // (1-255) Must be less than or equal to the busy count +#endif +#if !defined REPORT_WCO_REFRESH_BUSY_COUNT || defined __DOXYGEN__ +#define REPORT_WCO_REFRESH_BUSY_COUNT 30 // (2-255) +#endif +#if !defined REPORT_WCO_REFRESH_IDLE_COUNT || defined __DOXYGEN__ +#define REPORT_WCO_REFRESH_IDLE_COUNT 10 // (2-255) Must be less than or equal to the busy count +#endif +///@} + +/*! \def ACCELERATION_TICKS_PER_SECOND +\brief The temporal resolution of the acceleration management subsystem. +A higher number gives smoother +acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively +impact performance. The correct value for this parameter is machine dependent, so it's advised to +set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more. +
__NOTE:__ Changing this value also changes the execution time of a segment in the step segment buffer. +When increasing this value, this stores less overall time in the segment buffer and vice versa. Make +certain the step segment buffer is increased/decreased to account for these changes. +*/ +#if !defined ACCELERATION_TICKS_PER_SECOND || defined __DOXYGEN__ +#define ACCELERATION_TICKS_PER_SECOND 100 +#endif + +// Sets the maximum step rate allowed to be written as a grblHAL setting. This option enables an error +// check in the settings module to prevent settings values that will exceed this limitation. The maximum +// step rate is strictly limited by the CPU speed and will change if something other than an AVR running +// at 16MHz is used. +// NOTE: For now disabled, will enable if flash space permits. +//#define MAX_STEP_RATE_HZ 30000 // Hz + +/*! \def REPORT_ECHO_LINE_RECEIVED +\brief +With this enabled, grblHAL sends back an echo of the line it has received, which has been pre-parsed (spaces +removed, capitalized letters, no comments) and is to be immediately executed by grblHAL. Echoes will not be +sent upon a line buffer overflow, but should for all normal lines sent to grblHAL. For example, if a user +sends the line 'g1 x1.032 y2.45 (test comment)', grblHAL will echo back in the form '[echo: G1X1.032Y2.45]'. +NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect +performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased +to help minimize transmission waiting within the serial write protocol. + */ +#if !defined REPORT_ECHO_LINE_RECEIVED || defined __DOXYGEN__ +#define REPORT_ECHO_LINE_RECEIVED Off // Default disabled. Set to \ref On or 1 to enable. +#endif + +/*! \def TOOL_LENGTH_OFFSET_AXIS +\brief Sets which \ref axis the tool length offset is applied. +Assumes the spindle is always parallel with the selected axis with the tool oriented toward +the negative direction. In other words, a positive tool length offset value is subtracted +from the current location. +*/ +#if !defined TOOL_LENGTH_OFFSET_AXIS || defined __DOXYGEN__ +#define TOOL_LENGTH_OFFSET_AXIS 0 // Default is all axes. +#endif + +/*! \def MINIMUM_JUNCTION_SPEED +\brief Minimum planner junction speed. +Sets the default minimum junction speed the planner plans to at every buffer block junction, +except for starting from rest and end of the buffer, which are always zero. This value controls +how fast the machine moves through junctions with no regard for acceleration limits or angle +between neighboring block line move directions. This is useful for machines that can't +tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value +should not be much greater than zero or to the minimum value necessary for the machine to work. +*/ +#if !defined MINIMUM_JUNCTION_SPEED || defined __DOXYGEN__ +#define MINIMUM_JUNCTION_SPEED 0.0f // (mm/min) +#endif + +/*! \def MINIMUM_FEED_RATE +\brief +Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum +value. This also ensures that a planned motion always completes and accounts for any floating-point +round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller +machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors. +*/ +#if !defined MINIMUM_FEED_RATE || defined __DOXYGEN__ +#define MINIMUM_FEED_RATE 1.0f // (mm/min) +#endif + +/*! \def N_ARC_CORRECTION +\brief +Number of arc generation iterations by small angle approximation before exact arc trajectory +correction with expensive sin() and cos() calculations. This parameter maybe decreased if there +are issues with the accuracy of the arc generations, or increased if arc execution is getting +bogged down by too many trig calculations. +*/ +#if !defined N_ARC_CORRECTION || defined __DOXYGEN__ +#define N_ARC_CORRECTION 12 // Integer (1-255) +#endif + +/*! \def ARC_ANGULAR_TRAVEL_EPSILON +\brief +The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical +errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate +but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating +point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely +small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues. +This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not. +
__NOTE:__ Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too +much greater than this. The default setting should capture most, if not all, full arc error situations. +*/ +#if !defined ARC_ANGULAR_TRAVEL_EPSILON || defined __DOXYGEN__ +#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7f // Float (radians) +#endif + +/*! @name Default constants for G5 Cubic splines +// +*/ +///@{ +#if !defined BEZIER_MIN_STEP || defined __DOXYGEN__ +#define BEZIER_MIN_STEP 0.002f +#endif +#if !defined BEZIER_MAX_STEP || defined __DOXYGEN__ +#define BEZIER_MAX_STEP 0.1f +#endif +#if !defined BEZIER_SIGMA || defined __DOXYGEN__ +#define BEZIER_SIGMA 0.1f +#endif +///@} + + +/*! \def DWELL_TIME_STEP +\brief Time delay increments performed during a dwell. +The default value is set at 50ms, which provides a maximum time delay of roughly 55 minutes, +more than enough for most any application. Increasing this delay will increase the maximum +dwell time linearly, but also reduces the responsiveness of run-time command executions, +like status reports, since these are performed between each dwell time step. +*/ +#if !defined DWELL_TIME_STEP || defined __DOXYGEN__ +#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) +#endif + +/*! \def SEGMENT_BUFFER_SIZE +\brief +Governs the size of the intermediary step segment buffer between the step execution algorithm +and the planner blocks. Each segment is set of steps executed at a constant velocity over a +fixed time defined by \ref ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner +block velocity profile is traced exactly. The size of this buffer governs how much step +execution lead time there is for other grblHAL processes have to compute and do their thing +before having to come back and refill this buffer, currently at ~50msec of step moves. +*/ +#if !defined SEGMENT_BUFFER_SIZE || defined __DOXYGEN__ +#define SEGMENT_BUFFER_SIZE 10 // Uncomment to override default in stepper.h. +#endif + +/*! \def SET_CHECK_MODE_PROBE_TO_START +\brief +Configures the position after a probing cycle during grblHAL's check mode. Disabled sets +the position to the probe target, when enabled sets the position to the start position. +*/ +#if !defined SET_CHECK_MODE_PROBE_TO_START || defined __DOXYGEN__ +#define SET_CHECK_MODE_PROBE_TO_START Off // Default disabled. Set to \ref On or 1 to enable. +#endif + +/*! \def HARD_LIMIT_FORCE_STATE_CHECK +\brief +Force grblHAL to check the state of the hard limit switches when the processor detects a pin +change inside the hard limit ISR routine. By default, grblHAL will trigger the hard limits +alarm upon any pin change, since bouncing switches can cause a state check like this to +misread the pin. When hard limits are triggered, they should be 100% reliable, which is the +reason that this option is disabled by default. Only if your system/electronics can guarantee +that the switches don't bounce, we recommend enabling this option. This will help prevent +triggering a hard limit when the machine disengages from the switch. +
__NOTE:__ This option has no effect if SOFTWARE_DEBOUNCE is enabled. +*/ +#if !defined HARD_LIMIT_FORCE_STATE_CHECK || defined __DOXYGEN__ +#define HARD_LIMIT_FORCE_STATE_CHECK Off // Default disabled. Set to \ref On or 1 to enable. +#endif + +/*! @name Homing cycle search and locate scalars +\brief +Adjusts homing cycle search and locate scalars. These are the multipliers used by grblHAL's +homing cycle to ensure the limit switches are engaged and cleared through each phase of +the cycle. The search phase uses the axes max-travel setting times the +`HOMING_AXIS_SEARCH_SCALAR` to determine distance to look for the limit switch. Once found, +the locate phase begins and uses the homing pull-off distance setting times the +`HOMING_AXIS_LOCATE_SCALAR` to pull-off and re-engage the limit switch. +
__NOTE:__ Both of these values must be greater than 1.0 to ensure proper function. +*/ +///@{ +#if !defined HOMING_AXIS_SEARCH_SCALAR || defined __DOXYGEN__ +#define HOMING_AXIS_SEARCH_SCALAR 1.5f // Must be > 1 to ensure limit switch will be engaged. +#endif +#if !defined HOMING_AXIS_LOCATE_SCALAR || defined __DOXYGEN__ +#define HOMING_AXIS_LOCATE_SCALAR 10.0f// Must be > 1 to ensure limit switch is cleared. +#endif +///@} + +/*! @name Non-volatile storage restore commands +\brief +Enable the `$RST=*`, `$RST=$`, `$RST=#` and `$RST=&` non-volatile storage restore commands. There are +cases where these commands may be undesirable. Simply change desired macro to \ref Off or 0 to disable it. +
__NOTE:__ See _Non-volatile storage restore options_ below for customizing the `$RST=*` command. +*/ +///@{ +#if !defined ENABLE_RESTORE_NVS_WIPE_ALL || defined __DOXYGEN__ +#define ENABLE_RESTORE_NVS_WIPE_ALL On //!< `$RST=*` Default enabled. Set to \ref Off or 0 to disable. +#endif +#if !defined ENABLE_RESTORE_NVS_DEFAULT_SETTINGS || defined __DOXYGEN__ +#define ENABLE_RESTORE_NVS_DEFAULT_SETTINGS On //!< `$RST=$` Default enabled. Set to \ref Off or 0 to disable. +#endif +#if !defined ENABLE_RESTORE_NVS_CLEAR_PARAMETERS || defined __DOXYGEN__ +#define ENABLE_RESTORE_NVS_CLEAR_PARAMETERS On //!< `$RST=#` Default enabled. Set to \ref Off or 0 to disable. +#endif +#if !defined ENABLE_RESTORE_NVS_DRIVER_PARAMETERS || defined __DOXYGEN__ +#define ENABLE_RESTORE_NVS_DRIVER_PARAMETERS On //!< `$RST=&` Default enabled. Set to \ref Off or 0 to disable. For drivers that implements non-generic settings. +#endif +///@} + +/*! @name Non-volatile storage restore options +\brief +// Defines the non-volatile data restored upon a settings version change and `$RST=*` command. Whenever the +// the settings or other non-volatile data structure changes between grblHAL versions, grblHAL will automatically +// wipe and restore the non-volatile data. These macros controls what data is wiped and restored. This is useful +// particularly for OEMs that need to retain certain data. For example, the \ref BUILD_INFO string can be +// written into non-volatile storage via a separate program to contain product data. Altering these +// macros to not restore the build info non-volatile storage will ensure this data is retained after firmware upgrades. +*/ +///@{ +#if !defined SETTINGS_RESTORE_DEFAULTS || defined __DOXYGEN__ +#define SETTINGS_RESTORE_DEFAULTS On //!< Default enabled. Set to \ref Off or 0 to disable. +#endif +#if !defined SETTINGS_RESTORE_PARAMETERS || defined __DOXYGEN__ +#define SETTINGS_RESTORE_PARAMETERS On //!< Default enabled. Set to \ref Off or 0 to disable. +#endif +#if !defined SETTINGS_RESTORE_STARTUP_LINES || defined __DOXYGEN__ +#define SETTINGS_RESTORE_STARTUP_LINES On //!< Default enabled. Set to \ref Off or 0 to disable. +#endif +#if !defined SETTINGS_RESTORE_BUILD_INFO || defined __DOXYGEN__ +#define SETTINGS_RESTORE_BUILD_INFO On //!< Default enabled. Set to \ref Off or 0 to disable. +#endif +#if !defined SETTINGS_RESTORE_DRIVER_PARAMETERS || defined __DOXYGEN__ +#define SETTINGS_RESTORE_DRIVER_PARAMETERS On //!< Default enabled. Set to \ref Off or 0 to disable. +#endif +/*! \def DISABLE_BUILD_INFO_WRITE_COMMAND +\brief Disable the `$I=(string)` build info write command. +If disabled, any existing build info data must be placed into non-volatile storage via external +means with a valid checksum value. This macro option is useful to prevent this data from being +over-written by a user, when used to store OEM product data. +
__NOTE:__ If disabled and to ensure grblHAL can never alter the build info line, you'll also need +to set the \ref SETTINGS_RESTORE_BUILD_INFO symbol to \ref Off or 0. +*/ +#if !defined DISABLE_BUILD_INFO_WRITE_COMMAND || defined __DOXYGEN__ +#define DISABLE_BUILD_INFO_WRITE_COMMAND Off //!< `$I=` Default enabled. Uncomment to disable. +#endif +///@} + +/*! \def SLEEP_DURATION +\brief Configures grblHAL's sleep mode feature. +If the spindle or coolant are powered and grblHAL is not actively moving or receiving any +commands, a sleep timer will start. If any data or commands are received, the sleep timer +will reset and restart until the above condition are not satisfied. If the sleep timer elaspes, +grblHAL will immediately execute the sleep mode by shutting down the spindle and coolant and +entering a safe sleep state. If parking is enabled, grblHAL will park the machine as well. +While in sleep mode, only a hard/soft reset will exit it and the job will be unrecoverable. +Sleep mode is enabled by setting \ref DEFAULT_SLEEP_ENABLE to \ref On or 1, overridable by the +`$62` setting. +
__NOTE:__ Sleep mode is a safety feature, primarily to address communication disconnect problems. To +keep grblHAL from sleeping, employ a stream of '?' status report commands as a connection "heartbeat". +*/ +#if !defined SLEEP_DURATION || defined __DOXYGEN__ +#define SLEEP_DURATION 5.0f // Number of minutes before sleep mode is entered. +#endif + +/*! \def NVSDATA_BUFFER_ENABLE +\brief Disable non-volatile storage (NVS) emulation/buffering in RAM (allocated from heap memory). +The NVS buffer can be used for MCUs with no non-volatile storage or for delaying writing to +non-volatile storage until the controller is in IDLE state. +*/ +#if !defined NVSDATA_BUFFER_ENABLE || defined __DOXYGEN__ +#define NVSDATA_BUFFER_ENABLE On // Default on, set to \ref off or 0 to disable. +#endif + +/*! \def TOOLSETTER_RADIUS +\brief +The grbl.on_probe_fixture event handler is called by the default tool change algorithm when probing at G59.3. +In addition it will be called on a "normal" probe sequence if the XY position is +within the radius of the G59.3 position defined below. +Change if the default value of 5mm is not suitable or set it to 0.0f to disable. +
__NOTE:__ A grbl.on_probe_fixture event handler is not installed by the core, it has to be provided +by a driver or a plugin. +*/ +#if !defined TOOLSETTER_RADIUS || defined __DOXYGEN__ +#define TOOLSETTER_RADIUS 5.0f +#endif + +#if !defined ENABLE_BACKLASH_COMPENSATION || defined __DOXYGEN__ +#define ENABLE_BACKLASH_COMPENSATION Off +#endif + +#if COMPATIBILITY_LEVEL == 0 || defined __DOXYGEN__ +/*! \def N_TOOLS +\brief +Number of tools in tool table, edit to enable (max. 16 allowed) +*/ +#if !defined N_TOOLS || defined __DOXYGEN__ +#define N_TOOLS 0 +#endif +#endif + +/*! \def NGC_EXPRESSIONS_ENABLE +\brief +Set to \ref On or 1 to enable experimental support for parameters and expressions. + +Some LinuxCNC extensions are supported, conditionals and subroutines are not. +*/ +#if !defined NGC_EXPRESSIONS_ENABLE || defined __DOXYGEN__ +#define NGC_EXPRESSIONS_ENABLE Off +#endif + +/*! \def NGC_EXPRESSIONS_ENABLE +\brief +Maximum number of parameters allowed in a block. +*/ +#if (NGC_EXPRESSIONS_ENABLE && !defined NGC_N_ASSIGN_PARAMETERS_PER_BLOCK) || defined __DOXYGEN__ +#define NGC_N_ASSIGN_PARAMETERS_PER_BLOCK 10 +#endif + +// Max number of entries in log for PID data reporting, to be used for tuning +//#define PID_LOG 1000 // Default disabled. Uncomment to enable. + +// End compile time only default configuration + +// --------------------------------------------------------------------------------------- +// SETTINGS DEFAULT VALUE OVERRIDES: + +// General settings (Group_General) + +/*! @name $10 - Setting_StatusReportMask +The status report change for grblHAL v1.1 and after also removed the ability to disable/enable most data +fields from the report. This caused issues for GUI developers, who've had to manage several scenarios +and configurations. The increased efficiency of the new reporting style allows for all data fields to +be sent without potential performance issues. +
__NOTE:__ The options below are here only provide a way to disable certain data fields if a unique +situation demands it, but be aware GUIs may depend on this data. If disabled, it may not be compatible. +*/ +///@{ +/*! \def DEFAULT_REPORT_MACHINE_POSITION +\brief +If set to \ref Off or 0 position is reported with all offsets added. +\internal Bit 0 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_MACHINE_POSITION || defined __DOXYGEN__ +#define DEFAULT_REPORT_MACHINE_POSITION On // Default on. Set to \ref Off or 0 to disable. +#endif + +/*! \def DEFAULT_REPORT_BUFFER_STATE +\brief +If set to \ref Off or 0 the `|Bf:` buffer state element is not included in the real time report. +\internal Bit 1 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_BUFFER_STATE || defined __DOXYGEN__ +#define DEFAULT_REPORT_BUFFER_STATE On // Default on. Set to \ref Off or 0 to disable. +#endif + +/*! \def DEFAULT_REPORT_LINE_NUMBERS +\brief +If set to \ref Off or 0 the `|Ln:` line number element is not included +in the real time report. +
__NOTE:__ Line numbers are only reported if present in the gcode. +\internal Bit 2 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_LINE_NUMBERS || defined __DOXYGEN__ +#define DEFAULT_REPORT_LINE_NUMBERS On // Default on. Set to \ref Off or 0 to disable. +#endif + +/*! \def DEFAULT_REPORT_CURRENT_FEED_SPEED +\brief +If set to \ref Off or 0 the `|FS:` current feed & speed element is not included +in the real time report. +\internal Bit 3 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_CURRENT_FEED_SPEED || defined __DOXYGEN__ +#define DEFAULT_REPORT_CURRENT_FEED_SPEED On // Default on. Set to \ref Off or 0 to disable. +#endif + +/*! \def DEFAULT_REPORT_PIN_STATE +\brief +If set to \ref Off or 0 the `|Pn:` input pins state element is not included +in the real time report. +\internal Bit 4 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_PIN_STATE || defined __DOXYGEN__ +#define DEFAULT_REPORT_PIN_STATE On // Default on. Set to \ref Off or 0 to disable. +#endif + +/*! \def DEFAULT_REPORT_WORK_COORD_OFFSET +\brief +If set to \ref Off or 0 the `|WCO:` work coordinate offset element is not included +in the real time report. +\internal Bit 5 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_WORK_COORD_OFFSET || defined __DOXYGEN__ +#define DEFAULT_REPORT_WORK_COORD_OFFSET On // Default on. Set to \ref Off or 0 to disable. +#endif + +/*! \def DEFAULT_REPORT_OVERRIDES +\brief +If set to \ref Off or 0 the `|Pn:` input pins state element is not included +in the real time report. +\internal Bit 6 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_OVERRIDES || defined __DOXYGEN__ +#define DEFAULT_REPORT_OVERRIDES On // Default on. Set to \ref Off or 0 to disable. +#endif + +/*! \def DEFAULT_REPORT_PROBE_COORDINATES +\brief +Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates +through an automatically generated message. If disabled, users can still access the last probe +coordinates through grblHAL `$#` print parameters command. +\internal Bit 7 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_PROBE_COORDINATES || defined __DOXYGEN__ +#define DEFAULT_REPORT_PROBE_COORDINATES On // Default on. Set to \ref Off or 0 to disable. +#endif + +/*! \def DEFAULT_REPORT_SYNC_ON_WCO_CHANGE +\brief +In Grbl v0.9 and prior, there is an old outstanding bug where the `WPos:` work position reported +may not correlate to what is executing, because `WPos:` is based on the g-code parser state, which +can be several motions behind. This option forces the planner buffer to empty, sync, and stop +motion whenever there is a command that alters the work coordinate offsets `G10,G43.1,G92,G54-59.3`. +This is the simplest way to ensure `WPos:` is always correct. Fortunately, it's exceedingly rare +that any of these commands are used need continuous motions through them. +\internal Bit 8 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_SYNC_ON_WCO_CHANGE || defined __DOXYGEN__ +#define DEFAULT_REPORT_SYNC_ON_WCO_CHANGE On //!< ok +#endif + +/*! \def DEFAULT_REPORT_PARSER_STATE +\brief +When enabled adds automatic report of the parser state following a status report request +if the state was changed since the last report. The output is the same as provided by +the `$G` command. +\internal Bit 9 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_PARSER_STATE || defined __DOXYGEN__ +#define DEFAULT_REPORT_PARSER_STATE Off // Default off. Set to \ref On or 1 to enable. +#endif + +/*! \def DEFAULT_REPORT_ALARM_SUBSTATE +\brief +Many controllers cannot be hard reset on startup due to using native USB or network +protocols for communication. If the grblHAL for some reason is in `ALARM` state there is +normally no way to determine the cause of the alarm. Enabling this setting adds the alarm +code (see \ref alarm_code_t) as a substate, separated by a colon, to the _Alarm_ state in +the real time report. +
__NOTE:__ Enabling this option may break senders. +\internal Bit 10 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_ALARM_SUBSTATE || defined __DOXYGEN__ +#define DEFAULT_REPORT_ALARM_SUBSTATE Off // Default off. Set to \ref On or 1 to enable. +#endif + +/*! \def DEFAULT_REPORT_RUN_SUBSTATE +\brief +Enabling this setting may add a code, separated by a colon, to the _Run_ state in the real time report. +The following codes are defined: ++ `1` - a feed hold is pending, waiting for spindle synchronized motion to complete. ++ `2` - the motion is a probe. +
__NOTE:__ Enabling this option may break senders. +\internal Bit 11 in settings.status_report. +*/ +#if !defined DEFAULT_REPORT_RUN_SUBSTATE || defined __DOXYGEN__ +#define DEFAULT_REPORT_RUN_SUBSTATE Off // Default off. Set to \ref On or 1 to enable. +#endif + +///@} + +/*! @name $11 - Setting_JunctionDeviation + * + */ +///@{ +#if !defined DEFAULT_JUNCTION_DEVIATION || defined __DOXYGEN__ +#define DEFAULT_JUNCTION_DEVIATION 0.01f // mm +#endif +///@} + +/*! @name $12 - Setting_ArcTolerance + * + */ +///@{ +#if !defined DEFAULT_ARC_TOLERANCE || defined __DOXYGEN__ +#define DEFAULT_ARC_TOLERANCE 0.002f // mm +#endif +///@} + +/*! @name $13 - Setting_ReportInches +If set to \ref On or 1 reported positions, offsets etc will be converted to inches +with 4 digits of precision. +*/ +///@{ +#if !defined DEFAULT_REPORT_INCHES || defined __DOXYGEN__ +#define DEFAULT_REPORT_INCHES Off +#endif +///@} + +/*! @name $28 - Setting_G73Retract +The retract motion distance used for chip breaking by the `G73` canned cycle, executed +after each delta increment specified by the `Q` word. +*/ +///@{ +#if !defined DEFAULT_G73_RETRACT || defined __DOXYGEN__ +#define DEFAULT_G73_RETRACT 0.1f // mm +#endif +///@} + +/*! @name $32 - Setting_Mode +__NOTE:__ only one mode can be enabled. + */ +///@{ +#if !defined DEFAULT_LASER_MODE || defined __DOXYGEN__ +#define DEFAULT_LASER_MODE Off +#endif +#if !defined DEFAULT_LATHE_MODE || defined __DOXYGEN__ +#define DEFAULT_LATHE_MODE Off +#endif +///@} + +/*! @name $39 - Setting_EnableLegacyRTCommands +Using printable ASCII characters for realtime commands can cause issues with files +containing such characters in comments or settings. If the GCode sender support the +use of the top-bit set alternatives for these then they may be disabled. +
__NOTE:__ support for the top-bit set alternatives is always enabled. +
__NOTE:__ when disabled they are still active outside of comments and $ settings +allowing their use from manual input, eg. from a terminal or MDI. +*/ +///@{ +#if !defined DEFAULT_LEGACY_RTCOMMANDS || defined __DOXYGEN__ +#define DEFAULT_LEGACY_RTCOMMANDS On +#endif +///@} + +/*! @name $60 - Setting_RestoreOverrides +*/ +///@{ +#if !defined DEFAULT_RESET_OVERRIDES || defined __DOXYGEN__ +#define DEFAULT_RESET_OVERRIDES Off +#endif +///@} + +/*! @name $62 - Setting_SleepEnable +*/ +///@{ +#if !defined DEFAULT_SLEEP_ENABLE || defined __DOXYGEN__ +#define DEFAULT_SLEEP_ENABLE Off +#endif +///@} + +/*! @name $63 - Setting_HoldActions +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 +be re-enabled by disabling the spindle stop override, if needed. This is purely a safety feature +to ensure the laser doesn't inadvertently remain powered while at a stop and cause a fire. +*/ +///@{ +#if !defined DEFAULT_ENABLE_LASER_DURING_HOLD || defined __DOXYGEN__ +#define DEFAULT_ENABLE_LASER_DURING_HOLD Off +#endif +///@} + +/*! @name This option is for what should happen on resume from feed hold. +Default action is to restore spindle and coolant status (if overridden), this contradicts the +behaviour of industrial controllers but is in line with earlier versions of Grbl. +*/ +///@{ +#if !defined DEFAULT_RESTORE_AFTER_FEED_HOLD || defined __DOXYGEN__ +#define DEFAULT_RESTORE_AFTER_FEED_HOLD On +#endif +///@} + +/*! @name $64 - Setting_ForceInitAlarm +When grblHAL powers-cycles or is hard reset with the MCU reset button, grblHAL boots up with no ALARM +by default. This is to make it as simple as possible for new users to start using grblHAL. When homing +is enabled and a user has installed limit switches, grblHAL will boot up in an ALARM state to indicate +grblHAL doesn't know its position and to force the user to home before proceeding. This option forces +grblHAL to always initialize into an ALARM state regardless of homing or not. This option is more for +OEMs and LinuxCNC users that would like this power-cycle behavior. +*/ +///@{ +#if !defined DEFAULT_FORCE_INITIALIZATION_ALARM || defined __DOXYGEN__ +#define DEFAULT_FORCE_INITIALIZATION_ALARM Off +#endif +///@} + +/*! @name $384 - Setting_DisableG92Persistence +G92 offsets is by default stored to non-volatile storage (NVS) on changes and restored on startup +if \ref COMPATIBILITY_LEVEL is <= 1. If \ref 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 \ref COMPATIBILITY_LEVEL > 1 uncomment the line below and reset settings with $RST=*. +*/ +///@{ +#if !defined DEFAULT_DISABLE_G92_PERSISTENCE || defined __DOXYGEN__ +#if COMPATIBILITY_LEVEL <= 1 +#define DEFAULT_DISABLE_G92_PERSISTENCE Off +#else +#define DEFAULT_DISABLE_G92_PERSISTENCE On +#endif +#endif +///@} + +/*! @name $398 - Setting_PlannerBlocks +\brief The number of linear motions in the planner buffer to be planned at any give time. +The vast majority of RAM that grblHAL uses is based on this buffer size. Only increase if +there is extra available RAM, like when compiling for MCU with ample amounts of RAM. +Or decrease if the MCU begins to crash due to the lack of available RAM or if the CPU is +having trouble keeping up with planning new incoming motions as they are executed. + */ +///@{ +#if !defined DEFAULT_PLANNER_BUFFER_BLOCKS || defined __DOXYGEN__ +#define DEFAULT_PLANNER_BUFFER_BLOCKS 35 +#endif +///@} + +// Control signals settings (Group_ControlSignals) + +#ifndef __DOXYGEN__ // For now do not include in documentation /*! @name Control signals bit definitions and mask. @@ -126,480 +788,465 @@ __NOTE:__ these definitions are only referenced in this file. Do __NOT__ change! #define SIGNALS_BITMASK (SIGNALS_RESET_BIT|SIGNALS_FEEDHOLD_BIT|SIGNALS_CYCLESTART_BIT|SIGNALS_SAFETYDOOR_BIT|SIGNALS_BLOCKDELETE_BIT|SIGNALS_STOPDISABLE_BIT|SIGNALS_ESTOP_BIT|SIGNALS_PROBE_CONNECTED_BIT|SIGNALS_MOTOR_FAULT_BIT) ///@} -// --------------------------------------------------------------------------------------- -// ADVANCED CONFIGURATION OPTIONS: - -// Enables code for debugging purposes. Not for general use and always in constant flux. -//#define DEBUG // Uncomment to enable. Default disabled. -//#define DEBUGOUT 0 // Uncomment to claim serial port with given instance number and add HAL entry point for debug output. - -// Some status report data isn't necessary for realtime, only intermittently, because the values don't -// change often. The following macros configures how many times a status report needs to be called before -// the associated data is refreshed and included in the status report. However, if one of these value -// changes, Grbl will automatically include this data in the next status report, regardless of what the -// count is at the time. This helps reduce the communication overhead involved with high frequency reporting -// and aggressive streaming. There is also a busy and an idle refresh count, which sets up Grbl to send -// refreshes more often when its not doing anything important. With a good GUI, this data doesn't need -// to be refreshed very often, on the order of a several seconds. -// NOTE: WCO refresh must be 2 or greater. OVERRIDE refresh must be 1 or greater. -//#define REPORT_OVERRIDE_REFRESH_BUSY_COUNT 20 // (1-255) -//#define REPORT_OVERRIDE_REFRESH_IDLE_COUNT 10 // (1-255) Must be less than or equal to the busy count -//#define REPORT_WCO_REFRESH_BUSY_COUNT 30 // (2-255) -//#define REPORT_WCO_REFRESH_IDLE_COUNT 10 // (2-255) Must be less than or equal to the busy count - -// The temporal resolution of the acceleration management subsystem. A higher number gives smoother -// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively -// impact performance. The correct value for this parameter is machine dependent, so it's advised to -// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more. -// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. -// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make -// certain the step segment buffer is increased/decreased to account for these changes. -//#define ACCELERATION_TICKS_PER_SECOND 100 - -// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error -// check in the settings module to prevent settings values that will exceed this limitation. The maximum -// step rate is strictly limited by the CPU speed and will change if something other than an AVR running -// at 16MHz is used. -// NOTE: For now disabled, will enable if flash space permits. -//#define MAX_STEP_RATE_HZ 30000 // Hz - -// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces -// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be -// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user -// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'. -// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect -// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased -// to help minimize transmission waiting within the serial write protocol. -//#define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable. - -// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with -// the selected axis with the tool oriented toward the negative direction. In other words, a positive -// tool length offset value is subtracted from the current location. -//#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS. - -// Minimum planner junction speed. Sets the default minimum junction speed the planner plans to at -// every buffer block junction, except for starting from rest and end of the buffer, which are always -// zero. This value controls how fast the machine moves through junctions with no regard for acceleration -// limits or angle between neighboring block line move directions. This is useful for machines that can't -// tolerate the tool dwelling for a split second, i.e. 3d printers or laser cutters. If used, this value -// should not be much greater than zero or to the minimum value necessary for the machine to work. -//#define MINIMUM_JUNCTION_SPEED 0.0f // (mm/min) - -// Sets the minimum feed rate the planner will allow. Any value below it will be set to this minimum -// value. This also ensures that a planned motion always completes and accounts for any floating-point -// round-off errors. Although not recommended, a lower value than 1.0 mm/min will likely work in smaller -// machines, perhaps to 0.1mm/min, but your success may vary based on multiple factors. -//#define MINIMUM_FEED_RATE 1.0f // (mm/min) - -// Number of arc generation iterations by small angle approximation before exact arc trajectory -// correction with expensive sin() and cos() calculations. This parameter maybe decreased if there -// are issues with the accuracy of the arc generations, or increased if arc execution is getting -// bogged down by too many trig calculations. -//#define N_ARC_CORRECTION 12 // Integer (1-255) - -// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical -// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate -// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating -// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely -// small arcs with around machine epsilon (1.2e-7rad) due to numerical round-off and precision issues. -// This define value sets the machine epsilon cutoff to determine if the arc is a full-circle or not. -// NOTE: Be very careful when adjusting this value. It should always be greater than 1.2e-7 but not too -// much greater than this. The default setting should capture most, if not all, full arc error situations. -//#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7f // Float (radians) - -// Default constants for G5 Cubic splines -// -//#define BEZIER_MIN_STEP 0.002f -//#define BEZIER_MAX_STEP 0.1f -//#define BEZIER_SIGMA 0.1f - -// Time delay increments performed during a dwell. The default value is set at 50ms, which provides -// a maximum time delay of roughly 55 minutes, more than enough for most any application. Increasing -// this delay will increase the maximum dwell time linearly, but also reduces the responsiveness of -// run-time command executions, like status reports, since these are performed between each dwell -// time step. -//#define DWELL_TIME_STEP 50 // Integer (1-255) (milliseconds) - -// The number of linear motions in the planner buffer to be planned at any give time. The vast -// majority of RAM that Grbl uses is based on this buffer size. Only increase if there is extra -// available RAM, like when re-compiling for MCU with ample amounts of RAM. Or decrease if the MCU begins to -// crash due to the lack of available RAM or if the CPU is having trouble keeping up with planning -// new incoming motions as they are executed. -//#define BLOCK_BUFFER_SIZE 36 // Uncomment to override default in planner.h. - -// Governs the size of the intermediary step segment buffer between the step execution algorithm -// and the planner blocks. Each segment is set of steps executed at a constant velocity over a -// fixed time defined by ACCELERATION_TICKS_PER_SECOND. They are computed such that the planner -// block velocity profile is traced exactly. The size of this buffer governs how much step -// execution lead time there is for other Grbl processes have to compute and do their thing -// before having to come back and refill this buffer, currently at ~50msec of step moves. -//#define SEGMENT_BUFFER_SIZE 10 // Uncomment to override default in stepper.h. - -// Configures the position after a probing cycle during Grbl's check mode. Disabled sets -// the position to the probe target, when enabled sets the position to the start position. -//#define SET_CHECK_MODE_PROBE_TO_START // Default disabled. Uncomment to enable. - -// Force Grbl to check the state of the hard limit switches when the processor detects a pin -// change inside the hard limit ISR routine. By default, Grbl will trigger the hard limits -// alarm upon any pin change, since bouncing switches can cause a state check like this to -// misread the pin. When hard limits are triggered, they should be 100% reliable, which is the -// reason that this option is disabled by default. Only if your system/electronics can guarantee -// that the switches don't bounce, we recommend enabling this option. This will help prevent -// triggering a hard limit when the machine disengages from the switch. -// NOTE: This option has no effect if SOFTWARE_DEBOUNCE is enabled. -//#define HARD_LIMIT_FORCE_STATE_CHECK // Default disabled. Uncomment to enable. - -// Adjusts homing cycle search and locate scalars. These are the multipliers used by Grbl's -// homing cycle to ensure the limit switches are engaged and cleared through each phase of -// the cycle. The search phase uses the axes max-travel setting times the SEARCH_SCALAR to -// determine distance to look for the limit switch. Once found, the locate phase begins and -// uses the homing pull-off distance setting times the LOCATE_SCALAR to pull-off and re-engage -// the limit switch. -// NOTE: Both of these values must be greater than 1.0 to ensure proper function. -//#define HOMING_AXIS_SEARCH_SCALAR 1.5f // Uncomment to override defaults in limits.c. -//#define HOMING_AXIS_LOCATE_SCALAR 10.0f // Uncomment to override defaults in limits.c. - -// Enable the '$RST=*', '$RST=$', and '$RST=#' non-volatile storage restore commands. There are cases where -// these commands may be undesirable. Simply comment the desired macro to disable it. -// NOTE: See SETTINGS_RESTORE_ALL macro for customizing the `$RST=*` command. -//#define DISABLE_RESTORE_NVS_WIPE_ALL // '$RST=*' Default enabled. Uncomment to disable. -//#define DISABLE_RESTORE_NVS_DEFAULT_SETTINGS // '$RST=$' Default enabled. Uncomment to disable. -//#define DISABLE_RESTORE_NVS_CLEAR_PARAMETERS // '$RST=#' Default enabled. Uncomment to disable. -//#define DISABLE_RESTORE_DRIVER_PARAMETERS // '$RST=&' Default enabled. Uncomment to disable. For drivers that implements non-generic settings. - -// Defines the non-volatile data restored upon a settings version change and `$RST=*` command. Whenever the -// the settings or other non-volatile data structure changes between Grbl versions, Grbl will automatically -// wipe and restore the non-volatile data. These macros controls what data is wiped and restored. This is useful -// particularly for OEMs that need to retain certain data. For example, the BUILD_INFO string can be -// written into non-volatile storage via a separate program to contain product data. Altering these -// macros to not restore the build info non-volatile storage will ensure this data is retained after firmware upgrades. -//#define SETTINGS_RESTORE_DEFAULTS 0 // Default enabled, uncomment to disable -//#define SETTINGS_RESTORE_PARAMETERS 0 // Default enabled, uncomment to disable -//#define SETTINGS_RESTORE_STARTUP_LINES 0 // Default enabled, uncomment to disable -//#define SETTINGS_RESTORE_BUILD_INFO 0 // Default enabled, uncomment to disable -//#define SETTINGS_RESTORE_DRIVER_PARAMETERS 0 // Default enabled, uncomment to disable - -// Enable the '$I=(string)' build info write command. If disabled, any existing build info data must -// be placed into non-volatile storage via external means with a valid checksum value. This macro option is useful -// to prevent this data from being over-written by a user, when used to store OEM product data. -// NOTE: If disabled and to ensure Grbl can never alter the build info line, you'll also need to enable -// the SETTING_RESTORE_ALL macro above and remove SETTINGS_RESTORE_BUILD_INFO from the mask. -// NOTE: See the included grblWrite_BuildInfo.ino example file to write this string separately. -//#define DISABLE_BUILD_INFO_WRITE_COMMAND // '$I=' Default enabled. Uncomment to disable. - -// Enables and configures Grbl's sleep mode feature. If the spindle or coolant are powered and Grbl -// is not actively moving or receiving any commands, a sleep timer will start. If any data or commands -// are received, the sleep timer will reset and restart until the above condition are not satisfied. -// If the sleep timer elaspes, Grbl will immediately execute the sleep mode by shutting down the spindle -// and coolant and entering a safe sleep state. If parking is enabled, Grbl will park the machine as -// well. While in sleep mode, only a hard/soft reset will exit it and the job will be unrecoverable. -// NOTE: Sleep mode is a safety feature, primarily to address communication disconnect problems. To -// keep Grbl from sleeping, employ a stream of '?' status report commands as a connection "heartbeat". -//#define SLEEP_ENABLE // Default disabled. Uncomment to enable. -//#define SLEEP_DURATION 5.0f // Number of minutes before sleep mode is entered. - -// Disable non-volatile storage emulation/buffering in RAM (allocated from heap) -// Can be used for MCUs with no non-volatile storage or as buffer in order to avoid writing to -// non-volatile storage when not in idle state. -// The buffer will be written to non-volatile storage when in idle state. -//#define BUFFER_NVSDATA_DISABLE - -//#define ENABLE_BACKLASH_COMPENSATION - -// End compile time only default configuration - -// When the HAL driver supports spindle sync then this option sets the number of pulses per revolution -// for the spindle encoder. Depending on the driver this may lead to the "spindle at speed" detection -// being enabled. When this is enabled grbl will wait for the spindle to reach the programmed speed -// before continue processing. NOTE: Currently there is no timeout for this wait. -// Default value is 0, meaning spindle sync is disabled -//#define DEFAULT_SPINDLE_PPR 0 // Pulses per revolution. Default 0. - -// 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 -// be re-enabled by disabling the spindle stop override, if needed. This is purely a safety feature -// to ensure the laser doesn't inadvertently remain powered while at a stop and cause a fire. -//#define DEFAULT_ENABLE_LASER_DURING_HOLD // Default enabled. Uncomment to disable. - -// This option is for what should happen on resume from feed hold. -// Default action is to restore spindle and coolant status (if overridden), this contradicts the -// behaviour of industrial controllers but is in line with earlier versions of Grbl. -//#define DEFAULT_NO_RESTORE_AFTER_FEED_HOLD // Default enabled. Uncomment to disable. - -// When Grbl powers-cycles or is hard reset with the MCU reset button, Grbl boots up with no ALARM -// by default. This is to make it as simple as possible for new users to start using Grbl. When homing -// is enabled and a user has installed limit switches, Grbl will boot up in an ALARM state to indicate -// Grbl doesn't know its position and to force the user to home before proceeding. This option forces -// Grbl to always initialize into an ALARM state regardless of homing or not. This option is more for -// OEMs and LinuxCNC users that would like this power-cycle behavior. -//#define DEFAULT_FORCE_INITIALIZATION_ALARM // Default disabled. Uncomment to enable. - -// At power-up or a reset, Grbl will check the limit switch states to ensure they are not active -// before initialization. If it detects a problem and the hard limits setting is enabled, Grbl will -// simply message the user to check the limits and enter an alarm state, rather than idle. Grbl will -// not throw an alarm message. -//#define DEFAULT_CHECK_LIMITS_AT_INIT // Default disabled. Uncomment to enable. - -// Configure options for the parking motion, if enabled. -//#define DEFAULT_PARKING_AXIS Z_AXIS // Define which axis that performs the parking motion -//#define DEFAULT_PARKING_TARGET -5.0f // Parking axis target. In mm, as machine coordinate [-max_travel,0]. -//#define DEFAULT_PARKING_RATE 500.0f // Parking fast rate after pull-out in mm/min. -//#define DEFAULT_PARKING_PULLOUT_RATE 100.0f // Pull-out/plunge slow feed rate in mm/min. -//#define DEFAULT_PARKING_PULLOUT_INCREMENT 5.0f // Spindle pull-out and plunge distance in mm. Incremental distance. - // Must be positive value or equal to zero. - - -// Enables a special set of M-code commands that enables and disables the parking motion. -// 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. By default, M56 is active upon initialization. Use -// DEACTIVATE_PARKING_UPON_INIT to set M56 P0 as the power-up default. -//#define DEFAULT_ENABLE_PARKING_OVERRIDE_CONTROL // Default disabled. Uncomment to enable -//#define DEFAULT_DEACTIVATE_PARKING_UPON_INIT // Default disabled. Uncomment to enable. - -// Using printable ASCII characters for realtime commands can cause issues with -// files containing such characters in comments or settings. If the GCode sender support the -// use of the top-bit set alternatives for these then they may be disabled. -// NOTE: support for the top-bit set alternatives is always enabled. -// NOTE: when disabled they are still active outside of comments and $ settings -// allowing their use from manual input, eg. from a terminal or MDI. -//#define DEFAULT_NO_LEGACY_RTCOMMANDS // Default disabled. Uncomment to enable. - -//#define DEFAULT_TOOLCHANGE_MODE 0 // 0 = Normal mode, 1 = Manual change, 2 = Manual change @ G59.3, 3 = Manual change and probe sensor @ G59.3 - sets TLO -//#define DEFAULT_TOOLCHANGE_PROBING_DISTANCE 30 // max probing distance in mm for mode 3 -//#define DEFAULT_TOOLCHANGE_FEED_RATE 25.0f // mm/min -//#define DEFAULT_TOOLCHANGE_SEEK_RATE 200.0f // mm/min -//#define DEFAULT_TOOLCHANGE_PULLOFF_RATE 200.0f // mm/min - -// The grbl.on_probe_fixture event handler is called by the default tool change algorithm when probing at G59.3. -// In addition it will be called on a "normal" probe sequence if the XY position is -// within the radius of the G59.3 position defined below. -// Uncomment and change if the default value of 5mm is not suitable or set it to 0.0f to disable. -// NOTE: A grbl.on_probe_fixture event handler is not installed by the core, it has to be provided -// by a driver or a plugin. -//#define TOOLSETTER_RADIUS 5.0f - -// By default, Grbl sets all input pins to normal-low operation with their internal pull-up resistors -// enabled. This simplifies the wiring for users by requiring only a normally closed (NC) switch connected -// to ground. It is not recommended to use normally-open (NO) switches as this increases the risk -// of electrical noise spuriously triggering the inputs. If normally-open (NO) switches are used the -// logic of the input signals should be be inverted with the invert settings below. -// The following options disable the internal pull-up resistors, and switches must be now connect to Vcc -// instead of ground. -// WARNING: When the pull-ups are disabled, this might require additional wiring with pull-down resistors! -// Please check driver code and/or documentation. -//#define DISABLE_LIMIT_BITS_PULL_UP_MASK AXES_BITMASK -//#define DISABLE_LIMIT_BITS_PULL_UP_MASK (X_AXIS_BIT|Y_AXIS_BIT) -//#define DISABLE_CONTROL_PINS_PULL_UP_MASK SIGNALS_BITMASK -//#define DISABLE_CONTROL_PINS_PULL_UP_MASK (SIGNALS_SAFETYDOOR_BIT|SIGNALS_RESET_BIT) -//#define DISABLE_PROBE_BIT_PULL_UP - -// If your machine has two limits switches wired in parallel to one axis, you will need to enable -// this feature. Since the two switches are sharing a single pin, there is no way for Grbl to tell -// which one is enabled. This option only effects homing, where if a limit is engaged, Grbl will -// alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one -// limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a -// homing cycle while on the limit switch and not have to move the machine off of it. -//#define DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES // Default disabled. Uncomment to enable. - -// By default, Grbl disables feed rate overrides for all G38.x probe cycle commands. Although this -// may be different than some pro-class machine control, it's arguable that it should be this way. -// Most probe sensors produce different levels of error that is dependent on rate of speed. By -// keeping probing cycles to their programmed feed rates, the probe sensor should be a lot more -// repeatable. If needed, you can disable this behavior by uncommenting the define below. -//#define ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES // Default disabled. Uncomment to enable. - -// Inverts logic of the stepper enable signal(s). -#if COMPATIBILITY_LEVEL <= 2 -// NOTE: Not universally available for individual axes - check driver documentation. -// Specify at least X_AXIS_BIT if a common enable signal is used. -//#define INVERT_ST_ENABLE_MASK (X_AXIS_BIT|Y_AXIS_BIT|Z_AXIS_BIT) // Default disabled. Uncomment to enable. -#else -//#define INVERT_ST_ENABLE_MASK 1 // Default disabled. Uncomment to enable. -#endif -// Mask to be OR'ed with stepper disable signal(s). Axes configured will not be disabled. -// NOTE: Not universally available for individual axes - check driver documentation. -// Specify at least X_AXIS_BIT if a common enable signal is used. -//#define ST_DEENERGIZE_MASK (X_AXIS_BIT|Y_AXIS_BIT|Z_AXIS_BIT) // Default disabled. Uncomment to enable. -//#define DEFAULT_STEPPING_INVERT_MASK 0 -//#define DEFAULT_DIRECTION_INVERT_MASK 0 - -// Designate ABC axes as rotational. This will disable scaling (to mm) in inches mode. -// Set steps/mm for the axes to the value that represent the desired movement per unit. -// For the controller the distance is unitless and and can be in degrees, radians, rotations, ... -// NOTE: $376 can be used to configure rotational axes at run-time. -//#define ST_ROTATIONAL_MASK (A_AXIS_BIT|B_AXIS_BIT|C_AXIS_BIT) // Default disabled. Uncomment and possibly remove axis bit(s) as needed to enable. - -// Inverts logic of the input signals based on a mask. This essentially means you are using -// normally-open (NO) switches on the specified pins, rather than the default normally-closed (NC) switches. -// NOTE: The first option will invert all control pins. The second option is an example of -// inverting only a few pins. See the start of this file for other signal definitions. -//#define INVERT_CONTROL_PIN_MASK SIGNALS_BITMASK // Default disabled. Uncomment to enable. -//#define INVERT_CONTROL_PIN_MASK (SIGNALS_SAFETYDOOR_BIT|SIGNALS_RESET_BIT) // Default disabled. Uncomment to enable. -//#define INVERT_LIMIT_BIT_MASK AXES_BITMASK // Default disabled. Uncomment to enable. Uncomment to enable. -//#define INVERT_LIMIT_BIT_MASK (X_AXIS_BIT|Y_AXIS_BIT) // Default disabled. Uncomment to enable. -// For inverting the probe pin use DEFAULT_INVERT_PROBE_BIT in defaults.h - -// Inverts the selected spindle output signals from active high to active low. Useful for some pre-built electronic boards. -//#define INVERT_SPINDLE_ENABLE_PIN 1 // Default disabled. Uncomment to enable. -//#define INVERT_SPINDLE_CCW_PIN 1 // Default disabled. Uncomment to enable. NOTE: not supported by all drivers. -//#define INVERT_SPINDLE_PWM_PIN 1 // Default disabled. Uncomment to enable. NOTE: not supported by all drivers. - -// Inverts the selected coolant signals from active high to active low. Useful for some pre-built electronic boards. -//#define INVERT_COOLANT_FLOOD_PIN 1 // Default disabled. Uncomment to enable. -//#define INVERT_COOLANT_MIST_PIN 1 // Default disabled. Note: not supported by all drivers. - - -// Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled. -// The PWM pin will still read 0V when the spindle is disabled. Most users will not need this option, but -// it may be useful in certain scenarios. This minimum PWM settings coincides with the spindle rpm minimum -// setting, like rpm max to max PWM. This is handy if you need a larger voltage difference between 0V disabled -// and the voltage set by the minimum PWM for minimum rpm. This difference is 0.02V per PWM value. So, when -// minimum PWM is at 1, only 0.02 volts separate enabled and disabled. At PWM 5, this would be 0.1V. Keep -// in mind that you will begin to lose PWM resolution with increased minimum PWM values, since you have less -// and less range over the total 255 PWM levels to signal different spindle speeds. -// NOTE: Compute duty cycle at the minimum PWM by this equation: (% duty cycle)=(SPINDLE_PWM_MIN_VALUE/255)*100 -//#define DEFAULT_SPINDLE_PWM_MIN_VALUE 5.0f // Default disabled. Uncomment to enable. Must be greater than zero. Integer (1-255). - -// Number of homing cycles performed after when the machine initially jogs to limit switches. -// This help in preventing overshoot and should improve repeatability. This value should be one or -// greater. -//#define DEFAULT_N_HOMING_LOCATE_CYCLE 1 // Integer (1-127) - - -// In Grbl v0.9 and prior, there is an old outstanding bug where the `WPos:` work position reported -// may not correlate to what is executing, because `WPos:` is based on the g-code parser state, which -// can be several motions behind. This option forces the planner buffer to empty, sync, and stop -// motion whenever there is a command that alters the work coordinate offsets `G10,G43.1,G92,G54-59`. -// This is the simplest way to ensure `WPos:` is always correct. Fortunately, it's exceedingly rare -// that any of these commands are used need continuous motions through them. -//#define DEFAULT_NO_FORCE_BUFFER_SYNC_DURING_WCO_CHANGE // Default enabled. Uncomment to disable. - -// Upon a successful probe cycle, this option provides immediately feedback of the probe coordinates -// through an automatically generated message. If disabled, users can still access the last probe -// coordinates through Grbl '$#' print parameters. -//#define DEFAULT_NO_REPORT_PROBE_COORDINATES 1 // Default enabled. Uncomment to disable. - -// The status report change for Grbl v1.1 and after also removed the ability to disable/enable most data -// fields from the report. This caused issues for GUI developers, who've had to manage several scenarios -// and configurations. The increased efficiency of the new reporting style allows for all data fields to -// be sent without potential performance issues. -// NOTE: The options below are here only provide a way to disable certain data fields if a unique -// situation demands it, but be aware GUIs may depend on this data. If disabled, it may not be compatible. -//#define DEFAULT_REPORT_MACHINE_POSITION // Default disabled. Uncomment to enable. -//#define DEFAULT_NO_REPORT_BUFFER_STATE -//#define DEFAULT_NO_REPORT_LINE_NUMBERS -//#define DEFAULT_NO_REPORT_CURRENT_FEED_SPEED -//#define DEFAULT_NO_REPORT_PIN_STATE -//#define DEFAULT_NO_REPORT_WORK_COORD_OFFSET -//#define DEFAULT_NO_REPORT_OVERRIDES -//#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 tool table, uncomment and edit if necessary 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 +/*! @name $14 - Setting_ControlInvertMask +Inverts logic of the control input signals based on a \ref signalmask. This essentially means you are using +normally-open (NO) switches on the specified pins, rather than the default normally-closed (NC) switches. +
__NOTE:__ See above for other signal definitions. +*/ +///@{ +#if !defined DEFAULT_CONTROL_SIGNALS_INVERT_MASK || defined __DOXYGEN__ +#define DEFAULT_CONTROL_SIGNALS_INVERT_MASK 0 // Set to SIGNALS_BITMASK or -1 to invert all signals +#endif +///@} + +/*! @name $17 - Setting_ControlPullUpDisableMask +By default, grblHAL sets all input pins to normal-low operation with their internal pull-up resistors +enabled. This simplifies the wiring for users by requiring only a normally closed (NC) switch connected +to ground. It is not recommended to use normally-open (NO) switches as this increases the risk +of electrical noise spuriously triggering the inputs. If normally-open (NO) switches are used the +logic of the input signals should be be inverted with the invert settings below. +The following options disable the internal pull-up resistors, and switches must be now connect to Vcc +instead of ground. +
__WARNING:__ When the pull-ups are disabled, this might require additional wiring with pull-down resistors! +Please check driver code and/or documentation. +
__NOTE:__ The first example will disable pull-up for all control pins. The second is an example of +disabling pull-up for only a few pins. See above for other signal definitions. +*/ +///@{ +#if !defined DEFAULT_DISABLE_CONTROL_PINS_PULL_UP_MASK || defined __DOXYGEN__ +#define DEFAULT_DISABLE_CONTROL_PINS_PULL_UP_MASK 0 // Set to SIGNALS_BITMASK or -1 to invert all signals +#endif +///@} + +// Limits settings (Group_Limits) + +/*! @name $5 - Setting_LimitPinsInvertMask +By default, grblHAL sets all input pins to normal-low operation with their internal pull-up resistors +enabled. This simplifies the wiring for users by requiring only a normally closed (NC) switch connected +to ground. It is _not_ recommended to use normally-open (NO) switches as this increases the risk +of electrical noise or cable breaks spuriously triggering the inputs. If normally-open (NO) switches +are used the logic of the input signals should be be inverted with the \ref axismask below. +*/ +///@{ +#if !defined DEFAULT_LIMIT_SIGNALS_INVERT_MASK || defined __DOXYGEN__ +#define DEFAULT_LIMIT_SIGNALS_INVERT_MASK 0 // Set to -1 or AXES_BITMASK to invert for all axes +#endif +///@} + +/*! @name $18 - Setting_LimitPullUpDisableMask +The following options disable the internal pull-up resistors by \ref axismask, and switches must +be now connect to Vcc instead of ground. +
__WARNING:__ When the pull-ups are disabled, this might require additional wiring with + pull-down resistors! Please check driver code and/or documentation. +*/ +///@{ +#if !defined DEFAULT_LIMIT_SIGNALS_PULLUP_DISABLE_MASK || defined __DOXYGEN__ +#define DEFAULT_LIMIT_SIGNALS_PULLUP_DISABLE_MASK 0 // Set to -1 or AXES_BITMASK to disable pullup for all axes +#endif +///@} + +/*! @name $20 - Setting_SoftLimitsEnable +*/ +///@{ +#if !defined DEFAULT_SOFT_LIMIT_ENABLE || defined __DOXYGEN__ +#define DEFAULT_SOFT_LIMIT_ENABLE Off +#endif +///@} + +/*! @name $21 - Setting_HardLimitsEnable +*/ +///@{ +/*! \def DEFAULT_HARD_LIMIT_ENABLE +\brief +At power-up or a reset, grblHAL will check the limit switch states to ensure they are not active +before initialization. If it detects a problem and the hard limits setting is enabled, grblHAL will +simply message the user to check the limits and enter an alarm state, rather than idle. grblHAL will +not throw an alarm message. +*/ +#if !defined DEFAULT_HARD_LIMIT_ENABLE || defined __DOXYGEN__ +#define DEFAULT_HARD_LIMIT_ENABLE Off +#endif +#if !defined DEFAULT_CHECK_LIMITS_AT_INIT || defined __DOXYGEN__ +#define DEFAULT_CHECK_LIMITS_AT_INIT Off +#endif +/*! \def DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES +\brief +If your machine has two limits switches wired in parallel to one axis, you will need to enable +this feature. Since the two switches are sharing a single pin, there is no way for grblHAL to tell +which one is enabled. This option only effects homing, where if a limit is engaged, grblHAL will +alarm out and force the user to manually disengage the limit switch. Otherwise, if you have one +limit switch for each axis, don't enable this option. By keeping it disabled, you can perform a +homing cycle while on the limit switch and not have to move the machine off of it. +*/ +#if !defined DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES || defined __DOXYGEN__ +#define DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES Off // Default disabled. Set to \ref On or 1 to enable. +#endif +///@} + +/*! @name Group_Limits_DualAxis +\brief Dual axis limits settings (Group_Limits_DualAxis) + +To prevent the homing cycle from racking the dual axis, when one limit triggers before the +other due to switch failure or noise, the homing cycle will automatically abort if the second +motor's limit switch does not trigger within the three distance parameters defined below. +Axis length percent will automatically compute a fail distance as a percentage of the max +travel of the other non-dual axis, i.e. if dual axis select is X_AXIS at 5.0%, then the fail +distance will be computed as 5.0% of y-axis max travel. Fail distance max and min are the +limits of how far or little a valid fail distance is. +*/ +///@{ +/*! @name $347 - Setting_DualAxisLengthFailPercent +*/ +///@{ +#if !defined DEFAULT_DUAL_AXIS_HOMING_FAIL_AXIS_LENGTH_PERCENT || defined __DOXYGEN__ +#define DEFAULT_DUAL_AXIS_HOMING_FAIL_AXIS_LENGTH_PERCENT 5.0f // Float (percent) +#endif +///@} + +/*! @name $348 - Setting_DualAxisLengthFailMin +*/ +///@{ +#if !defined DEFAULT_DUAL_AXIS_HOMING_FAIL_DISTANCE_MIN || defined __DOXYGEN__ +#define DEFAULT_DUAL_AXIS_HOMING_FAIL_DISTANCE_MIN 2.5f // Float (mm) +#endif +///@} + +/*! @name $348 - Setting_DualAxisLengthFailMin + + */ +///@{ +#if !defined DEFAULT_DUAL_AXIS_HOMING_FAIL_DISTANCE_MAX || defined __DOXYGEN__ +#define DEFAULT_DUAL_AXIS_HOMING_FAIL_DISTANCE_MAX 25.0f // Float (mm) +#endif +///@} + +// Coolant settings (Group_Coolant) + +/*! @name $15 - Setting_CoolantInvertMask +Inverts the selected coolant signals from active high to active low. +Useful for some pre-built electronic boards. +*/ +///@{ +#if !defined DEFAULT_INVERT_COOLANT_FLOOD_PIN || defined __DOXYGEN__ +#define DEFAULT_INVERT_COOLANT_FLOOD_PIN Off +#endif +#if !defined DEFAULT_INVERT_COOLANT_MIST_PIN || defined __DOXYGEN__ +#define DEFAULT_INVERT_COOLANT_MIST_PIN Off // NOTE: not supported by all drivers. +#endif +///@} + +// Spindle settings (Group_Spindle) + +/*! @name $9 - Setting_SpindlePWMOptions +*/ +///@{ +#if !defined DEFAULT_SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED || defined __DOXYGEN__ +#define DEFAULT_SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED Off +#endif +///@} + +/*! @name $16 - Setting_SpindleInvertMask +Inverts the selected spindle output signals from active high to active low. Useful for some pre-built electronic boards. +*/ +///@{ +#if !defined DEFAULT_INVERT_SPINDLE_ENABLE_PIN || defined __DOXYGEN__ +#define DEFAULT_INVERT_SPINDLE_ENABLE_PIN Off +#endif +#if !defined DEFAULT_INVERT_SPINDLE_CCW_PIN || defined __DOXYGEN__ +#define DEFAULT_INVERT_SPINDLE_CCW_PIN Off // NOTE: not supported by all drivers. +#endif +#if !defined DEFAULT_INVERT_SPINDLE_PWM_PIN || defined __DOXYGEN__ +#define DEFAULT_INVERT_SPINDLE_PWM_PIN Off // NOTE: not supported by all drivers. +#endif +///@} + +/*! @name $30 - Setting_RpmMax +*/ +///@{ +#if !defined DEFAULT_SPINDLE_RPM_MAX || defined __DOXYGEN__ +#define DEFAULT_SPINDLE_RPM_MAX 1000.0f // rpm +#endif +///@} + +/*! @name $31 - Setting_RpmMin +*/ +///@{ +#if !defined DEFAULT_SPINDLE_RPM_MIN || defined __DOXYGEN__ +#define DEFAULT_SPINDLE_RPM_MIN 0.0f // rpm +#endif +///@} + +/*! @name $33 - Setting_PWMFreq +*/ +///@{ +#if !defined DEFAULT_SPINDLE_PWM_FREQ || defined __DOXYGEN__ +#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz +#endif +///@} + +/*! @name $34 - Setting_PWMOffValue +*/ +///@{ +#if !defined DEFAULT_SPINDLE_PWM_OFF_VALUE || defined __DOXYGEN__ +#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0.0f // Percent +#endif +///@} + +/*! @name $35 - Setting_PWMMinValue +Used by variable spindle output only. This forces the PWM output to a minimum duty cycle when enabled. +The PWM pin will still read 0V when the spindle is disabled. Most users will not need this option, but +it may be useful in certain scenarios. This minimum PWM settings coincides with the spindle rpm minimum +setting, like rpm max to max PWM. This is handy if you need a larger voltage difference between 0V disabled +and the voltage set by the minimum PWM for minimum rpm. This difference is 0.02V per PWM value. So, when +minimum PWM is at 1, only 0.02 volts separate enabled and disabled. At PWM 5, this would be 0.1V. Keep +in mind that you will begin to lose PWM resolution with increased minimum PWM values, since you have less +and less range over the total 255 PWM levels to signal different spindle speeds. +
__!! NOTE:__ Compute duty cycle at the minimum PWM by this equation: (% duty cycle)=(SPINDLE_PWM_MIN_VALUE/255)*100 +*/ +///@{ +#if !defined DEFAULT_SPINDLE_PWM_MIN_VALUE || defined __DOXYGEN__ +#define DEFAULT_SPINDLE_PWM_MIN_VALUE 0.0f // Must be greater than zero. Integer (+-255). +#endif +///@} + +/*! @name $36 - Setting_PWMMaxValue +*/ +///@{ +#if !defined DEFAULT_SPINDLE_PWM_MAX_VALUE || defined __DOXYGEN__ +#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100.0f // Percent +#endif +///@} + +/*! @name $38 - Setting_SpindlePPR +When the HAL driver supports spindle sync then this option sets the number of pulses per revolution +for the spindle encoder. Depending on the driver this may lead to the "spindle at speed" detection +being enabled. When this is enabled grblHAL will wait for the spindle to reach the programmed speed +before continue processing. NOTE: Currently there is no timeout for this wait. +Default value is 0, meaning spindle sync is disabled +*/ +///@{ +#if !defined DEFAULT_SPINDLE_PPR || defined __DOXYGEN__ +#define DEFAULT_SPINDLE_PPR 0 // Pulses per revolution. +#endif +///@} + +/*! @name $340 - Setting_SpindleAtSpeedTolerance +*/ +///@{ +#if !defined DEFAULT_SPINDLE_AT_SPEED_TOLERANCE || defined __DOXYGEN__ +#define DEFAULT_SPINDLE_AT_SPEED_TOLERANCE 0.0f // Percent - 0 means not checked +#endif +///@} + +// Closed loop spindle settings (Group_Spindle_ClosedLoop) + +// $9 - Setting_SpindlePWMOptions +// bit 0 +// always defaults to on +// bit 1 + +// Closed loop spindle settings (Group_Spindle_ClosedLoop) + +#ifndef DEFAULT_SPINDLE_P_GAIN +#define DEFAULT_SPINDLE_P_GAIN 1.0f +#endif +#ifndef DEFAULT_SPINDLE_I_GAIN +#define DEFAULT_SPINDLE_I_GAIN 0.01f +#endif +#ifndef DEFAULT_SPINDLE_D_GAIN +#define DEFAULT_SPINDLE_D_GAIN 0.0f +#endif +#ifndef DEFAULT_SPINDLE_I_MAX +#define DEFAULT_SPINDLE_I_MAX 10.0f #endif -#if defined(N_TOOLS) && N_TOOLS > 16 -#undef N_TOOLS -#define N_TOOLS 16 +// Tool change settings (Group_Toolchange) + +/*! @name $341 - Setting_ToolChangeMode +0 = Normal mode, 1 = Manual change, 2 = Manual change @ G59.3, 3 = Manual change and probe sensor @ G59.3 - sets TLO +*/ +///@{ +#if !defined DEFAULT_TOOLCHANGE_MODE || defined __DOXYGEN__ +#define DEFAULT_TOOLCHANGE_MODE 0 +#endif +///@} + +/*! @name $342 - Setting_ToolChangeProbingDistance +*/ +///@{ +#if !defined DEFAULT_TOOLCHANGE_PROBING_DISTANCE || defined __DOXYGEN__ +#define DEFAULT_TOOLCHANGE_PROBING_DISTANCE 30 // max probing distance in mm for mode 3 +#endif +///@} + +/*! @name $343 - Setting_ToolChangeFeedRate +*/ +///@{ +#if !defined DEFAULT_TOOLCHANGE_FEED_RATE || defined __DOXYGEN__ +#define DEFAULT_TOOLCHANGE_FEED_RATE 25.0f // mm/min +#endif +///@} + +/*! @name $344 - Setting_ToolChangeSeekRate + + */ +///@{ +#if !defined DEFAULT_TOOLCHANGE_SEEK_RATE || defined __DOXYGEN__ +#define DEFAULT_TOOLCHANGE_SEEK_RATE 200.0f // mm/min +#endif +///@} + +/*! @name $345 - Setting_ToolChangePulloffRate +*/ +///@{ +#if !defined DEFAULT_TOOLCHANGE_PULLOFF_RATE || defined __DOXYGEN__ +#define DEFAULT_TOOLCHANGE_PULLOFF_RATE 200.0f // mm/min +#endif +///@} + +/*! @name $346 - Setting_ToolChangeRestorePosition +*/ +///@{ +#if !defined DEFAULT_TOOLCHANGE_NO_RESTORE_POSITION || defined __DOXYGEN__ +#define DEFAULT_TOOLCHANGE_NO_RESTORE_POSITION Off +#endif +///@} + +// Homing settings (Group_Homing) + +/*! @name $22 - Setting_HomingEnable +\brief Enable homing. +Requires homing cycles to be defined by \ref DEFAULT_HOMING_CYCLE_0 - \ref DEFAULT_HOMING_CYCLE_2 +. +\internal Bit 0 in settings.homing.flags. +*/ +///@{ +#if !defined DEFAULT_HOMING_ENABLE || defined __DOXYGEN__ +#define DEFAULT_HOMING_ENABLE Off // Default disabled. Set to \ref On or 1 to enable. #endif -// Max number of entries in log for PID data reporting, to be used for tuning -//#define PID_LOG 1000 // Default disabled. Uncomment to enable. +/*! /def HOMING_SINGLE_AXIS_COMMANDS +\brief Enables single axis homing commands. +`$HX`, `$HY`, `$HZ` etc. for homing the respective axes.The full homing +cycle is still invoked by the `$H` command. This is disabled by default. +If you have a two-axis machine, _DON'T USE THIS_. Instead, just alter the homing cycle for two-axes. +\internal Bit 1 in settings.homing.flags. +*/ +#if !defined HOMING_SINGLE_AXIS_COMMANDS || defined __DOXYGEN__ +#define HOMING_SINGLE_AXIS_COMMANDS Off // Default disabled. Set to \ref On or 1 to enable. +#endif -//#define DEFAULT_X_STEPS_PER_MM 250.0f -//#define DEFAULT_Y_STEPS_PER_MM 250.0f -//#define DEFAULT_Z_STEPS_PER_MM 250.0f -//#define DEFAULT_X_MAX_RATE 500.0f // mm/min -//#define DEFAULT_Y_MAX_RATE 500.0f // mm/min -//#define DEFAULT_Z_MAX_RATE 500.0f // mm/min -//#define DEFAULT_X_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 -//#define DEFAULT_Y_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 -//#define DEFAULT_Z_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 -//#define DEFAULT_X_MAX_TRAVEL 200.0f // mm NOTE: Must be a positive value. -//#define DEFAULT_Y_MAX_TRAVEL 200.0f // mm NOTE: Must be a positive value. -//#define DEFAULT_Z_MAX_TRAVEL 200.0f // mm NOTE: Must be a positive value. -//#define DEFAULT_X_CURRENT 0.0 // amps -//#define DEFAULT_Y_CURRENT 0.0 // amps -//#define DEFAULT_Z_CURRENT 0.0 // amps -//#define DEFAULT_A_CURRENT 0.0 // amps -//#define DEFAULT_SPINDLE_PWM_FREQ 5000 // Hz -//#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0.0f // Percent -//#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100.0f // Percent -//#define DEFAULT_SPINDLE_AT_SPEED_TOLERANCE 0.0f // Percent - 0 means not checked -//#define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm -//#define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm -//#define DEFAULT_SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED 0 -//#define DEFAULT_STEP_PULSE_MICROSECONDS 10.0f -//#define DEFAULT_STEP_PULSE_DELAY 5.0f // uncomment to set default > 0.0f -//#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-65535, 255 keeps steppers enabled) -//#define DEFAULT_JUNCTION_DEVIATION 0.01f // mm -//#define DEFAULT_ARC_TOLERANCE 0.002f // mm -//#define DEFAULT_REPORT_INCHES -//#define DEFAULT_INVERT_LIMIT_BITS -//#define DEFAULT_SOFT_LIMIT_ENABLE -//#define DEFAULT_JOG_LIMIT_ENABLE -//#define DEFAULT_HARD_LIMIT_ENABLE -//#define DEFAULT_INVERT_PROBE_BIT -//#define DEFAULT_LASER_MODE -//#define DEFAULT_LATHE_MODE -//#define DEFAULT_HOMING_ENABLE -//#define DEFAULT_HOMING_ALLOW_MANUAL -//#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir -//#define DEFAULT_HOMING_FEED_RATE 25.0f // mm/min -//#define DEFAULT_HOMING_SEEK_RATE 500.0f // mm/min -//#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k) -//#define DEFAULT_HOMING_PULLOFF 1.0f // mm +/*! /def DEFAULT_HOMING_INIT_LOCK +\brief +If homing is enabled, homing init lock sets grblHAL into an alarm state upon power up or a soft reset. +This forces the user to perform the homing cycle before doing anything else. This is +mainly a safety feature to remind the user to home, since position is unknown to grblHAL. +\internal Bit 2 in settings.homing.flags. +*/ +#if !defined DEFAULT_HOMING_INIT_LOCK || defined __DOXYGEN__ +#define DEFAULT_HOMING_INIT_LOCK Off // Default disabled. Set to \ref On or 1 to enable. +#endif -//#define DEFAULT_A_STEPS_PER_MM 250.0f -//#define DEFAULT_A_MAX_RATE 500.0f // mm/min -//#define DEFAULT_A_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 -//#define DEFAULT_A_MAX_TRAVEL 200.0f // mm +/*! /def HOMING_FORCE_SET_ORIGIN +\brief +After homing, grblHAL will set by default the entire machine space into negative space, as is typical +for professional CNC machines, regardless of where the limit switches are located. Set this +define to \ref On or 1 to force grblHAL to always set the machine origin at the homed location despite switch orientation. +\internal Bit 3 in settings.homing.flags. +*/ +#if !defined HOMING_FORCE_SET_ORIGIN || defined __DOXYGEN__ +#define HOMING_FORCE_SET_ORIGIN Off // Default disabled. Set to \ref On or 1 to enable. +#endif -//#define DEFAULT_B_STEPS_PER_MM 250.0f -//#define DEFAULT_B_MAX_RATE 500.0f // mm/min -//#define DEFAULT_B_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 -//#define DEFAULT_B_MAX_TRAVEL 200.0f // mm +/*! /def DEFAULT_HOMING_ALLOW_MANUAL +\brief +If enabled this allows using the homing $-commands to set the home position to the +current axis position. +\internal Bit 4 in settings.homing.flags. +*/ +#if !defined DEFAULT_HOMING_ALLOW_MANUAL || defined __DOXYGEN__ +#define DEFAULT_HOMING_ALLOW_MANUAL Off // Default disabled. Set to \ref On or 1 to enable. +#endif -//#define DEFAULT_C_STEPS_PER_MM 250.0f -//#define DEFAULT_C_MAX_RATE 500.0f // mm/min -//#define DEFAULT_C_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 -//#define DEFAULT_C_MAX_TRAVEL 200.0f // mm +/*! /def DEFAULT_HOMING_OVERRIDE_LOCKS +\brief +If homing init lock is enabled this sets grblHAL into an alarm state upon power up or a soft reset. +To allow a soft reset to override the lock uncomment the line below. +\internal Bit 5 in settings.homing.flags. +*/ +#if !defined DEFAULT_HOMING_OVERRIDE_LOCKS || defined __DOXYGEN__ +#define DEFAULT_HOMING_OVERRIDE_LOCKS Off // Default disabled. Set to \ref On or 1 to enable. +#endif -//#define DEFAULT_G73_RETRACT 0.1f // mm +/*! /def DEFAULT_HOMING_KEEP_STATUS_ON_RESET +\brief +Enable this setting to keep homed status over a soft reset - if position was not lost due +to a reset during motion. +\internal Bit 6 in settings.homing.flags. +*/ +#if !defined DEFAULT_HOMING_KEEP_STATUS_ON_RESET || defined __DOXYGEN__ +#define DEFAULT_HOMING_KEEP_STATUS_ON_RESET Off // Default disabled. Set to \ref On or 1 to enable. +#endif +///@} -#ifdef DEFAULT_HOMING_ENABLE +/*! @name $23 - Setting_HomingDirMask +\ref axismask controlling the direction of movement during homing. +Unset bits in the mask results in movement in positive direction. +*/ +///@{ +#if !defined DEFAULT_HOMING_DIR_MASK || defined __DOXYGEN__ +#define DEFAULT_HOMING_DIR_MASK 0 +#endif +///@} -// Number of homing cycles performed after when the machine initially jogs to limit switches. -// This help in preventing overshoot and should improve repeatability. This value should be one or -// greater. -//#define DEFAULT_N_HOMING_LOCATE_CYCLE 1 // Integer (1-127) +/*! @name $24 - Setting_HomingFeedRate +*/ +///@{ +#if !defined DEFAULT_HOMING_FEED_RATE || defined __DOXYGEN__ +#define DEFAULT_HOMING_FEED_RATE 25.0f // mm/min +#endif +///@} -// If homing is enabled, homing init lock sets Grbl into an alarm state upon power up or a soft reset. -// This forces the user to perform the homing cycle before doing anything else. This is -// mainly a safety feature to remind the user to home, since position is unknown to Grbl. -//#define DEFAULT_HOMING_INIT_LOCK // Default disabled. Uncomment to enable. +/*! @name $25 - Setting_HomingSeekRate +*/ +///@{ +#if !defined DEFAULT_HOMING_SEEK_RATE || defined __DOXYGEN__ +#define DEFAULT_HOMING_SEEK_RATE 500.0f // mm/min +#endif +///@} -// If homing init lock is enabled this sets Grbl into an alarm state upon power up or a soft reset. -// To allow a soft reset to override the lock uncomment the line below. -//#define DEFAULT_HOMING_OVERRIDE_LOCKS // Default disabled. Uncomment to enable. +/*! @name $26 - Setting_HomingDebounceDelay +*/ +///@{ +#if !defined DEFAULT_HOMING_DEBOUNCE_DELAY || defined __DOXYGEN__ +#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k) +#endif +///@} +/*! @name $27 - Setting_HomingPulloff +*/ +///@{ +#if !defined DEFAULT_HOMING_PULLOFF || defined __DOXYGEN__ +#define DEFAULT_HOMING_PULLOFF 1.0f // mm +#endif +///@} + +/*! @name $43 - Setting_HomingLocateCycles +Number of homing cycles performed after when the machine initially jogs to limit switches. +This help in preventing overshoot and should improve repeatability. This value should be one or +greater. +*/ +///@{ +#if !defined DEFAULT_N_HOMING_LOCATE_CYCLE || defined __DOXYGEN__ +#define DEFAULT_N_HOMING_LOCATE_CYCLE 1 // Integer (1-127) +#endif +///@} + +/*! @name Setting_HomingCycle_1 - Setting_HomingCycle_6 // Define the homing cycle patterns with bitmasks. The homing cycle first performs a search mode // to quickly engage the limit switches, followed by a slower locate mode, and finished by a short -// pull-off motion to disengage the limit switches. The following HOMING_CYCLE_x defines are executed +// pull-off motion to disengage the limit switches. The following DEFAULT_HOMING_CYCLE_x defines are executed // in order starting with suffix 0 and completes the homing routine for the specified-axes only. If // an axis is omitted from the defines, it will not home, nor will the system update its position. // Meaning that this allows for users with non-standard cartesian machines, such as a lathe (x then z, @@ -612,44 +1259,106 @@ __NOTE:__ these definitions are only referenced in this file. Do __NOT__ change! // on separate pin, but homed in one cycle. Also, it should be noted that the function of hard limits // will not be affected by pin sharing. // NOTE: Defaults are set for a traditional 3-axis CNC machine. Z-axis first to clear, followed by X & Y. +*/ -//#define HOMING_CYCLE_0 (Z_AXIS_BIT) // REQUIRED: First move Z to clear workspace. -//#define HOMING_CYCLE_1 (X_AXIS_BIT|Y_AXIS_BIT) // OPTIONAL: Then move X,Y at the same time. -//#define HOMING_CYCLE_2 0 // OPTIONAL: Uncomment and add axes mask to enable -#if N_AXIS > 3 -//#define HOMING_CYCLE_3 0 // OPTIONAL: Uncomment and add axes mask to enable -//#define HOMING_CYCLE_4 0 // OPTIONAL: Uncomment and add axes mask to enable -//#define HOMING_CYCLE_5 0 // OPTIONAL: Uncomment and add axes mask to enable +/*! @name $44 - Setting_HomingCycle_1 +*/ +///@{ +#if !defined DEFAULT_HOMING_CYCLE_0 || defined __DOXYGEN__ +#define DEFAULT_HOMING_CYCLE_0 (Z_AXIS_BIT) // REQUIRED: First move Z to clear workspace. #endif +///@} -// Enables single axis homing commands. $HX, $HY, and $HZ for X, Y, and Z-axis homing. The full homing -// cycle is still invoked by the $H command. This is disabled by default. It's here only to address -// users that need to switch between a two-axis and three-axis machine. This is actually very rare. -// If you have a two-axis machine, DON'T USE THIS. Instead, just alter the homing cycle for two-axes. -//#define HOMING_SINGLE_AXIS_COMMANDS // Default disabled. Uncomment to enable. +/*! @name $45 - Setting_HomingCycle_2 +*/ +///@{ +#if !defined DEFAULT_HOMING_CYCLE_1 || defined __DOXYGEN__ +#if COREXY +#define DEFAULT_HOMING_CYCLE_1 (X_AXIS_BIT) // OPTIONAL: Then move X. +#else +#define DEFAULT_HOMING_CYCLE_1 (X_AXIS_BIT|Y_AXIS_BIT) // OPTIONAL: Then move X,Y at the same time. +#endif +#endif +///@} -// After homing, Grbl will set by default the entire machine space into negative space, as is typical -// for professional CNC machines, regardless of where the limit switches are located. Set this -// define to 1 to force Grbl to always set the machine origin at the homed location despite switch orientation. -//#define HOMING_FORCE_SET_ORIGIN // Default disabled. Uncomment to enable. -#define HOMING_FORCE_SET_ORIGIN 1 +/*! @name $46 - Setting_HomingCycle_3 +*/ +///@{ +#if !defined DEFAULT_HOMING_CYCLE_2 || defined __DOXYGEN__ +#if COREXY +#define DEFAULT_HOMING_CYCLE_2 (Y_AXIS_BIT) // OPTIONAL: Then move Y. +#else +#define DEFAULT_HOMING_CYCLE_2 0 // OPTIONAL: Uncomment and add axes mask to enable +#endif +#endif +///@} -// To prevent the homing cycle from racking the dual axis, when one limit triggers before the -// other due to switch failure or noise, the homing cycle will automatically abort if the second -// motor's limit switch does not trigger within the three distance parameters defined below. -// Axis length percent will automatically compute a fail distance as a percentage of the max -// travel of the other non-dual axis, i.e. if dual axis select is X_AXIS at 5.0%, then the fail -// distance will be computed as 5.0% of y-axis max travel. Fail distance max and min are the -// limits of how far or little a valid fail distance is. -//#define DUAL_AXIS_HOMING_FAIL_AXIS_LENGTH_PERCENT 5.0f // Float (percent) -//#define DUAL_AXIS_HOMING_FAIL_DISTANCE_MAX 25.0f // Float (mm) -//#define DUAL_AXIS_HOMING_FAIL_DISTANCE_MIN 2.5f // Float (mm) +/*! @name $47 - Setting_HomingCycle_4 +*/ +///@{ +#if (defined A_AXIS && !defined DEFAULT_HOMING_CYCLE_3) || defined __DOXYGEN__ +#define DEFAULT_HOMING_CYCLE_3 0 // OPTIONAL: Uncomment and add axes mask to enable +#endif +///@} +/*! @name $48 - Setting_HomingCycle_5 +\ref axismask + */ +///@{ +#if (defined B_AXIS && !defined DEFAULT_HOMING_CYCLE_4) || defined __DOXYGEN__ +#define DEFAULT_HOMING_CYCLE_4 0 // OPTIONAL: Uncomment and add axes mask to enable +#endif +///@} + +/*! @name $49 - Setting_HomingCycle_6 +*/ +///@{ +#if (defined C_AXIS && !defined DEFAULT_HOMING_CYCLE_5) || defined __DOXYGEN__ +#define DEFAULT_HOMING_CYCLE_5 0 // OPTIONAL: Uncomment and add axes mask to enable +#endif +///@} + +// Probing settings (Group_Probing) + +/*! @name $6 - Setting_InvertProbePin +*/ +///@{ +#if !defined DEFAULT_PROBE_SIGNAL_INVERT || defined __DOXYGEN__ +#define DEFAULT_PROBE_SIGNAL_INVERT Off +#endif +///@} + +/*! @name $19 - Setting_ProbePullUpDisable +*/ +///@{ +#if !defined DEFAULT_PROBE_SIGNAL_DISABLE_PULLUP || defined __DOXYGEN__ +#define DEFAULT_PROBE_SIGNAL_DISABLE_PULLUP Off +#endif +///@} + +/*! @name $65 - Setting_ProbingFeedOverride +// By default, grblHAL disables feed rate overrides for all G38.x probe cycle commands. Although this +// may be different than some pro-class machine control, it's arguable that it should be this way. +// Most probe sensors produce different levels of error that is dependent on rate of speed. By +// keeping probing cycles to their programmed feed rates, the probe sensor should be a lot more +// repeatable. If needed, you can disable this behavior by uncommenting the define below. +*/ +///@{ +#if !defined DEFAULT_ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES || defined __DOXYGEN__ +#define DEFAULT_ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES Off +#endif +///@} + +// Safety door/parking settings (Group_SafetyDoor) + +#ifdef DEFAULT_HOMING_ENABLE + +/*! @name $41 - Setting_ParkingEnable // Enables and configures parking motion methods upon a safety door state. Primarily for OEMs -// that desire this feature for their integrated machines. At the moment, Grbl assumes that +// that desire this feature for their integrated machines. At the moment, grblHAL assumes that // the parking motion only involves one axis, although the parking implementation was written // to be easily refactored for any number of motions on different axes by altering the parking -// source code. At this time, Grbl only supports parking one axis (typically the Z-axis) that +// source code. At this time, grblHAL only supports parking one axis (typically the Z-axis) that // moves in the positive direction upon retracting and negative direction upon restoring position. // The motion executes with a slow pull-out retraction motion, power-down, and a fast park. // Restoring to the resume position follows these set motions in reverse: fast restore to @@ -658,17 +1367,523 @@ __NOTE:__ these definitions are only referenced in this file. Do __NOT__ change! // NOTE: Still a work-in-progress. Machine coordinates must be in all negative space and // does not work with HOMING_FORCE_SET_ORIGIN enabled. Parking motion also moves only in // positive direction. -//#define DEFAULT_PARKING_ENABLE // Default disabled. Uncomment to enable. + * // Default disabled. Uncomment to enable. +*/ +///@{ +#if !defined DEFAULT_PARKING_ENABLE || defined __DOXYGEN__ +#define DEFAULT_PARKING_ENABLE Off // bit 0 +// Enables a special set of M-code commands that enables and disables the parking motion. +// 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. By default, M56 is active upon initialization. Use +// DEACTIVATE_PARKING_UPON_INIT to set M56 P0 as the power-up default. +#endif +#if !defined DEFAULT_DEACTIVATE_PARKING_UPON_INIT || defined __DOXYGEN__ +#define DEFAULT_DEACTIVATE_PARKING_UPON_INIT Off // bit 1 +#endif +#if !defined DEFAULT_ENABLE_PARKING_OVERRIDE_CONTROL || defined __DOXYGEN__ +#define DEFAULT_ENABLE_PARKING_OVERRIDE_CONTROL Off // bit 2 +#endif +///@} -// End default values for run time configurable settings +/*! @name $42 - Setting_ParkingAxis +Define which axis that performs the parking motion +*/ +///@{ +#if !defined DEFAULT_PARKING_AXIS || defined __DOXYGEN__ +#define DEFAULT_PARKING_AXIS Z_AXIS // +#endif +///@} + +/*! @name $56 - Setting_ParkingPulloutIncrement +*/ +///@{ +#if !defined DEFAULT_PARKING_PULLOUT_INCREMENT || defined __DOXYGEN__ +#define DEFAULT_PARKING_PULLOUT_INCREMENT 5.0f // +#endif +///@} + +/*! @name $57 - Setting_ParkingPulloutRate +Spindle pull-out and plunge distance in mm. Incremental distance. +Must be positive value or equal to zero.*/ +///@{ +#if !defined DEFAULT_PARKING_PULLOUT_RATE || defined __DOXYGEN__ +#define DEFAULT_PARKING_PULLOUT_RATE 100.0f // mm/min. +#endif +///@} + +/*! @name $58 - Setting_ParkingTarget +Parking axis target. In mm, as machine coordinate [-max_travel, 0]. +*/ +///@{ +#if !defined DEFAULT_PARKING_TARGET || defined __DOXYGEN__ +#define DEFAULT_PARKING_TARGET -5.0f // mm +#endif +///@} + +/*! @name $59 - Setting_ParkingFastRate +Parking fast rate after pull-out in mm/min. +*/ +///@{ +#if !defined DEFAULT_HOMING_CYCLE_5 || defined __DOXYGEN__ +#define DEFAULT_PARKING_RATE 500.0f // mm/min +#endif +///@} + +/*! @name $61 - Setting_DoorOptions +*/ +///@{ +/*! +\brief +If set to \ref On or 1 ignore the door open signal command when in IDLE state. +This can be useful for jogging laser cutters/engravers when the lid is open. + */ +#if !defined DEFAULT_DOOR_IGNORE_WHEN_IDLE || defined __DOXYGEN__ +#define DEFAULT_DOOR_IGNORE_WHEN_IDLE Off +#endif +/*! +\brief +If set to \ref On or 1 keep the coolant on when door is opened. + */ +#if !defined DEFAULT_DOOR_KEEP_COOLANT_ON || defined __DOXYGEN__ +#define DEFAULT_DOOR_KEEP_COOLANT_ON Off +#endif +///@} +/*! @name 392 - Setting_DoorSpindleOnDelay +\brief +After the safety door switch has been toggled and restored, this setting sets the power-up delay +between restoring the spindle and resuming the cycle. +*/ +///@{ +#if !defined DEFAULT_SAFETY_DOOR_SPINDLE_DELAY || defined __DOXYGEN__ +#define DEFAULT_SAFETY_DOOR_SPINDLE_DELAY 4.0f // Float (seconds) +#endif +///@} + +/*! @name 393 - Setting_DoorCoolantOnDelay +\brief +After the safety door switch has been toggled and restored, this setting sets the power-up delay +between restoring the coolant and resuming the cycle. +*/ +///@{ +#if !defined DEFAULT_SAFETY_DOOR_COOLANT_DELAY || defined __DOXYGEN__ +#define DEFAULT_SAFETY_DOOR_COOLANT_DELAY 1.0f // Float (seconds) +#endif +///@} #endif // DEFAULT_HOMING_ENABLE -// Uncomment to enable experimental support for parameters and expressions -//#define NGC_EXPRESSIONS_ENABLE 1 +// Jogging settings (Group_Jogging) -#ifndef TOOLSETTER_RADIUS -#define TOOLSETTER_RADIUS 5.0f // Default value - do not change here! +/*! @name $40 - Setting_JogSoftLimited +\brief Soft limit jog commands to stay within machine limits. +Unlike the general soft limits that raises an alarm for motions that exceeds +machine limits this setting, when enabled, keeps them with the limits. +
__NOTE:__ Requires the machine to be homed and have correctly set machine limts. +*/ +///@{ +#if !defined DEFAULT_JOG_LIMIT_ENABLE || defined __DOXYGEN__ +#define DEFAULT_JOG_LIMIT_ENABLE Off +#endif +///@} + +// Stepper settings (Group_Stepper) + +/*! @name $0 - Setting_PulseMicroseconds +\brief Stepper pulse length in microseconds. +
__NOTE:__ The different MCUs supported have different interrupt latencies +and some drivers may enable features that are not available on others. This may +lead to this setting not beeing respected exactly over the supported range. +Typically drivers are calibrated to be correct for 10 microsecond pulse lengths, +however if a precise pulse length is required it should be measured and +adjusted either by changing this value or by changing the `STEP_PULSE_LATENCY` symbol +value that many drivers supports. Note that `STEP_PULSE_LATENCY` symbol is driver +specific - it is _not_ defined in the core. +*/ +///@{ +#if !defined DEFAULT_STEP_PULSE_MICROSECONDS || defined __DOXYGEN__ +#define DEFAULT_STEP_PULSE_MICROSECONDS 10.0f +#endif +///@} + +/*! @name $1 - Setting_StepperIdleLockTime +Delay in milliseconds before steppers are disabled when idle, range 0-65535. +Which axes are disabled can be defined by the \ref DEFAULT_STEPPER_DEENERGIZE_MASK +symbol. E.g. it might be desirable to unlock X and Y and keep the Z-axis enabled +since the spindle may pull down the Z due to its weight. +
__NOTE:__ Setting this value to 255 keeps all steppers enabled. +*/ +///@{ +#if !defined DEFAULT_STEPPER_IDLE_LOCK_TIME || defined __DOXYGEN__ +#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // milliseconds +#endif +///@} + +/*! @name $2 - Setting_StepInvertMask +\brief \ref axismask controlling the polarity of the step signals. The default is positive pulses. +Set this value to -1 to invert for all steppers or specify which by mask. +*/ +///@{ +#if !defined DEFAULT_STEP_SIGNALS_INVERT_MASK || defined __DOXYGEN__ +#define DEFAULT_STEP_SIGNALS_INVERT_MASK 0 +#endif +///@} + +/*! @name $3 - Setting_DirInvertMask +\brief \ref axismask controling the polarity of the stepper direction signals. The default +is positive voltage for motions in negative direction. +Set this value to -1 to invert for all steppers or specify which by mask.*/ +///@{ +#if !defined DEFAULT_DIR_SIGNALS_INVERT_MASK || defined __DOXYGEN__ +#define DEFAULT_DIR_SIGNALS_INVERT_MASK 0 +#endif +///@} + +/*! @name $4 - Setting_InvertStepperEnable +\brief \ref axismask for inverting the polarity of the stepper enable signal(s). +
__NOTE:__ If \ref COMPATIBILITY_LEVEL > 2 this setting reverts to the legacy + Grbl behaviour where 0 inverts the enable signals for all drivers + and 1 does not. +
__NOTE:__ This setting is not universally available for individual axes - check + board documentation. + Specify at least \ref X_AXIS_BIT if a common enable signal is used. +*/ +///@{ +#if !defined DEFAULT_ENABLE_SIGNALS_INVERT_MASK || defined __DOXYGEN__ +#define DEFAULT_ENABLE_SIGNALS_INVERT_MASK (X_AXIS_BIT|Y_AXIS_BIT|Z_AXIS_BIT) // Default disabled. Uncomment to enable. +#else +//#define DEFAULT_ENABLE_SIGNALS_INVERT_MASK 1 +#endif +///@} + +/*! @name $8 - Setting_GangedDirInvertMask +\brief \ref axismask for inverting the polarity of the stepper direction signal(s) for the +second motor for ganged/auto squared axes. +*/ +///@{ +#if !defined DEFAULT_GANGED_DIRECTION_INVERT_MASK || defined __DOXYGEN__ +#define DEFAULT_GANGED_DIRECTION_INVERT_MASK 0 +#endif +///@} + +/*! @name $29 - Setting_PulseDelayMicroseconds +*/ +///@{ +#if !defined DEFAULT_STEP_PULSE_DELAY || defined __DOXYGEN__ +#define DEFAULT_STEP_PULSE_DELAY 5.0f // uncomment to set default > 0.0f +#endif +///@} + +/*! @name $37 - Setting_StepperDeenergizeMask +\ref axismask to be OR'ed with stepper disable signal(s). Axes configured will not be disabled. +
__NOTE:__ Not universally available for individual axes - check driver documentation. +Specify at least \ref X_AXIS_BIT if a common enable signal is used. +*/ +///@{ +#if !defined DEFAULT_STEPPER_DEENERGIZE_MASK || defined __DOXYGEN__ +#define DEFAULT_STEPPER_DEENERGIZE_MASK 0 +#endif +///@} + +/*! @name $376 - Settings_Axis_Rotational +Designate ABC axes as rotational by \ref axismask. This will disable scaling (to mm) in inches mode. +Set steps/mm for the axes to the value that represent the desired movement per unit. +For the controller the distance is unitless and and can be in degrees, radians, rotations, ... +*/ +///@{ +#if !defined DEFAULT_AXIS_ROTATIONAL_MASK || defined __DOXYGEN__ +#define DEFAULT_AXIS_ROTATIONAL_MASK 0 +#endif +///@} + +/*! @name $481 - Setting_AutoReportInterval +// Auto status report interval, allowed range is 100 - 1000. Set to 0 to disable. +*/ +///@{ +#if !defined DEFAULT_AUTOREPORT_INTERVAL || defined __DOXYGEN__ +#define DEFAULT_AUTOREPORT_INTERVAL 0 +#endif +///@} + +/*! @name $482 - Setting_TimeZoneOffset +Timezone offset from UTC in hours, allowed range is -12.0 - 12.0. +*/ +///@{ +#if !defined DEFAULT_TIMEZONE_OFFSET || defined __DOXYGEN__ +#define DEFAULT_TIMEZONE_OFFSET 0.0f +#endif +///@} + +// Axis settings (Group_XAxis - Group_VAxis) + +/*! @name $10x - Setting_AxisStepsPerMM + + */ +///@{ +#if !defined DEFAULT_X_STEPS_PER_MM || defined __DOXYGEN__ +#define DEFAULT_X_STEPS_PER_MM 250.0f +#endif +#if !defined DEFAULT_Y_STEPS_PER_MM || defined __DOXYGEN__ +#define DEFAULT_Y_STEPS_PER_MM 250.0f +#endif +#if !defined DEFAULT_Z_STEPS_PER_MM || defined __DOXYGEN__ +#define DEFAULT_Z_STEPS_PER_MM 250.0f +#endif +#if (defined A_AXIS && !defined DEFAULT_A_STEPS_PER_MM) || defined __DOXYGEN__ +#define DEFAULT_A_STEPS_PER_MM 250.0f +#endif +#if (defined B_AXIS && !defined DEFAULT_B_STEPS_PER_MM) || defined __DOXYGEN__ +#define DEFAULT_B_STEPS_PER_MM 250.0f +#endif +#if (defined C_AXIS && !defined DEFAULT_C_STEPS_PER_MM) || defined __DOXYGEN__ +#define DEFAULT_C_STEPS_PER_MM 250.0f +#endif +#if (defined U_AXIS && !defined DEFAULT_U_STEPS_PER_MM) || defined __DOXYGEN__ +#define DEFAULT_U_STEPS_PER_MM 250.0f +#endif +#if (defined V_AXIS && !defined DEFAULT_V_STEPS_PER_MM) || defined __DOXYGEN__ +#define DEFAULT_V_STEPS_PER_MM 250.0f +#endif +///@} + +/*! @name $11x - Setting_AxisMaxRate + +*/ +///@{ +#if !defined DEFAULT_X_MAX_RATE || defined __DOXYGEN__ +#define DEFAULT_X_MAX_RATE 500.0f // mm/min +#endif +#if !defined DEFAULT_Y_MAX_RATE || defined __DOXYGEN__ +#define DEFAULT_Y_MAX_RATE 500.0f // mm/min +#endif +#if !defined DEFAULT_Z_MAX_RATE || defined __DOXYGEN__ +#define DEFAULT_Z_MAX_RATE 500.0f // mm/min +#endif +#if (defined A_AXIS && !defined DEFAULT_A_MAX_RATE) || defined __DOXYGEN__ +#define DEFAULT_A_MAX_RATE 500.0f // mm/min +#endif +#if (defined B_AXIS && !defined DEFAULT_B_MAX_RATE) || defined __DOXYGEN__ +#define DEFAULT_B_MAX_RATE 500.0f // mm/min +#endif +#if (defined C_AXIS && !defined DEFAULT_C_MAX_RATE) || defined __DOXYGEN__ +#define DEFAULT_C_MAX_RATE 500.0f // mm/min +#endif +#if (defined U_AXIS && !defined DEFAULT_U_MAX_RATE) || defined __DOXYGEN__ +#define DEFAULT_U_MAX_RATE 500.0f // mm/min +#endif +#if (defined V_AXIS && !defined DEFAULT_V_MAX_RATE) || defined __DOXYGEN__ +#define DEFAULT_V_MAX_RATE 500.0f // mm/min +#endif +///@} + +/*! @name 12x - Setting_AxisAcceleration +*/ +///@{ +#if !defined DEFAULT_X_ACCELERATION || defined __DOXYGEN__ +#define DEFAULT_X_ACCELERATION 10.0f // mm/min^2 +#endif +#if !defined DEFAULT_Y_ACCELERATION || defined __DOXYGEN__ +#define DEFAULT_Y_ACCELERATION 10.0f // mm/min^2 +#endif +#if !defined DEFAULT_Z_ACCELERATION || defined __DOXYGEN__ +#define DEFAULT_Z_ACCELERATION 10.0f // mm/min^2 +#endif +#if (defined A_AXIS && !defined DEFAULT_A_ACCELERATION) || defined __DOXYGEN__ +#define DEFAULT_A_ACCELERATION 10.0f // mm/min^2 +#endif +#if (defined B_AXIS && !defined DEFAULT_B_ACCELERATION) || defined __DOXYGEN__ +#define DEFAULT_B_ACCELERATION 10.0f // mm/min^2 +#endif +#if (defined C_AXIS && !defined DEFAULT_C_ACCELERATION) || defined __DOXYGEN__ +#define DEFAULT_C_ACCELERATION 10.0f // mm/min^2 +#endif +#if (defined U_AXIS && !defined DEFAULT_U_ACCELERATION) || defined __DOXYGEN__ +#define DEFAULT_U_ACCELERATION 10.0f // mm/min^2 +#endif +#if (defined V_AXIS && !defined DEFAULT_V_ACCELERATION) || defined __DOXYGEN__ +#define DEFAULT_V_ACCELERATION 10.0f // mm/min^2 +#endif +///@} + +/*! @name 13x - Setting_AxisMaxTravel +__NOTE:__ Must be a positive values. +*/ +///@{ +#if !defined DEFAULT_X_MAX_TRAVEL || defined __DOXYGEN__ +#define DEFAULT_X_MAX_TRAVEL 200.0f // mm +#endif +#if !defined DEFAULT_Y_MAX_TRAVEL || defined __DOXYGEN__ +#define DEFAULT_Y_MAX_TRAVEL 200.0f // mm +#endif +#if !defined DEFAULT_Z_MAX_TRAVEL || defined __DOXYGEN__ +#define DEFAULT_Z_MAX_TRAVEL 200.0f // mm +#endif +#if (defined A_AXIS && !defined DEFAULT_A_MAX_TRAVEL) || defined __DOXYGEN__ +#define DEFAULT_A_MAX_TRAVEL 200.0f // mm +#endif +#if (defined B_AXIS && !defined DEFAULT_B_MAX_TRAVEL) || defined __DOXYGEN__ +#define DEFAULT_B_MAX_TRAVEL 200.0f // mm +#endif +#if (defined C_AXIS && !defined DEFAULT_C_MAX_TRAVEL) || defined __DOXYGEN__ +#define DEFAULT_C_MAX_TRAVEL 200.0f // mm +#endif +#if (defined U_AXIS && !defined DEFAULT_U_MAX_TRAVEL) || defined __DOXYGEN__ +#define DEFAULT_U_MAX_TRAVEL 200.0f // mm +#endif +#if (defined V_AXIS && !defined DEFAULT_V_MAX_TRAVEL) || defined __DOXYGEN__ +#define DEFAULT_V_MAX_TRAVEL 200.0f // mm +#endif +///@} + +/*! @name 14x - Setting_AxisStepperCurrent + * + */ +///@{ +#if !defined DEFAULT_X_CURRENT || defined __DOXYGEN__ +#define DEFAULT_X_CURRENT 0.0 // amps +#endif +#if !defined DEFAULT_Y_CURRENT || defined __DOXYGEN__ +#define DEFAULT_Y_CURRENT 0.0 // amps +#endif +#if !defined DEFAULT_Z_CURRENT || defined __DOXYGEN__ +#define DEFAULT_Z_CURRENT 0.0 // amps +#endif +#if (defined A_AXIS && !defined DEFAULT_A_CURRENT) || defined __DOXYGEN__ +#define DEFAULT_A_CURRENT 0.0 // amps +#endif +#if (defined B_AXIS && !defined DEFAULT_B_CURRENT) || defined __DOXYGEN__ +#define DEFAULT_B_CURRENT 0.0 // amps +#endif +#if (defined C_AXIS && !defined DEFAULT_C_CURRENT) || defined __DOXYGEN__ +#define DEFAULT_C_CURRENT 0.0 // amps +#endif +#if (defined U_AXIS && !defined DEFAULT_U_CURRENT) || defined __DOXYGEN__ +#define DEFAULT_U_CURRENT 0.0 // amps +#endif +#if (defined V_AXIS && !defined DEFAULT_V_CURRENT) || defined __DOXYGEN__ +#define DEFAULT_V_CURRENT 0.0 // amps +#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 + +#if (REPORT_WCO_REFRESH_BUSY_COUNT < REPORT_WCO_REFRESH_IDLE_COUNT) + #error "WCO busy refresh is less than idle refresh." +#endif +#if (REPORT_OVERRIDE_REFRESH_BUSY_COUNT < REPORT_OVERRIDE_REFRESH_IDLE_COUNT) + #error "Override busy refresh is less than idle refresh." +#endif +#if (REPORT_WCO_REFRESH_IDLE_COUNT < 2) + #error "WCO refresh must be greater than one." +#endif +#if (REPORT_OVERRIDE_REFRESH_IDLE_COUNT < 1) + #error "Override refresh must be greater than zero." +#endif + +#if DEFAULT_LASER_MODE && DEFAULT_LATHE_MODE +#error "Cannot enable laser and lathe mode at the same time!" +#endif + +#if DEFAULT_CONTROL_SIGNALS_INVERT_MASK < 0 +#undef DEFAULT_CONTROL_SIGNALS_INVERT_MASK +#define DEFAULT_CONTROL_SIGNALS_INVERT_MASK SIGNALS_BITMASK +#endif + +#if DEFAULT_LIMIT_SIGNALS_INVERT_MASK < 0 +#undef DEFAULT_LIMIT_SIGNALS_INVERT_MASK +#define DEFAULT_LIMIT_SIGNALS_INVERT_MASK AXES_BITMASK +#endif + +#if DEFAULT_LIMIT_SIGNALS_PULLUP_DISABLE_MASK < 0 +#undef DEFAULT_LIMIT_SIGNALS_PULLUP_DISABLE_MASK +#define DEFAULT_LIMIT_SIGNALS_PULLUP_DISABLE_MASK AXES_BITMASK +#endif + +#if DEFAULT_STEP_SIGNALS_INVERT_MASK < 0 +#undef DEFAULT_STEP_SIGNALS_INVERT_MASK +#define DEFAULT_STEP_SIGNALS_INVERT_MASK AXES_BITMASK +#endif + +#if DEFAULT_ENABLE_SIGNALS_INVERT_MASK < 0 +#undef DEFAULT_ENABLE_SIGNALS_INVERT_MASK +#define DEFAULT_ENABLE_SIGNALS_INVERT_MASK AXES_BITMASK +#endif + +#if DEFAULT_PARKING_ENABLE > 0 + #if DEFAULT_HOMING_FORCE_SET_ORIGIN > 0 + #error "HOMING_FORCE_SET_ORIGIN is not supported with PARKING_ENABLE at this time." + #endif +#endif + +#if DEFAULT_ENABLE_PARKING_OVERRIDE_CONTROL > 0 + #if DEFAULT_PARKING_ENABLE < 1 + #error "ENABLE_PARKING_OVERRIDE_CONTROL must be enabled with PARKING_ENABLE." + #endif +#endif + +/*! \page page1 Documentation of some common concepts used in config.h +\section axismask axismask +Example axismasks, replace XXX with the symbol name you want to define sans `_MASK`: +
No axes: +
`#define XXX_MASK 0` +
All axes: +
`#define XXX_MASK AXES_BITMASK` +
`#define XXX_MASK -1` // the value may be used from the compiler command line. +
Single axis: +
`#define XXX_MASK Z_AXIS` +
`#define XXX_MASK 4` // same as above but as a bitfield value, the value may be used from the compiler command line. +
Specific axes: +
`#define XXX_MASK (X_AXIS || Y_AXIS)` +
`#define XXX_MASK 3` // same as above but as a bitfield value, the value may be used from the compiler command line. + +\section axis axis +Bitfield values are the sum of the individual bit values for each axis, these are: +
`X_AXIS = 1` +
`Y_AXIS = 2` +
`Z_AXIS = 4` +
`A_AXIS = 8` +
`B_AXIS = 16` +
`C_AXIS = 32` +
`U_AXIS = 64` +
`V_AXIS = 128` + +\section signalmask signalmask +Example signalmasks, replace XXX with the symbol name you want to define sans `_MASK`: +
No signals: +
`#define XXX_MASK 0` +
All signals: +
`#define XXX_MASK SIGNALS_BITMASK` +
`#define XXX_MASK -1` // the value may be used from the compiler command line. +
Single axis: +
`#define XXX_MASK SIGNALS_ESTOP_BIT` +
`#define XXX_MASK 64` // same as above but as a bitfield value, the value may be used from the compiler command line. +
Specific axes: +
`#define XXX_MASK (SIGNALS_FEEDHOLD_BIT || SIGNALS_CYCLESTART_BIT)` +
`#define XXX_MASK 6` // same as above but as a bitfield value, the value may be used from the compiler command line. + +\section signal signal + +
`SIGNALS_RESET_BIT = 1` +
`SIGNALS_FEEDHOLD_BIT = 2` +
`SIGNALS_CYCLESTART_BIT= 4` +
`SIGNALS_SAFETYDOOR_BIT = 8` +
`SIGNALS_BLOCKDELETE_BIT = 16` +
`SIGNALS_STOPDISABLE_BIT = 32` +
`SIGNALS_ESTOP_BIT = 64` +
`SIGNALS_PROBE_CONNECTED_BIT = 128` +
`SIGNALS_MOTOR_FAULT_BIT = 256` +
`SIGNALS_BITMASK = 512` +*/ + +#endif // _GRBL_CONFIG_H_ diff --git a/coolant_control.h b/coolant_control.h index 3c6f206..8fd097b 100644 --- a/coolant_control.h +++ b/coolant_control.h @@ -22,6 +22,7 @@ #ifndef _COOLANT_CONTROL_H_ #define _COOLANT_CONTROL_H_ +// if changed to > 8 bits planner_cond_t needs to be changed too typedef union { uint8_t value; //!< Bitmask value uint8_t mask; //!< Synonym for bitmask value diff --git a/core_handlers.h b/core_handlers.h index 802f95f..7656698 100644 --- a/core_handlers.h +++ b/core_handlers.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2020-2022 Terje Io + Copyright (c) 2020-2023 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,15 @@ #include "report.h" #include "planner.h" +typedef enum { + OverrideChanged_FeedRate = 0, + OverrideChanged_RapidRate = 0, + OverrideChanged_SpindleRPM = 0, + OverrideChanged_SpindleState = 0, + OverrideChanged_CoolantState = 0, + OverrideChanged_FanState = 0 +} override_changed_t; + /* TODO: add to grbl pointers so that a different formatting (xml, json etc) of reports may be implemented by driver? typedef struct { status_code_t (*report_status_message)(status_code_t status_code); @@ -68,6 +77,7 @@ typedef bool (*enqueue_gcode_ptr)(char *data); typedef bool (*protocol_enqueue_realtime_command_ptr)(char c); typedef void (*on_state_change_ptr)(sys_state_t state); +typedef void (*on_override_changed_ptr)(override_changed_t override); typedef void (*on_spindle_programmed_ptr)(spindle_state_t spindle, float rpm, spindle_rpm_mode_t mode); typedef void (*on_program_completed_ptr)(program_flow_t program_flow, bool check_mode); typedef void (*on_execute_realtime_ptr)(sys_state_t state); @@ -99,6 +109,7 @@ typedef struct { report_t report; // grbl core events - may be subscribed to by drivers or by the core. on_state_change_ptr on_state_change; + on_override_changed_ptr on_override_changed; on_report_handlers_init_ptr on_report_handlers_init; on_spindle_programmed_ptr on_spindle_programmed; on_program_completed_ptr on_program_completed; diff --git a/corexy.c b/corexy.c index 41790d5..b9d0886 100644 --- a/corexy.c +++ b/corexy.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2019-2022 Terje Io + Copyright (c) 2019-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Grbl is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ #include "grbl.h" -#ifdef COREXY +#if COREXY #include diff --git a/defaults.h b/defaults.h deleted file mode 100644 index ae9f240..0000000 --- a/defaults.h +++ /dev/null @@ -1,650 +0,0 @@ -/* - defaults.h - defaults settings configuration file - - Do NOT modify this file unless adding settings! - Changes to these default values should be made in config.h or by declaring compiler symbols. - - NOTE: This file is only used by settings.c and should NOT be referenced elsewhere! - - Part of grblHAL - - Copyright (c) 2017-2020 Terje Io - Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC - - Grbl is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Grbl is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Grbl. If not, see . -*/ - -#ifndef _DEFAULTS_H_ -#define _DEFAULTS_H_ - -#include "config.h" - -#ifndef BUILD_INFO -#define BUILD_INFO "" -#endif - -// 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 -#else -#define DEFAULT_REPORT_MACHINE_POSITION 0 -#endif - -#ifdef DEFAULT_NO_REPORT_BUFFER_STATE -#undef DEFAULT_NO_REPORT_BUFFER_STATE -#define DEFAULT_REPORT_BUFFER_STATE 0 -#else -#define DEFAULT_REPORT_BUFFER_STATE 1 -#endif - -#ifdef DEFAULT_NO_REPORT_LINE_NUMBERS -#undef DEFAULT_NO_REPORT_LINE_NUMBERS -#define DEFAULT_REPORT_LINE_NUMBERS 0 -#else -#define DEFAULT_REPORT_LINE_NUMBERS 1 -#endif - -#ifdef DEFAULT_NO_REPORT_CURRENT_FEED_SPEED -#undef DEFAULT_NO_REPORT_CURRENT_FEED_SPEED -#define DEFAULT_REPORT_CURRENT_FEED_SPEED 0 -#else -#define DEFAULT_REPORT_CURRENT_FEED_SPEED 1 -#endif - -#ifdef DEFAULT_NO_REPORT_PIN_STATE -#undef DEFAULT_NO_REPORT_PIN_STATE -#define DEFAULT_REPORT_PIN_STATE 0 -#else -#define DEFAULT_REPORT_PIN_STATE 1 -#endif - -#ifdef DEFAULT_NO_REPORT_WORK_COORD_OFFSET -#undef DEFAULT_NO_REPORT_WORK_COORD_OFFSET -#define DEFAULT_REPORT_WORK_COORD_OFFSET 0 -#else -#define DEFAULT_REPORT_WORK_COORD_OFFSET 1 -#endif - -#ifdef DEFAULT_NO_REPORT_OVERRIDES -#undef DEFAULT_NO_REPORT_OVERRIDES -#define DEFAULT_REPORT_OVERRIDES 0 -#else -#define DEFAULT_REPORT_OVERRIDES 1 -#endif - -#ifdef DEFAULT_NO_REPORT_PROBE_COORDINATES -#undef DEFAULT_NO_REPORT_PROBE_COORDINATES -#define DEFAULT_REPORT_PROBE_COORDINATES 0 -#else -#define DEFAULT_REPORT_PROBE_COORDINATES 1 -#endif - -#ifdef DEFAULT_NO_FORCE_BUFFER_SYNC_DURING_WCO_CHANGE -#undef DEFAULT_NO_FORCE_BUFFER_SYNC_DURING_WCO_CHANGE -#define DEFAULT_REPORT_SYNC_ON_WCO_CHANGE 0 -#else -#define DEFAULT_REPORT_SYNC_ON_WCO_CHANGE 1 -#endif - -#ifdef DEFAULT_REPORT_PARSER_STATE -#undef DEFAULT_REPORT_PARSER_STATE -#define DEFAULT_REPORT_PARSER_STATE 1 -#else -#define DEFAULT_REPORT_PARSER_STATE 0 -#endif - -#ifdef DEFAULT_REPORT_ALARM_SUBSTATE -#undef DEFAULT_REPORT_ALARM_SUBSTATE -#define DEFAULT_REPORT_ALARM_SUBSTATE 1 -#else -#define DEFAULT_REPORT_ALARM_SUBSTATE 0 -#endif - -#ifndef DEFAULT_X_STEPS_PER_MM -#define DEFAULT_X_STEPS_PER_MM 250.0f -#endif -#ifndef DEFAULT_Y_STEPS_PER_MM -#define DEFAULT_Y_STEPS_PER_MM 250.0f -#endif -#ifndef DEFAULT_Z_STEPS_PER_MM -#define DEFAULT_Z_STEPS_PER_MM 250.0f -#endif -#ifndef DEFAULT_X_MAX_RATE -#define DEFAULT_X_MAX_RATE 500.0f -#endif -#ifndef DEFAULT_Y_MAX_RATE -#define DEFAULT_Y_MAX_RATE 500.0f -#endif -#ifndef DEFAULT_Z_MAX_RATE -#define DEFAULT_Z_MAX_RATE 500.0f -#endif -#ifndef DEFAULT_X_ACCELERATION -#define DEFAULT_X_ACCELERATION DEFAULT_ACCELERATION -#endif -#ifndef DEFAULT_Y_ACCELERATION -#define DEFAULT_Y_ACCELERATION DEFAULT_ACCELERATION -#endif -#ifndef DEFAULT_Z_ACCELERATION -#define DEFAULT_Z_ACCELERATION DEFAULT_ACCELERATION -#endif -#ifndef DEFAULT_X_MAX_TRAVEL -#define DEFAULT_X_MAX_TRAVEL 200.0f -#endif -#ifndef DEFAULT_Y_MAX_TRAVEL -#define DEFAULT_Y_MAX_TRAVEL 200.0f -#endif -#ifndef DEFAULT_Z_MAX_TRAVEL -#define DEFAULT_Z_MAX_TRAVEL 200.0f -#endif -#ifndef DEFAULT_X_CURRENT -#define DEFAULT_X_CURRENT 0.0 -#endif -#ifndef DEFAULT_Y_CURRENT -#define DEFAULT_Y_CURRENT 0.0 -#endif -#ifndef DEFAULT_Z_CURRENT -#define DEFAULT_Z_CURRENT 0.0 -#endif -#ifndef DEFAULT_A_CURRENT -#define DEFAULT_A_CURRENT 0.0 -#endif -#ifndef DEFAULT_SPINDLE_PWM_FREQ -#define DEFAULT_SPINDLE_PWM_FREQ 5000 -#endif -#ifndef DEFAULT_SPINDLE_PWM_OFF_VALUE -#define DEFAULT_SPINDLE_PWM_OFF_VALUE 0.0f -#endif -#ifndef DEFAULT_SPINDLE_PWM_MIN_VALUE -#define DEFAULT_SPINDLE_PWM_MIN_VALUE 0.0f -#endif -#ifndef DEFAULT_SPINDLE_PWM_MAX_VALUE -#define DEFAULT_SPINDLE_PWM_MAX_VALUE 100.0f -#endif -#ifndef DEFAULT_SPINDLE_AT_SPEED_TOLERANCE -#define DEFAULT_SPINDLE_AT_SPEED_TOLERANCE 0.0f -#endif -#ifndef DEFAULT_SPINDLE_RPM_MAX -#define DEFAULT_SPINDLE_RPM_MAX 1000.0 -#endif -#ifndef DEFAULT_SPINDLE_RPM_MIN -#define DEFAULT_SPINDLE_RPM_MIN 0.0 -#endif -#ifndef DEFAULT_SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED -#define DEFAULT_SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED 0 -#endif -#ifndef DEFAULT_STEP_PULSE_MICROSECONDS -#define DEFAULT_STEP_PULSE_MICROSECONDS 10.0f -#endif -#ifndef DEFAULT_STEP_PULSE_DELAY -#define DEFAULT_STEP_PULSE_DELAY 0.0f -#endif -#ifndef DEFAULT_STEPPING_INVERT_MASK -#define DEFAULT_STEPPING_INVERT_MASK 0 -#endif -#ifndef DEFAULT_DIRECTION_INVERT_MASK -#define DEFAULT_DIRECTION_INVERT_MASK 0 -#endif -#ifndef DEFAULT_GANGED_DIRECTION_INVERT_MASK -#define DEFAULT_GANGED_DIRECTION_INVERT_MASK 0 -#endif -#ifndef DEFAULT_STEPPER_IDLE_LOCK_TIME -#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 -#endif -#ifndef DEFAULT_JUNCTION_DEVIATION -#define DEFAULT_JUNCTION_DEVIATION 0.01f -#endif -#ifndef DEFAULT_ARC_TOLERANCE -#define DEFAULT_ARC_TOLERANCE 0.002f -#endif - -#ifdef DEFAULT_INVERT_LIMIT_BITS -#undef DEFAULT_INVERT_LIMIT_BITS -#define INVERT_LIMIT_BIT_MASK AXES_BITMASK -#endif - -#ifdef DEFAULT_REPORT_INCHES -#undef DEFAULT_REPORT_INCHES -#define DEFAULT_REPORT_INCHES 1 -#else -#define DEFAULT_REPORT_INCHES 0 -#endif - -#ifdef DEFAULT_SOFT_LIMIT_ENABLE -#undef DEFAULT_SOFT_LIMIT_ENABLE -#define DEFAULT_SOFT_LIMIT_ENABLE 1 -#else -#define DEFAULT_SOFT_LIMIT_ENABLE 0 -#endif - -#ifdef DEFAULT_JOG_LIMIT_ENABLE -#undef DEFAULT_JOG_LIMIT_ENABLE -#define DEFAULT_JOG_LIMIT_ENABLE 1 -#else -#define DEFAULT_JOG_LIMIT_ENABLE 0 -#endif - -#ifdef DEFAULT_HARD_LIMIT_ENABLE -#undef DEFAULT_HARD_LIMIT_ENABLE -#define DEFAULT_HARD_LIMIT_ENABLE 1 -#else -#define DEFAULT_HARD_LIMIT_ENABLE 0 -#endif - -#ifdef DEFAULT_INVERT_PROBE_BIT -#undef DEFAULT_INVERT_PROBE_BIT -#define DEFAULT_INVERT_PROBE_BIT 1 -#else -#define DEFAULT_INVERT_PROBE_BIT 0 -#endif - -#ifndef DEFAULT_A_STEPS_PER_MM -#define DEFAULT_A_STEPS_PER_MM 250.0f -#endif -#ifndef DEFAULT_A_MAX_RATE -#define DEFAULT_A_MAX_RATE 500.0f -#endif -#ifndef DEFAULT_A_ACCELERATION -#define DEFAULT_A_ACCELERATION DEFAULT_ACCELERATION -#endif -#ifndef DEFAULT_A_MAX_TRAVEL -#define DEFAULT_A_MAX_TRAVEL 200.0f -#endif - -#ifndef DEFAULT_B_STEPS_PER_MM -#define DEFAULT_B_STEPS_PER_MM 250.0f -#endif -#ifndef DEFAULT_B_MAX_RATE -#define DEFAULT_B_MAX_RATE 500.0f -#endif -#ifndef DEFAULT_B_ACCELERATION -#define DEFAULT_B_ACCELERATION DEFAULT_ACCELERATION -#endif -#ifndef DEFAULT_B_MAX_TRAVEL -#define DEFAULT_B_MAX_TRAVEL 200.0f -#endif - -#ifndef DEFAULT_C_STEPS_PER_MM -#define DEFAULT_C_STEPS_PER_MM 250.0f -#endif -#ifndef DEFAULT_C_MAX_RATE -#define DEFAULT_C_MAX_RATE 500.0f -#endif -#ifndef DEFAULT_C_ACCELERATION -#define DEFAULT_C_ACCELERATION DEFAULT_ACCELERATION -#endif -#ifndef DEFAULT_C_MAX_TRAVEL -#define DEFAULT_C_MAX_TRAVEL 200.0f -#endif - -#ifndef DEFAULT_U_STEPS_PER_MM -#define DEFAULT_U_STEPS_PER_MM 250.0f -#endif -#ifndef DEFAULT_U_MAX_RATE -#define DEFAULT_U_MAX_RATE 500.0f -#endif -#ifndef DEFAULT_U_ACCELERATION -#define DEFAULT_U_ACCELERATION DEFAULT_ACCELERATION -#endif -#ifndef DEFAULT_U_MAX_TRAVEL -#define DEFAULT_U_MAX_TRAVEL 200.0f -#endif - -#ifndef DEFAULT_V_STEPS_PER_MM -#define DEFAULT_V_STEPS_PER_MM 250.0f -#endif -#ifndef DEFAULT_V_MAX_RATE -#define DEFAULT_V_MAX_RATE 500.0f -#endif -#ifndef DEFAULT_V_ACCELERATION -#define DEFAULT_V_ACCELERATION DEFAULT_ACCELERATION -#endif -#ifndef DEFAULT_V_MAX_TRAVEL -#define DEFAULT_V_MAX_TRAVEL 200.0f -#endif - -#ifndef DEFAULT_G73_RETRACT -#define DEFAULT_G73_RETRACT 0.1f -#endif - -#ifdef DEFAULT_LASER_MODE -#undef DEFAULT_LASER_MODE -#define DEFAULT_LASER_MODE 1 -#else -#define DEFAULT_LASER_MODE 0 -#endif - -#ifdef DEFAULT_LATHE_MODE -#undef DEFAULT_LATHE_MODE -#define DEFAULT_LATHE_MODE 1 -#else -#define DEFAULT_LATHE_MODE 0 -#endif - -#if DEFAULT_LASER_MODE && DEFAULT_LATHE_MODE -#error "Cannot enable laser and lathe mode at the same time!" -#endif - -#ifndef DEFAULT_SPINDLE_PPR -#define DEFAULT_SPINDLE_PPR 0. -#endif - -#ifndef DEFAULT_SPINDLE_P_GAIN -#define DEFAULT_SPINDLE_P_GAIN 1.0f -#endif -#ifndef DEFAULT_SPINDLE_I_GAIN -#define DEFAULT_SPINDLE_I_GAIN 0.01f -#endif -#ifndef DEFAULT_SPINDLE_D_GAIN -#define DEFAULT_SPINDLE_D_GAIN 0.0f -#endif -#ifndef DEFAULT_SPINDLE_I_MAX -#define DEFAULT_SPINDLE_I_MAX 10.0f -#endif - -#ifdef DEFAULT_SLEEP_ENABLE -#undef DEFAULT_SLEEP_ENABLE -#define DEFAULT_SLEEP_ENABLE 1 -#else -#define DEFAULT_SLEEP_ENABLE 0 -#endif - -#ifdef DEFAULT_ENABLE_LASER_DURING_HOLD -#undef DEFAULT_ENABLE_LASER_DURING_HOLD -#define DEFAULT_ENABLE_LASER_DURING_HOLD 0 -#else -#define DEFAULT_ENABLE_LASER_DURING_HOLD 1 -#endif - - -#ifdef DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES -#undef DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES -#define DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES 1 -#else -#define DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES 0 -#endif - -#ifdef DEFAULT_NO_RESTORE_AFTER_FEED_HOLD -#define DEFAULT_RESTORE_AFTER_FEED_HOLD 0 -#undef DEFAULT_NO_RESTORE_AFTER_FEED_HOLD -#else -#define DEFAULT_RESTORE_AFTER_FEED_HOLD 1 -#endif - -#ifdef DEFAULT_FORCE_INITIALIZATION_ALARM -#undef DEFAULT_FORCE_INITIALIZATION_ALARM -#define DEFAULT_FORCE_INITIALIZATION_ALARM 1 -#else -#define DEFAULT_FORCE_INITIALIZATION_ALARM 0 -#endif - -#ifdef DEFAULT_CHECK_LIMITS_AT_INIT -#undef DEFAULT_CHECK_LIMITS_AT_INIT -#define DEFAULT_CHECK_LIMITS_AT_INIT 1 -#else -#define DEFAULT_CHECK_LIMITS_AT_INIT 0 -#endif - -#ifdef DEFAULT_HOMING_INIT_LOCK -#undef DEFAULT_HOMING_INIT_LOCK -#define DEFAULT_HOMING_INIT_LOCK 1 -#else -#define DEFAULT_HOMING_INIT_LOCK 0 -#endif - -#ifdef HOMING_SINGLE_AXIS_COMMANDS -#undef HOMING_SINGLE_AXIS_COMMANDS -#define HOMING_SINGLE_AXIS_COMMANDS 1 -#else -#define HOMING_SINGLE_AXIS_COMMANDS 0 -#endif - -#ifdef HOMING_FORCE_SET_ORIGIN -#undef HOMING_FORCE_SET_ORIGIN -#define HOMING_FORCE_SET_ORIGIN 1 -#else -#define HOMING_FORCE_SET_ORIGIN 0 -#endif - -#ifdef DEFAULT_HOMING_OVERRIDE_LOCKS -#undef DEFAULT_HOMING_OVERRIDE_LOCKS -#define DEFAULT_HOMING_OVERRIDE_LOCKS 1 -#else -#define DEFAULT_HOMING_OVERRIDE_LOCKS 0 -#endif - -#ifndef DUAL_AXIS_HOMING_FAIL_AXIS_LENGTH_PERCENT -#define DUAL_AXIS_HOMING_FAIL_AXIS_LENGTH_PERCENT 5.0f -#endif -#ifndef DUAL_AXIS_HOMING_FAIL_DISTANCE_MAX -#define DUAL_AXIS_HOMING_FAIL_DISTANCE_MAX 25.0f // Float (mm) -#endif -#ifndef DUAL_AXIS_HOMING_FAIL_DISTANCE_MIN -#define DUAL_AXIS_HOMING_FAIL_DISTANCE_MIN 2.5f // Float (mm) -#endif - -#ifdef DEFAULT_PARKING_ENABLE -#undef DEFAULT_PARKING_ENABLE -#define DEFAULT_PARKING_ENABLE 1 -#else -#define DEFAULT_PARKING_ENABLE 0 -#endif - -#ifndef DEFAULT_PARKING_AXIS -#define DEFAULT_PARKING_AXIS Z_AXIS -#endif -#ifndef DEFAULT_PARKING_TARGET -#define DEFAULT_PARKING_TARGET -5.0f -#endif -#ifndef DEFAULT_PARKING_RATE -#define DEFAULT_PARKING_RATE 500.0f -#endif -#ifndef DEFAULT_PARKING_PULLOUT_RATE -#define DEFAULT_PARKING_PULLOUT_RATE 100.0f -#endif -#ifndef DEFAULT_PARKING_PULLOUT_INCREMENT -#define DEFAULT_PARKING_PULLOUT_INCREMENT 5.0f -#endif - -#ifdef DEFAULT_ENABLE_PARKING_OVERRIDE_CONTROL -#undef DEFAULT_ENABLE_PARKING_OVERRIDE_CONTROL -#define DEFAULT_ENABLE_PARKING_OVERRIDE_CONTROL 1 -#else -#define DEFAULT_ENABLE_PARKING_OVERRIDE_CONTROL 0 -#endif - -#ifdef DEFAULT_DEACTIVATE_PARKING_UPON_INIT -#undef DEFAULT_DEACTIVATE_PARKING_UPON_INIT -#define DEFAULT_DEACTIVATE_PARKING_UPON_INIT 1 -#else -#define DEFAULT_DEACTIVATE_PARKING_UPON_INIT 0 -#endif - -#ifdef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES -#undef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES -#define ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES 1 -#else -#define ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES 0 -#endif - -#ifdef DEFAULT_NO_LEGACY_RTCOMMANDS -#undef DEFAULT_NO_LEGACY_RTCOMMANDS -#define DEFAULT_LEGACY_RTCOMMANDS 0 -#else -#define DEFAULT_LEGACY_RTCOMMANDS 1 -#endif - -#ifndef DEFAULT_TOOLCHANGE_MODE -#define DEFAULT_TOOLCHANGE_MODE 0 -#endif -#ifndef DEFAULT_TOOLCHANGE_PROBING_DISTANCE -#define DEFAULT_TOOLCHANGE_PROBING_DISTANCE 30 -#endif -#ifndef DEFAULT_TOOLCHANGE_FEED_RATE -#define DEFAULT_TOOLCHANGE_FEED_RATE 25.0f -#endif -#ifndef DEFAULT_TOOLCHANGE_SEEK_RATE -#define DEFAULT_TOOLCHANGE_SEEK_RATE 200.0f -#endif -#ifndef DEFAULT_TOOLCHANGE_PULLOFF_RATE -#define DEFAULT_TOOLCHANGE_PULLOFF_RATE 100.0f -#endif - -#ifdef DEFAULT_HOMING_ENABLE -#undef DEFAULT_HOMING_ENABLE -#define DEFAULT_HOMING_ENABLE 1 -#else -#define DEFAULT_HOMING_ENABLE 0 -#endif - -#ifdef DEFAULT_HOMING_ALLOW_MANUAL -#undef DEFAULT_HOMING_ALLOW_MANUAL -#define DEFAULT_HOMING_ALLOW_MANUAL 1 -#else -#define DEFAULT_HOMING_ALLOW_MANUAL 0 -#endif - -#ifndef DEFAULT_HOMING_DIR_MASK -#define DEFAULT_HOMING_DIR_MASK 0 -#endif -#ifndef DEFAULT_HOMING_FEED_RATE -#define DEFAULT_HOMING_FEED_RATE 25.0f -#endif -#ifndef DEFAULT_HOMING_SEEK_RATE -#define DEFAULT_HOMING_SEEK_RATE 500.0f -#endif -#ifndef DEFAULT_HOMING_DEBOUNCE_DELAY -#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 -#endif -#ifndef DEFAULT_HOMING_PULLOFF -#define DEFAULT_HOMING_PULLOFF 1.0f -#endif - -#ifndef DEFAULT_N_HOMING_LOCATE_CYCLE -#define DEFAULT_N_HOMING_LOCATE_CYCLE 1 -#endif - -#ifndef HOMING_CYCLE_0 -#define HOMING_CYCLE_0 (Z_AXIS_BIT) -#endif -#ifndef HOMING_CYCLE_1 -#define HOMING_CYCLE_1 (X_AXIS_BIT|Y_AXIS_BIT) -#endif -#ifndef HOMING_CYCLE_2 -#define HOMING_CYCLE_2 0 -#endif -#ifndef HOMING_CYCLE_3 -#define HOMING_CYCLE_3 0 -#endif -#ifndef HOMING_CYCLE_4 -#define HOMING_CYCLE_4 0 -#endif -#ifndef HOMING_CYCLE_5 -#define HOMING_CYCLE_5 0 -#endif - -#ifndef ST_DEENERGIZE_MASK -#define ST_DEENERGIZE_MASK 0 -#endif - -#ifndef ST_ROTATIONAL_MASK -#define ST_ROTATIONAL_MASK 0 -#endif - -#ifndef INVERT_ST_ENABLE_MASK -#if COMPATIBILITY_LEVEL <= 2 -#define INVERT_ST_ENABLE_MASK AXES_BITMASK -#else -#define INVERT_ST_ENABLE_MASK 0 -#endif -#endif - -#ifndef INVERT_LIMIT_BIT_MASK -#define INVERT_LIMIT_BIT_MASK 0 -#endif - -#ifndef INVERT_CONTROL_PIN_MASK -#define INVERT_CONTROL_PIN_MASK 0 -#endif - -#ifndef INVERT_SPINDLE_ENABLE_PIN -#define INVERT_SPINDLE_ENABLE_PIN 0 -#endif - -#ifndef INVERT_SPINDLE_CCW_PIN -#define INVERT_SPINDLE_CCW_PIN 0 -#endif - -#ifndef INVERT_SPINDLE_PWM_PIN -#define INVERT_SPINDLE_PWM_PIN 0 -#endif - -#ifndef DISABLE_LIMIT_BITS_PULL_UP_MASK -#define DISABLE_LIMIT_BITS_PULL_UP_MASK 0 -#endif - -#ifndef DISABLE_PROBE_BIT_PULL_UP -#define DISABLE_PROBE_BIT_PULL_UP 0 -#endif - -#ifndef DISABLE_CONTROL_PINS_PULL_UP_MASK -#define DISABLE_CONTROL_PINS_PULL_UP_MASK 0 -#endif - -#ifndef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES -#define ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES 0 -#endif - -#ifndef INVERT_COOLANT_FLOOD_PIN -#define INVERT_COOLANT_FLOOD_PIN 0 -#endif - -#ifndef INVERT_COOLANT_MIST_PIN -#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: - -#if DEFAULT_PARKING_ENABLE > 0 - #if DEFAULT_HOMING_FORCE_SET_ORIGIN > 0 - #error "HOMING_FORCE_SET_ORIGIN is not supported with PARKING_ENABLE at this time." - #endif -#endif - -#if DEFAULT_ENABLE_PARKING_OVERRIDE_CONTROL > 0 - #if DEFAULT_PARKING_ENABLE < 1 - #error "ENABLE_PARKING_OVERRIDE_CONTROL must be enabled with PARKING_ENABLE." - #endif -#endif - -// --------------------------------------------------------------------------------------- - -#endif diff --git a/driver_opts.h b/driver_opts.h index bb672d1..c16ebab 100644 --- a/driver_opts.h +++ b/driver_opts.h @@ -5,7 +5,7 @@ Part of grblHAL - Copyright (c) 2020-2022 Terje Io + Copyright (c) 2020-2023 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -75,6 +75,10 @@ #define N_AUTO_SQUARED (X_AUTO_SQUARE + Y_AUTO_SQUARE + Z_AUTO_SQUARE) #define N_ABC_MOTORS (N_ABC_AXIS + N_GANGED) +#ifndef PROBE_ENABLE +#define PROBE_ENABLE 1 +#endif + #ifndef USB_SERIAL_CDC #define USB_SERIAL_CDC 0 // for UART comms #endif @@ -86,6 +90,10 @@ #define KEYPAD_ENABLE 0 #endif +#ifndef MACROS_ENABLE +#define MACROS_ENABLE 0 +#endif + #ifndef MPG_ENABLE #define MPG_ENABLE 0 #endif @@ -214,8 +222,10 @@ #endif #endif -#ifndef DUAL_SPINDLE -#define DUAL_SPINDLE 0 +#if !VFD_SPINDLE || N_SPINDLE > 1 +#define DRIVER_SPINDLE_ENABLE 1 +#else +#define DRIVER_SPINDLE_ENABLE 0 #endif #ifndef QEI_ENABLE @@ -296,11 +306,13 @@ #undef WEBSOCKET_ENABLE #endif #define WEBSOCKET_ENABLE 1 -#ifdef SDCARD_ENABLE +#if defined(SDCARD_ENABLE) && SDCARD_ENABLE == 0 #undef SDCARD_ENABLE #endif +#ifndef SDCARD_ENABLE #define SDCARD_ENABLE 1 #endif +#endif #ifndef ETHERNET_ENABLE #define ETHERNET_ENABLE 0 diff --git a/errors.c b/errors.c index da48af8..d51323f 100644 --- a/errors.c +++ b/errors.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2021 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -112,3 +112,20 @@ error_details_t *errors_get_details (void) { return &details; } + +const char *errors_get_description (status_code_t id) +{ + uint_fast16_t n_errors; + const char *description = NULL; + error_details_t *details = grbl.on_get_errors(); + + do { + n_errors = details->n_errors; + do { + if(details->errors[--n_errors].id == id) + description = details->errors[n_errors].description; + } while(description == NULL && n_errors); + } while(description == NULL && (details = details->next)); + + return description; +} diff --git a/errors.h b/errors.h index e4777fd..15e2ed2 100644 --- a/errors.h +++ b/errors.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2021 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -124,6 +124,7 @@ typedef struct error_details { typedef error_details_t *(*on_get_errors_ptr)(void); error_details_t *errors_get_details (void); +const char *errors_get_description (status_code_t id); void errors_register (error_details_t *details); #endif diff --git a/gcode.c b/gcode.c index e49747f..2b226c6 100644 --- a/gcode.c +++ b/gcode.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -39,7 +39,7 @@ // arbitrary value, and some GUIs may require more. So we increased it based on a max safe // value when converting a float (7.2 digit precision)s to an integer. #define MAX_LINE_NUMBER 10000000 -#ifdef N_TOOLS +#if N_TOOLS #define MAX_TOOL_NUMBER N_TOOLS // Limited by max unsigned 8-bit value #else #define MAX_TOOL_NUMBER 4294967294 // Limited by max unsigned 32-bit value - 1 @@ -61,7 +61,7 @@ typedef union { uint32_t mask; struct { uint32_t G0 :1, //!< [G4,G10,G28,G28.1,G30,G30.1,G53,G92,G92.1] Non-modal - G1 :1, //!< [G0,G1,G2,G3,G33,G38.2,G38.3,G38.4,G38.5,G76,G80] Motion + G1 :1, //!< [G0,G1,G2,G3,G33,G33.1,G38.2,G38.3,G38.4,G38.5,G76,G80] Motion G2 :1, //!< [G17,G18,G19] Plane selection G3 :1, //!< [G90,G91] Distance mode G4 :1, //!< [G91.1] Arc IJK distance mode @@ -71,7 +71,7 @@ typedef union { G8 :1, //!< [G43,G43.1,G49] Tool length offset G10 :1, //!< [G98,G99] Return mode in canned cycles G11 :1, //!< [G50,G51] Scaling - G12 :1, //!< [G54,G55,G56,G57,G58,G59] Coordinate system selection + G12 :1, //!< [G54,G55,G56,G57,G58,G59,G59.1,G59.2,G59.3] Coordinate system selection G13 :1, //!< [G61] Control mode G14 :1, //!< [G96,G97] Spindle Speed Mode G15 :1, //!< [G7,G8] Lathe Diameter Mode @@ -109,7 +109,7 @@ typedef union { // Declare gc extern struct parser_state_t gc_state, *saved_state = NULL; -#ifdef N_TOOLS +#if N_TOOLS tool_data_t tool_table[N_TOOLS + 1]; #else tool_data_t tool_table; @@ -275,7 +275,7 @@ void gc_init (void) #if COMPATIBILITY_LEVEL > 1 memset(&gc_state, 0, sizeof(parser_state_t)); - #ifdef N_TOOLS + #if N_TOOLS gc_state.tool = &tool_table[0]; #else memset(&tool_table, 0, sizeof(tool_table)); @@ -284,7 +284,7 @@ void gc_init (void) #else if(sys.cold_start) { memset(&gc_state, 0, sizeof(parser_state_t)); - #ifdef N_TOOLS + #if N_TOOLS gc_state.tool = &tool_table[0]; #else memset(&tool_table, 0, sizeof(tool_table)); @@ -556,6 +556,7 @@ status_code_t gc_execute_block(char *block) .f = On, .h = On, .n = On, + .o = On, .t = On, .s = On }; @@ -621,7 +622,7 @@ status_code_t gc_execute_block(char *block) // Initialize command and value words and parser flags variables. modal_groups_t command_words = {0}; // Bitfield for tracking G and M command words. Also used for modal group violations. gc_parser_flags_t gc_parser_flags = {0}; // Parser flags for handling special cases. - static parameter_words_t user_words = {0}; // User M-code words "taken" + static parameter_words_t user_words = {0}; // User M-code words "taken" // Determine if the line is a jogging motion or a normal g-code block. if (block[0] == '$') { // NOTE: `$J=` already parsed when passed to this function. @@ -697,7 +698,7 @@ status_code_t gc_execute_block(char *block) continue; } - if((letter < 'A') || (letter > 'Z')) + if((letter < 'A' && letter != '$') || letter > 'Z') FAIL(Status_ExpectedCommandLetter); // [Expected word letter] if((status = read_parameter(block, &char_counter, &value)) != Status_OK) @@ -708,7 +709,7 @@ status_code_t gc_execute_block(char *block) #else - if((letter < 'A') || (letter > 'Z')) + if((letter < 'A' && letter != '$') || letter > 'Z') FAIL(Status_ExpectedCommandLetter); // [Expected word letter] if (!read_float(block, &char_counter, &value)) { @@ -784,13 +785,15 @@ status_code_t gc_execute_block(char *block) break; case 33: case 76: - if(!hal.spindle.get_data) - FAIL(Status_GcodeUnsupportedCommand); // [G33 or G76 not supported] + if(!hal.spindle.get_data || (mantissa != 0)) + FAIL(Status_GcodeUnsupportedCommand); // [G33, G33.1 or G76 not supported] if (axis_command) FAIL(Status_GcodeAxisCommandConflict); // [Axis word/command conflict] axis_command = AxisCommand_MotionMode; word_bit.modal_group.G1 = On; gc_block.modal.motion = (motion_mode_t)int_value; +// if(mantissa == 10) +// gc_block.modal.motion = MotionMode_RigidTapping; gc_block.modal.canned_cycle_active = false; break; @@ -883,7 +886,7 @@ status_code_t gc_execute_block(char *block) // NOTE: cannot find the NIST statement referenced above, changed to match LinuxCNC behaviour in build 20210513. if (int_value == 49) // G49 gc_block.modal.tool_offset_mode = ToolLengthOffset_Cancel; -#ifdef N_TOOLS +#if N_TOOLS else if (mantissa == 0) // G43 gc_block.modal.tool_offset_mode = ToolLengthOffset_Enable; else if (mantissa == 20) // G43.2 @@ -1118,7 +1121,7 @@ status_code_t gc_execute_block(char *block) switch(letter) { #ifdef A_AXIS - #ifndef AXIS_REMAP_ABC2UVW + #if !AXIS_REMAP_ABC2UVW case 'A': #else case 'U': @@ -1130,7 +1133,7 @@ status_code_t gc_execute_block(char *block) #endif #ifdef B_AXIS - #ifndef AXIS_REMAP_ABC2UVW + #if !AXIS_REMAP_ABC2UVW case 'B': #else case 'V': @@ -1142,7 +1145,7 @@ status_code_t gc_execute_block(char *block) #endif #ifdef C_AXIS - #ifndef AXIS_REMAP_ABC2UVW + #if !AXIS_REMAP_ABC2UVW case 'C': #else case 'W': @@ -1205,6 +1208,13 @@ status_code_t gc_execute_block(char *block) gc_block.values.n = (int32_t)truncf(value); break; + case 'O': + if (mantissa > 0) + FAIL(Status_GcodeCommandValueNotInteger); + word_bit.parameter.o = On; + gc_block.values.o = isnan(value) ? 0xFFFFFFFF : int_value; + break; + case 'P': // NOTE: For certain commands, P value must be an integer, but none of these commands are supported. word_bit.parameter.p = On; gc_block.values.p = value; @@ -1268,6 +1278,13 @@ status_code_t gc_execute_block(char *block) gc_block.values.xyz[Z_AXIS] = value; break; + case '$': + if(mantissa > 0) + FAIL(Status_GcodeCommandValueNotInteger); + word_bit.parameter.$ = On; + gc_block.values.$ = (int32_t)value; + break; + default: FAIL(Status_GcodeUnsupportedCommand); } // end parameter letter switch @@ -1422,6 +1439,14 @@ status_code_t gc_execute_block(char *block) // bit_false(gc_block.words,bit(Word_F)); // NOTE: Single-meaning value word. Set at end of error-checking. // [4. Set spindle speed ]: S or D is negative (done.) + if(gc_block.words.$) { + if(gc_block.values.$ < (command_words.M7 ? -1 : 0)) // if S word provided allow -1? + FAIL(command_words.M7 ? Status_GcodeValueOutOfRange: Status_NegativeValue); + if(gc_block.values.$ >= 1 /*spindle_get_count()*/) + FAIL(Status_GcodeValueOutOfRange); + gc_block.words.$ = Off; + } + if (command_words.G14) { if(gc_block.modal.spindle_rpm_mode == SpindleSpeedMode_CSS) { if (!gc_block.words.s) // TODO: add check for S0? @@ -1535,7 +1560,9 @@ status_code_t gc_execute_block(char *block) // bit_false(gc_block.words,bit(Word_T)); // NOTE: Single-meaning value word. Set at end of error-checking. // [6. Change tool ]: N/A - // [7. Spindle control ]: N/A + + // [7. Spindle control ]: N/A - spindle id validation taken care of above in step 4. + // [8. Coolant control ]: N/A // [9. Override control ]: @@ -1711,7 +1738,7 @@ status_code_t gc_execute_block(char *block) // [G43.2 Errors]: Tool number not in the tool table, if (command_words.G8) { // Indicates called in block. -#ifdef TOOL_LENGTH_OFFSET_AXIS +#if TOOL_LENGTH_OFFSET_AXIS >= 0 // NOTE: Although not explicitly stated so, G43.1 should be applied to only one valid // axis that is configured (in config.h). There should be an error if the configured axis // is absent or if any of the other axis words are present. @@ -1727,7 +1754,7 @@ status_code_t gc_execute_block(char *block) if (!axis_words.mask) FAIL(Status_GcodeG43DynamicAxisError); break; -#ifdef N_TOOLS +#if N_TOOLS case ToolLengthOffset_Enable: if (gc_block.words.h) { if(gc_block.values.h > MAX_TOOL_NUMBER) @@ -1836,7 +1863,7 @@ status_code_t gc_execute_block(char *block) } while(idx); break; -#ifdef N_TOOLS +#if N_TOOLS case 1: case 10: case 11:; if(p_value == 0 || p_value > MAX_TOOL_NUMBER) FAIL(Status_GcodeIllegalToolTableEntry); // [Greater than MAX_TOOL_NUMBER] @@ -2618,7 +2645,7 @@ status_code_t gc_execute_block(char *block) // If M6 not available or M61 commanded set new tool immediately if(set_tool || settings.tool_change.mode == ToolChange_Ignore || !(hal.stream.suspend_read || hal.tool.change)) { -#ifdef N_TOOLS +#if N_TOOLS gc_state.tool = &tool_table[gc_state.tool_pending]; #else gc_state.tool->tool = gc_state.tool_pending; @@ -2628,7 +2655,7 @@ status_code_t gc_execute_block(char *block) // Prepare tool carousel when available if(hal.tool.select) { -#ifdef N_TOOLS +#if N_TOOLS hal.tool.select(&tool_table[gc_state.tool_pending], !set_tool); #else hal.tool.select(gc_state.tool, !set_tool); @@ -2679,7 +2706,7 @@ status_code_t gc_execute_block(char *block) plan_data.message = NULL; } -#ifdef N_TOOLS +#if N_TOOLS gc_state.tool = &tool_table[gc_state.tool_pending]; #else gc_state.tool->tool = gc_state.tool_pending; @@ -2782,7 +2809,7 @@ status_code_t gc_execute_block(char *block) tlo_changed |= gc_state.tool_length_offset[idx] != 0.0f; gc_state.tool_length_offset[idx] = 0.0f; break; -#ifdef N_TOOLS +#if N_TOOLS case ToolLengthOffset_Enable: // G43 if (gc_state.tool_length_offset[idx] != tool_table[gc_block.values.h].offset[idx]) { tlo_changed = true; diff --git a/gcode.h b/gcode.h index 8f3a03c..6625014 100644 --- a/gcode.h +++ b/gcode.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -67,6 +67,7 @@ typedef enum { MotionMode_CubicSpline = 5, //!< 5 - G5 MotionMode_QuadraticSpline = 51, //!< 51 - G5.1 MotionMode_SpindleSynchronized = 33, //!< 33 - G33 + MotionMode_RigidTapping = 331, //!< 331 - G33.1 MotionMode_DrillChipBreak = 73, //!< 73 - G73 MotionMode_Threading = 76, //!< 76 - G76 MotionMode_CannedCycle81 = 81, //!< 81 - G81 @@ -212,18 +213,21 @@ typedef enum { OpenPNP_GetCurrentPosition = 114, //!< 114 - M114 OpenPNP_FirmwareInfo = 115, //!< 115 - M115 Trinamic_DebugReport = 122, //!< 122 - M122, Marlin format + Trinamic_ReadRegister = 123, //!< 123 - M123, + Trinamic_WriteRegister = 124, //!< 124 - M124, LaserPPI_Enable = 126, //!< 126 - M126 LaserPPI_Rate = 127, //!< 127 - M127 LaserPPI_PulseLength = 128, //!< 128 - M128 OpenPNP_SetAcceleration = 204, //!< 204 - M204 OpenPNP_FinishMoves = 400, //!< 400 - M400 OpenPNP_SettingsReset = 502, //!< 502 - M502 - Trinamic_ModeToggle = 569, //!< 569 - M122, Marlin format - Trinamic_StepperCurrent = 906, //!< 906 - M122, Marlin format - Trinamic_ReportPrewarnFlags = 911, //!< 911 - M122, Marlin format - Trinamic_ClearPrewarnFlags = 912, //!< 912 - M122, Marlin format - Trinamic_HybridThreshold = 913, //!< 913 - M122, Marlin format - Trinamic_HomingSensitivity = 914, //!< 914 - M122, Marlin format + Trinamic_ModeToggle = 569, //!< 569 - M569, Marlin format + Trinamic_StepperCurrent = 906, //!< 906 - M906, Marlin format + Trinamic_ReportPrewarnFlags = 911, //!< 911 - M911, Marlin format + Trinamic_ClearPrewarnFlags = 912, //!< 912 - M912, Marlin format + Trinamic_HybridThreshold = 913, //!< 913 - M913, Marlin format + Trinamic_HomingSensitivity = 914, //!< 914 - M914, Marlin format + Trinamic_ChopperTiming = 919, //!< 919 - M919, Marlin format Spindle_Select = UserMCode_Generic4 //!< Value to be assigned later! } user_mcode_t; @@ -262,7 +266,7 @@ typedef enum { GCProbe_Abort = GCUpdatePos_None, //!< 2 GCProbe_FailInit = GCUpdatePos_None, //!< 2 GCProbe_FailEnd = GCUpdatePos_Target, //!< 0 - #ifdef SET_CHECK_MODE_PROBE_TO_START + #if SET_CHECK_MODE_PROBE_TO_START GCProbe_CheckMode = GCUpdatePos_None //!< 2 #else GCProbe_CheckMode = GCUpdatePos_Target //!< 0 @@ -357,7 +361,9 @@ typedef struct { float s; //!< Spindle speed - single-meaning word float xyz[N_AXIS]; //!< X,Y,Z (and A,B,C,U,V when enabled) translational axes coord_system_t coord_data; //!< Coordinate data + int32_t $; //!< Spindle id - single-meaning word int32_t n; //!< Line number - single-meaning word + uint32_t o; //!< Subroutine identifier - single-meaning word (not used by the core) uint32_t h; //!< Tool number - single-meaning word uint32_t t; //!< Tool selection uint8_t l; //!< G10 or canned cycles parameters @@ -368,7 +374,8 @@ typedef union { uint32_t mask; //!< All flags as a bitmap. uint32_t value; //!< Synonymous with \a mask. struct { - uint32_t e :1, //!< Analog port number for M66 - M68. + uint32_t $ :1, //!< Spindle id + e :1, //!< Analog port number for M66 - M68. f :1, //!< Feedrate. h :1, //!< Tool length offset index. i :1, //!< X-axis offset for arcs @@ -376,6 +383,7 @@ typedef union { k :1, //!< Z-axis offset for arcs l :1, //!< Number of repetitions in canned cycles, wait mode for M66. n :1, //!< Line number. + o :1, //!< Subroutine identifier. p :1, //!< Dwell time for G4 or in canned cycles, port number for M62 - M66. r :1, //!< Arc radius, canned cycle retract level. s :1, //!< Spindle speed. @@ -513,7 +521,7 @@ typedef struct { } scale_factor_t; extern parser_state_t gc_state; -#ifdef N_TOOLS +#if N_TOOLS extern tool_data_t tool_table[N_TOOLS + 1]; #else extern tool_data_t tool_table; @@ -534,6 +542,7 @@ typedef struct { parameter_words_t words; //!< Bitfield for tracking found parameter values. output_command_t output_command; //!< Details about M62-M68 output command to execute if present in block. uint32_t arc_turns; // + int32_t spindle_id; //!< Spindle to control, -1 for all } parser_block_t; // Initialize the parser diff --git a/grbl.h b/grbl.h index e2b475a..11920eb 100644 --- a/grbl.h +++ b/grbl.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2015-2016 Sungeun K. Jeon for Gnea Research LLC Grbl is free software: you can redistribute it and/or modify @@ -38,7 +38,7 @@ #else #define GRBL_VERSION "1.1f" #endif -#define GRBL_BUILD 20221115 +#define GRBL_BUILD 20230125 #define GRBL_URL "https://github.com/grblHAL" @@ -70,30 +70,10 @@ #define PROGMEM #endif -#if (defined(COREXY) || defined(WALL_PLOTTER) || defined(MASLOW_ROUTER)) && !defined(KINEMATICS_API) +#if (COREXY || WALL_PLOTTER || MASLOW_ROUTER) && !defined(KINEMATICS_API) #define KINEMATICS_API #endif -#ifndef CHECK_MODE_DELAY -#define CHECK_MODE_DELAY 0 // ms -#endif - -#ifndef SAFETY_DOOR_SPINDLE_DELAY -#define SAFETY_DOOR_SPINDLE_DELAY 4.0f // Float (seconds) -#endif - -#ifndef SAFETY_DOOR_COOLANT_DELAY -#define SAFETY_DOOR_COOLANT_DELAY 1.0f // Float (seconds) -#endif - -#ifndef SLEEP_DURATION -#define SLEEP_DURATION 5.0f // Number of minutes before sleep mode is entered. -#endif - -#ifndef BUFFER_NVSDATA_DISABLE -#define BUFFER_NVSDATA -#endif - // The following symbols are default values that are unlikely to be changed // Do not change unless you know what you are doing! @@ -127,18 +107,19 @@ #define CMD_STATUS_REPORT_ALL 0x87 #define CMD_OPTIONAL_STOP_TOGGLE 0x88 #define CMD_SINGLE_BLOCK_TOGGLE 0x89 -#define CMD_OVERRIDE_FAN0_TOGGLE 0x8A // Toggle Fan 0 on/off, not implemented by the core. -#define CMD_MPG_MODE_TOGGLE 0x8B // Toggle MPG mode on/off, not implemented by the core. -#define CMD_OVERRIDE_FEED_RESET 0x90 // Restores feed override value to 100%. +#define CMD_OVERRIDE_FAN0_TOGGLE 0x8A // Toggle Fan 0 on/off, not implemented by the core. +#define CMD_MPG_MODE_TOGGLE 0x8B // Toggle MPG mode on/off, not implemented by the core. +#define CMD_AUTO_REPORTING_TOGGLE 0x8C // Toggle auto real time reporting if configured. +#define CMD_OVERRIDE_FEED_RESET 0x90 // Restores feed override value to 100%. #define CMD_OVERRIDE_FEED_COARSE_PLUS 0x91 #define CMD_OVERRIDE_FEED_COARSE_MINUS 0x92 #define CMD_OVERRIDE_FEED_FINE_PLUS 0x93 #define CMD_OVERRIDE_FEED_FINE_MINUS 0x94 -#define CMD_OVERRIDE_RAPID_RESET 0x95 // Restores rapid override value to 100%. +#define CMD_OVERRIDE_RAPID_RESET 0x95 // Restores rapid override value to 100%. #define CMD_OVERRIDE_RAPID_MEDIUM 0x96 #define CMD_OVERRIDE_RAPID_LOW 0x97 // #define CMD_OVERRIDE_RAPID_EXTRA_LOW 0x98 // *NOT SUPPORTED* -#define CMD_OVERRIDE_SPINDLE_RESET 0x99 // Restores spindle override value to 100%. +#define CMD_OVERRIDE_SPINDLE_RESET 0x99 // Restores spindle override value to 100%. #define CMD_OVERRIDE_SPINDLE_COARSE_PLUS 0x9A #define CMD_OVERRIDE_SPINDLE_COARSE_MINUS 0x9B #define CMD_OVERRIDE_SPINDLE_FINE_PLUS 0x9C @@ -200,29 +181,6 @@ #define SPINDLE_OVERRIDE_COARSE_INCREMENT 10 // (1-99). Usually 10%. #define SPINDLE_OVERRIDE_FINE_INCREMENT 1 // (1-99). Usually 1%. -// Some status report data isn't necessary for realtime, only intermittently, because the values don't -// change often. The following macros configures how many times a status report needs to be called before -// the associated data is refreshed and included in the status report. However, if one of these value -// changes, Grbl will automatically include this data in the next status report, regardless of what the -// count is at the time. This helps reduce the communication overhead involved with high frequency reporting -// and aggressive streaming. There is also a busy and an idle refresh count, which sets up Grbl to send -// refreshes more often when its not doing anything important. With a good GUI, this data doesn't need -// to be refreshed very often, on the order of a several seconds. -// NOTE: WCO refresh must be 2 or greater. OVERRIDE refresh must be 1 or greater. -//#define REPORT_OVERRIDE_REFRESH_BUSY_COUNT 20 // (1-255) -//#define REPORT_OVERRIDE_REFRESH_IDLE_COUNT 10 // (1-255) Must be less than or equal to the busy count -//#define REPORT_WCO_REFRESH_BUSY_COUNT 30 // (2-255) -//#define REPORT_WCO_REFRESH_IDLE_COUNT 10 // (2-255) Must be less than or equal to the busy count - -// The temporal resolution of the acceleration management subsystem. A higher number gives smoother -// acceleration, particularly noticeable on machines that run at very high feedrates, but may negatively -// impact performance. The correct value for this parameter is machine dependent, so it's advised to -// set this only as high as needed. Approximate successful values can widely range from 50 to 200 or more. -// NOTE: Changing this value also changes the execution time of a segment in the step segment buffer. -// When increasing this value, this stores less overall time in the segment buffer and vice versa. Make -// certain the step segment buffer is increased/decreased to account for these changes. -//#define ACCELERATION_TICKS_PER_SECOND 100 - // Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies, // smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step // frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible @@ -248,26 +206,11 @@ #endif #endif -// Sets the maximum step rate allowed to be written as a Grbl setting. This option enables an error -// check in the settings module to prevent settings values that will exceed this limitation. The maximum -// step rate is strictly limited by the CPU speed and will change if something other than an AVR running -// at 16MHz is used. -// NOTE: For now disabled, will enable if flash space permits. -// #define MAX_STEP_RATE_HZ 30000 // Hz - -// With this enabled, Grbl sends back an echo of the line it has received, which has been pre-parsed (spaces -// removed, capitalized letters, no comments) and is to be immediately executed by Grbl. Echoes will not be -// sent upon a line buffer overflow, but should for all normal lines sent to Grbl. For example, if a user -// sendss the line 'g1 x1.032 y2.45 (test comment)', Grbl will echo back in the form '[echo: G1X1.032Y2.45]'. -// NOTE: Only use this for debugging purposes!! When echoing, this takes up valuable resources and can effect -// performance. If absolutely needed for normal operation, the serial write buffer should be greatly increased -// to help minimize transmission waiting within the serial write protocol. -// #define REPORT_ECHO_LINE_RECEIVED // Default disabled. Uncomment to enable. - // Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with // the selected axis with the tool oriented toward the negative direction. In other words, a positive // tool length offset value is subtracted from the current location. -#if COMPATIBILITY_LEVEL > 2 && defined(TOOL_LENGTH_OFFSET_AXIS) == 0 +#if COMPATIBILITY_LEVEL > 2 && TOOL_LENGTH_OFFSET_AXIS == -1 +#undef TOOL_LENGTH_OFFSET_AXIS #define TOOL_LENGTH_OFFSET_AXIS Z_AXIS // Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS. #endif diff --git a/grbllib.c b/grbllib.c index f01b588..02b7cff 100644 --- a/grbllib.c +++ b/grbllib.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2015 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -35,18 +35,18 @@ #include "state_machine.h" #include "nvs_buffer.h" #include "stream.h" -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION #include "motion_control.h" #endif #ifdef KINEMATICS_API #include "kinematics.h" #endif -#ifdef COREXY +#if COREXY #include "corexy.h" #endif -#ifdef WALL_PLOTTER +#if WALL_PLOTTER #include "wall_plotter.h" #endif @@ -68,6 +68,7 @@ struct system sys = {0}; //!< System global variable structure. grbl_t grbl; grbl_hal_t hal; static driver_startup_t driver = { .ok = 0xFF }; +static on_execute_realtime_ptr on_execute_realtime; #ifdef KINEMATICS_API kinematics_t kinematics; @@ -95,6 +96,23 @@ static void report_driver_error (sys_state_t state) report_message(msg, Message_Plain); } +static void auto_realtime_report (sys_state_t state) +{ + static uint32_t ms = 0; + + if(sys.flags.auto_reporting) { + + uint32_t t = hal.get_elapsed_ticks(); + + if(t - ms >= settings.report_interval) { + ms = t; + system_set_exec_state_flag(EXEC_STATUS_REPORT); + } + } + + on_execute_realtime(state); +} + // main entry point int grbl_enter (void) @@ -131,7 +149,7 @@ int grbl_enter (void) sys.cold_start = true; -#ifdef BUFFER_NVSDATA +#if NVSDATA_BUFFER_ENABLE nvs_buffer_alloc(); // Allocate memory block for NVS buffer #endif @@ -156,7 +174,7 @@ int grbl_enter (void) hal.signals_cap.safety_door_ajar = Off; #endif - #ifdef BUFFER_NVSDATA + #if NVSDATA_BUFFER_ENABLE nvs_buffer_init(); #endif settings_init(); // Load settings from non-volatile storage @@ -208,15 +226,15 @@ int grbl_enter (void) if(hal.get_position) hal.get_position(&sys.position); // TODO: restore on abort when returns true? -#ifdef COREXY +#if COREXY corexy_init(); #endif -#ifdef WALL_PLOTTER +#if WALL_PLOTTER wall_plotter_init(); #endif -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION mc_backlash_init((axes_signals_t){AXES_BITMASK}); #endif @@ -226,6 +244,11 @@ int grbl_enter (void) if(hal.homing.get_state == NULL) hal.homing.get_state = hal.limits.get_state; + if(settings.report_interval) { + on_execute_realtime = grbl.on_execute_realtime; + grbl.on_execute_realtime = auto_realtime_report; + } + // Grbl initialization loop upon power-up or a system abort. For the latter, all processes // will return to this loop to be cleanly re-initialized. while(looping) { @@ -242,6 +265,7 @@ int grbl_enter (void) sys.override.feed_rate = DEFAULT_FEED_OVERRIDE; // Set to 100% sys.override.rapid_rate = DEFAULT_RAPID_OVERRIDE; // Set to 100% sys.override.spindle_rpm = DEFAULT_SPINDLE_RPM_OVERRIDE; // Set to 100% + sys.flags.auto_reporting = settings.report_interval != 0; if(settings.parking.flags.enabled) sys.override.control.parking_disable = settings.parking.flags.deactivate_upon_init; diff --git a/hal.h b/hal.h index 1b3372a..34ed45d 100644 --- a/hal.h +++ b/hal.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2016-2022 Terje Io + Copyright (c) 2016-2023 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -96,7 +96,7 @@ typedef void (*register_periph_pin_ptr)(const periph_pin_t *pin); /*! \brief Pointer to function for setting pin description for a peripheral pin. \param function as #pin_function_t enum. \param group as #pin_group_t enum. -\param s pointer to null terminated description string. +\param description pointer to null terminated description string. */ typedef void (*set_periph_pin_description_ptr)(const pin_function_t function, const pin_group_t group, const char *description); @@ -157,7 +157,7 @@ typedef void (*limits_enable_ptr)(bool on, bool homing); typedef limit_signals_t (*limits_get_state_ptr)(void); /*! \brief Pointer to callback function for reporting limit switches events (interrupts). _Set by the core on startup._ -\param switch states in a limit_signals_t struct. +\param state input pin states in a limit_signals_t struct. */ typedef void (*limit_interrupt_callback_ptr)(limit_signals_t state); @@ -189,7 +189,7 @@ typedef struct { typedef control_signals_t (*control_signals_get_state_ptr)(void); /*! \brief Pointer to callback function for reporting control switches events (interrupts). _Set by the core on startup._ -\param switch states in a control_signals_t struct. +\param signals input pin states in a control_signals_t struct. */ typedef void (*control_signals_callback_ptr)(control_signals_t signals); @@ -255,7 +255,7 @@ typedef void (*stepper_enable_ptr)(axes_signals_t enable); Used by auto squaring functionality where two motors are employed for one or more axes. -\param enable a \a axes_signals_t union containing separate flags for each motor to enable/disable. +\param axes a \a axes_signals_t union containing separate flags for each motor to enable/disable. \param mode a \a #squaring_mode_t enum for which side to enable/disable. */ typedef void (*stepper_disable_motors_ptr)(axes_signals_t axes, squaring_mode_t mode); @@ -290,7 +290,7 @@ typedef void (*stepper_pulse_start_ptr)(stepper_t *stepper); This is for an experimental implementation of plasma Torch Height Control (THC) and may be removed and/or changed. \param step_outbits a \a #axes_signals_t union containing the axes to output a step signal for. -\param step_outbits a \a #axes_signals_t union containing the axes to output a direction signal for. +\param dir_outbits a \a #axes_signals_t union containing the axes to output a direction signal for. __NOTE:__ this function will be called from an interrupt context */ diff --git a/ioports.h b/ioports.h index f95603c..98e0cd2 100644 --- a/ioports.h +++ b/ioports.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2021 Terje Io + Copyright (c) 2021-2023 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +46,7 @@ typedef bool (*analog_out_ptr)(uint8_t port, float value); /*! \brief Pointer to function for reading a digital or analog input. -__NOTE:__ The latest value read is stored in \ref #sys \ref #sys#var5399. +__NOTE:__ The latest value read is stored in \ref #sys sys.var5399. \param type as an \a #io_port_type_t enum value. \param port port number. @@ -76,6 +76,7 @@ typedef xbar_t *(*get_pin_info_ptr)(io_port_type_t type, io_port_direction_t dir \param type as an \a #io_port_type_t enum value. \param dir as an \a #io_port_direction_t enum value. \param port port number. +\param description description of the pin function. \returns true if successful, false if not. */ typedef bool (*claim_port_ptr)(io_port_type_t type, io_port_direction_t dir, uint8_t *port, const char *description); diff --git a/machine_limits.c b/machine_limits.c index 8428cbd..022451b 100644 --- a/machine_limits.c +++ b/machine_limits.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -36,15 +36,7 @@ #include "kinematics.h" #endif -#include "defaults.h" - -// Homing axis search distance multiplier. Computed by this value times the cycle travel. -#ifndef HOMING_AXIS_SEARCH_SCALAR - #define HOMING_AXIS_SEARCH_SCALAR 1.5f // Must be > 1 to ensure limit switch will be engaged. -#endif -#ifndef HOMING_AXIS_LOCATE_SCALAR - #define HOMING_AXIS_LOCATE_SCALAR 5.0f // Must be > 1 to ensure limit switch is cleared. -#endif +#include "config.h" // This is the Limit Pin Change Interrupt, which handles the hard limit feature. A bouncing // limit switch can cause a lot of problems, like false readings and multiple interrupt calls. @@ -104,7 +96,7 @@ ISR_CODE void ISR_FUNC(limit_interrupt_handler)(limit_signals_t state) // DEFAUL if (!(state_get() & (STATE_ALARM|STATE_ESTOP)) && !sys.rt_exec_alarm) { - #ifdef HARD_LIMIT_FORCE_STATE_CHECK + #if HARD_LIMIT_FORCE_STATE_CHECK // Check limit pin state. if (limit_signals_merge(state).value) { mc_reset(); // Initiate system kill. @@ -152,7 +144,7 @@ static bool limits_pull_off (axes_signals_t axis, float distance) plan_line_data_t plan_data = { .condition.system_motion = On, .condition.no_feed_override = On, - .line_number = HOMING_CYCLE_LINE_NUMBER + .line_number = DEFAULT_HOMING_CYCLE_LINE_NUMBER }; system_convert_array_steps_to_mpos(target.values, sys.position); @@ -257,7 +249,7 @@ static bool limits_homing_cycle (axes_signals_t cycle, axes_signals_t auto_squar memset(&plan_data, 0, sizeof(plan_line_data_t)); plan_data.condition.system_motion = On; plan_data.condition.no_feed_override = On; - plan_data.line_number = HOMING_CYCLE_LINE_NUMBER; + plan_data.line_number = DEFAULT_HOMING_CYCLE_LINE_NUMBER; memcpy(&plan_data.spindle, &gc_state.spindle, sizeof(spindle_t)); plan_data.condition.spindle = gc_state.modal.spindle; plan_data.condition.coolant = gc_state.modal.coolant; @@ -478,7 +470,7 @@ static bool limits_homing_cycle (axes_signals_t cycle, axes_signals_t auto_squar limits_set_machine_positions(cycle, true); #endif -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION mc_backlash_init(cycle); #endif sys.step_control.flags = 0; // Return step control to normal operation. diff --git a/maslow.c b/maslow.c index 975d0cf..70ea8ea 100644 --- a/maslow.c +++ b/maslow.c @@ -28,7 +28,7 @@ #include "grbl.h" -#ifdef MASLOW_ROUTER +#if MASLOW_ROUTER #include diff --git a/motion_control.c b/motion_control.c index ed0eaf1..6a934e8 100644 --- a/motion_control.c +++ b/motion_control.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -40,24 +40,7 @@ #include "kinematics.h" #endif -#ifndef N_ARC_CORRECTION -#define N_ARC_CORRECTION 12 -#endif -#ifndef ARC_ANGULAR_TRAVEL_EPSILON // Float (radians) -#define ARC_ANGULAR_TRAVEL_EPSILON 5E-7f // Float (radians) -#endif - -#ifndef BEZIER_MIN_STEP -#define BEZIER_MIN_STEP 0.002f -#endif -#ifndef BEZIER_MAX_STEP -#define BEZIER_MAX_STEP 0.1f -#endif -#ifndef BEZIER_SIGMA -#define BEZIER_SIGMA 0.1f -#endif - -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION static float target_prev[N_AXIS] = {0}; static axes_signals_t dir_negative = {0}, backlash_enabled = {0}; @@ -127,7 +110,7 @@ bool mc_line (float *target, plan_line_data_t *pl_data) while(kinematics.segment_line(target, NULL, pl_data, false)) { #endif -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(backlash_enabled.mask) { @@ -190,11 +173,11 @@ bool mc_line (float *target, plan_line_data_t *pl_data) break; } while(true); - // Plan and queue motion into planner buffer - // bool plan_status; // Not used in normal operation. + // Plan and queue motion into planner buffer. + // While in M3 laser mode also set spindle state and force a buffer sync + // if there is a coincident position passed. if(!plan_buffer_line(target, pl_data) && sys.mode == Mode_Laser && pl_data->condition.spindle.on && !pl_data->condition.spindle.ccw) { - // Correctly set spindle state, if there is a coincident position passed. - // Forces a buffer sync while in M3 laser mode only. + protocol_buffer_synchronize(); hal.spindle.set_state(pl_data->condition.spindle, pl_data->spindle.rpm); } @@ -1041,7 +1024,7 @@ gc_probe_t mc_probe_cycle (float *target, plan_line_data_t *pl_data, gc_parser_f st_reset(); // Reset step segment buffer. plan_reset(); // Reset planner buffer. Zero planner positions. Ensure probing motion is cleared. plan_sync_position(); // Sync planner position to current machine position. -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION mc_sync_backlash_position(); #endif diff --git a/motion_control.h b/motion_control.h index fd837e6..aed5483 100644 --- a/motion_control.h +++ b/motion_control.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -25,13 +25,13 @@ #define _MOTION_CONTROL_H_ // System motion commands must have a line number of zero. -#define HOMING_CYCLE_LINE_NUMBER 0 +#define DEFAULT_HOMING_CYCLE_LINE_NUMBER 0 #define PARKING_MOTION_LINE_NUMBER 0 -#define HOMING_CYCLE_ALL 0 // Must be zero. -#define HOMING_CYCLE_X bit(X_AXIS) -#define HOMING_CYCLE_Y bit(Y_AXIS) -#define HOMING_CYCLE_Z bit(Z_AXIS) +#define DEFAULT_HOMING_CYCLE_ALL 0 // Must be zero. +#define DEFAULT_HOMING_CYCLE_X bit(X_AXIS) +#define DEFAULT_HOMING_CYCLE_Y bit(Y_AXIS) +#define DEFAULT_HOMING_CYCLE_Z bit(Z_AXIS) // Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second // unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in @@ -74,7 +74,7 @@ void mc_cubic_b_spline(float *target, plan_line_data_t *pl_data, float *position // Performs system reset. If in motion state, kills all motion and sets system alarm. void mc_reset (void); -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION void mc_backlash_init (axes_signals_t axes); void mc_sync_backlash_position (void); #endif diff --git a/nuts_bolts.c b/nuts_bolts.c index ceab01e..a443b32 100644 --- a/nuts_bolts.c +++ b/nuts_bolts.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -64,21 +64,21 @@ char const *const axis_letter[N_AXIS] = { "Y", "Z" #if N_AXIS > 3 - #ifndef AXIS_REMAP_ABC2UVW + #if !AXIS_REMAP_ABC2UVW ,"A" #else ,"U" #endif #endif #if N_AXIS > 4 - #ifndef AXIS_REMAP_ABC2UVW + #if !AXIS_REMAP_ABC2UVW ,"B" #else ,"V" #endif #endif #if N_AXIS > 5 - #ifndef AXIS_REMAP_ABC2UVW + #if !AXIS_REMAP_ABC2UVW ,"C" #else ,"W" @@ -166,6 +166,58 @@ char *ftoa (float n, uint8_t decimal_places) return bptr; } +// Extracts an unsigned integer value from a string. +status_code_t read_uint (char *line, uint_fast8_t *char_counter, uint32_t *uint_ptr) +{ + char *ptr = line + *char_counter; + int_fast8_t exp = 0; + uint_fast8_t ndigit = 0, c; + uint32_t intval = 0; + bool isdecimal = false, ok = false; + + // Grab first character and increment pointer. No spaces assumed in line. + c = *ptr++; + + if (c == '-') + return Status_NegativeValue; + + // Skip initial sign character + if (c == '+') + c = *ptr++; + + // Extract number into fast integer. Track decimal in terms of exponent value. + while(c) { + c -= '0'; + if (c <= 9) { + ok = true; + if(!isdecimal && (c != 0 || intval)) + ndigit++; + if (isdecimal && c != 0) + return Status_GcodeCommandValueNotInteger; + + if ((ndigit <= 9 || c <= 4) && intval <= 429496729) { + intval = (((intval << 2) + intval) << 1) + c; // intval * 10 + c + } else if (!isdecimal) + exp++; // Drop overflow digits + } else if (c == (uint_fast8_t)('.' - '0') && !isdecimal) + isdecimal = true; + else + break; + + c = *ptr++; + } + + // Return if no digits have been read. + + if (!ok) + return Status_BadNumberFormat; + + *uint_ptr = intval; // Assign value. + *char_counter = ptr - line - 1; // Set char_counter to next statement + + return Status_OK; +} + // Extracts a floating point value from a string. The following code is based loosely on // the avr-libc strtod() function by Michael Stumpf and Dmitry Xmelkov and many freely // available conversion method examples, but has been highly optimized for Grbl. For known @@ -179,12 +231,12 @@ bool read_float (char *line, uint_fast8_t *char_counter, float *float_ptr) int_fast8_t exp = 0; uint_fast8_t ndigit = 0, c; uint32_t intval = 0; - bool isnegative, isdecimal = false; + bool isnegative, isdecimal = false, ok = false; // Grab first character and increment pointer. No spaces assumed in line. c = *ptr++; - // Capture initial positive/minus character + // Capture initial sign character if ((isnegative = (c == '-')) || c == '+') c = *ptr++; @@ -192,11 +244,13 @@ bool read_float (char *line, uint_fast8_t *char_counter, float *float_ptr) while(c) { c -= '0'; if (c <= 9) { - ndigit++; + ok = true; + if(c != 0 || intval) + ndigit++; if (ndigit <= MAX_INT_DIGITS) { if (isdecimal) exp--; - intval = (((intval << 2) + intval) << 1) + c; // intval*10 + c + intval = (((intval << 2) + intval) << 1) + c; // intval * 10 + c } else if (!isdecimal) exp++; // Drop overflow digits } else if (c == (uint_fast8_t)('.' - '0') && !isdecimal) @@ -208,7 +262,7 @@ bool read_float (char *line, uint_fast8_t *char_counter, float *float_ptr) } // Return if no digits have been read. - if (!ndigit) + if (!ok) return false; // Convert integer into floating point. diff --git a/nuts_bolts.h b/nuts_bolts.h index bc144b1..5d94746 100644 --- a/nuts_bolts.h +++ b/nuts_bolts.h @@ -25,6 +25,7 @@ #define _NUTS_BOLTS_H_ #include "grbl.h" +#include "errors.h" #ifndef true #define false 0 @@ -164,7 +165,7 @@ typedef enum { #define MM_PER_INCH (25.40f) #define INCH_PER_MM (0.0393701f) -#define MAX_INT_DIGITS 8 // Maximum number of digits in int32 (and float) +#define MAX_INT_DIGITS 9 // Maximum number of digits in int32 (and float) #define STRLEN_COORDVALUE (MAX_INT_DIGITS + N_DECIMAL_COORDVALUE_INCH + 1) // 8.4 format - excluding terminating null // Useful macros @@ -200,6 +201,8 @@ char *ftoa (float n, uint8_t decimal_places); // Returns true if float value is a whole number (integer) bool isintf (float value); +status_code_t read_uint (char *line, uint_fast8_t *char_counter, uint32_t *uint_ptr); + // Read a floating point value from a string. Line points to the input buffer, char_counter // is the indexer pointing to the current character of the line, while float_ptr is // a pointer to the result variable. Returns true when it succeeds diff --git a/nvs.h b/nvs.h index 644d708..41ee157 100644 --- a/nvs.h +++ b/nvs.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2020 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2009-2011 Simen Svale Skogsrud Grbl is free software: you can redistribute it and/or modify @@ -53,7 +53,7 @@ __NOTE:__ 1024 bytes of persistent storage is the minimum required. #define NVS_ADDR_PARAMETERS 512U #define NVS_ADDR_BUILD_INFO (GRBL_NVS_END - 81U) #define NVS_ADDR_STARTUP_BLOCK (NVS_ADDR_BUILD_INFO - 1 - N_STARTUP_LINE * (sizeof(stored_line_t) + NVS_CRC_BYTES)) -#ifdef N_TOOLS +#if N_TOOLS #define NVS_ADDR_TOOL_TABLE (GRBL_NVS_END + 1) #define GRBL_NVS_SIZE (GRBL_NVS_END + 1 + N_TOOLS * (sizeof(tool_data_t) + NVS_CRC_BYTES)) #else @@ -97,7 +97,7 @@ typedef void (*put_byte_ptr)(uint32_t addr, uint8_t new_value); /*! \brief Pointer to function for reading a block of data from NVS storage \param dest pointer to destination of data. \param source index based address into the storage area. -\param number of bytes to write. +\param size number of bytes to write. \param with_checksum \a true calculate and verify checksum at the end of the data block, \a false do not calculate and verify checksum. \returns #nvs_transfer_result_t enum. */ @@ -106,7 +106,7 @@ typedef nvs_transfer_result_t (*memcpy_from_nvs_ptr)(uint8_t *dest, uint32_t sou /*! \brief Pointer to function for writing a block of data to NVS storage \param dest index based address into the storage area. \param source pointer to source data -\param number of bytes to write +\param size number of bytes to write \param with_checksum \a true calculate and add a checksum at the end of the data block, \a false do not add checksum. \returns #nvs_transfer_result_t enum. */ diff --git a/nvs_buffer.c b/nvs_buffer.c index eb71490..f319e76 100644 --- a/nvs_buffer.c +++ b/nvs_buffer.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -57,7 +57,7 @@ typedef struct { #define PARAMETER_ADDR(n) (NVS_ADDR_PARAMETERS + n * (sizeof(coord_data_t) + NVS_CRC_BYTES)) #define STARTLINE_ADDR(n) (NVS_ADDR_STARTUP_BLOCK + n * (sizeof(stored_line_t) + NVS_CRC_BYTES)) -#ifdef N_TOOLS +#if N_TOOLS #define TOOL_ADDR(n) (NVS_ADDR_TOOL_TABLE + n * (sizeof(tool_data_t) + NVS_CRC_BYTES)) #endif @@ -82,7 +82,7 @@ static const emap_t target[] = { #error Increase number of startup line entries! #endif {NVS_ADDR_BUILD_INFO, NVS_GROUP_BUILD, 0}, -#ifdef N_TOOLS +#if N_TOOLS {TOOL_ADDR(0), NVS_GROUP_TOOLS, 0}, {TOOL_ADDR(1), NVS_GROUP_TOOLS, 1}, {TOOL_ADDR(2), NVS_GROUP_TOOLS, 2}, @@ -161,7 +161,7 @@ static nvs_transfer_result_t memcpy_to_ram (uint32_t destination, uint8_t *sourc case NVS_GROUP_GLOBAL: settings_dirty.global_settings = true; break; -#ifdef N_TOOLS +#if N_TOOLS case NVS_GROUP_TOOLS: settings_dirty.tool_data |= (1 << target[idx].offset); break; @@ -339,7 +339,7 @@ void nvs_buffer_sync_physical (void) settings_dirty.driver_settings = false; } -#ifdef N_TOOLS +#if N_TOOLS idx = N_TOOLS; if(settings_dirty.tool_data) do { idx--; @@ -354,7 +354,7 @@ void nvs_buffer_sync_physical (void) settings_dirty.global_settings || settings_dirty.driver_settings || settings_dirty.startup_lines || -#ifdef N_TOOLS +#if N_TOOLS settings_dirty.tool_data || #endif settings_dirty.build_info; @@ -405,7 +405,7 @@ void nvs_memmap (void) strcat(buf, uitoa(sizeof(stored_line_t) + NVS_CRC_BYTES)); report_message(buf, Message_Plain); -#ifdef N_TOOLS +#if N_TOOLS strcpy(buf, "Tool table: "); strcat(buf, uitoa(NVS_ADDR_TOOL_TABLE)); strcat(buf, " "); diff --git a/nvs_buffer.h b/nvs_buffer.h index f306b89..0eb0444 100644 --- a/nvs_buffer.h +++ b/nvs_buffer.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2021 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2009-2011 Simen Svale Skogsrud Grbl is free software: you can redistribute it and/or modify @@ -33,7 +33,7 @@ typedef struct { bool driver_settings; uint8_t startup_lines; uint16_t coord_data; -#ifdef N_TOOLS +#if N_TOOLS #if N_TOOLS > 16 uint32_t tool_data; #else diff --git a/planner.c b/planner.c index 7db71d4..e9284c1 100644 --- a/planner.c +++ b/planner.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Jens Geisler @@ -31,19 +31,12 @@ #include "planner.h" #include "protocol.h" -#ifndef MINIMUM_JUNCTION_SPEED -#define MINIMUM_JUNCTION_SPEED 0.0f -#endif -#ifndef MINIMUM_FEED_RATE -#define MINIMUM_FEED_RATE 1.0f -#endif -#ifdef ENABLE_BACKLASH_COMPENSATION -void mc_sync_backlash_position (void); +#ifndef ROTARY_FIX +#define ROTARY_FIX 0 #endif -// The number of linear motions that can be in the plan at any give time -#ifndef BLOCK_BUFFER_SIZE - #define BLOCK_BUFFER_SIZE 35 +#if ENABLE_BACKLASH_COMPENSATION +void mc_sync_backlash_position (void); #endif static uint_fast16_t block_buffer_size; // Number of blocks in the planner buffer minus 1 @@ -55,7 +48,6 @@ static plan_block_t *block_buffer_planned; // Pointer to the optima static planner_t pl; - /* PLANNER SPEED DEFINITION +--------+ <- current->nominal_speed / \ @@ -225,17 +217,11 @@ inline static void plan_reset_buffer (void) block_buffer_planned = block_buffer_tail; // = block_buffer_tail } - -#ifdef BLOCK_BUFFER_DYNAMIC - static void planner_warning (sys_state_t state) { report_message("Planner buffer size was reduced!", Message_Plain); } -#endif - - uint_fast16_t plan_get_buffer_size (void) { return block_buffer_size; @@ -243,15 +229,6 @@ uint_fast16_t plan_get_buffer_size (void) bool plan_reset (void) { -#ifndef BLOCK_BUFFER_DYNAMIC - - static plan_block_t block_buffer_s[BLOCK_BUFFER_SIZE + 1]; - - block_buffer = block_buffer_s; - block_buffer_size = BLOCK_BUFFER_SIZE; - -#else - if(block_buffer == NULL) { block_buffer_size = settings.planner_buffer_blocks; @@ -270,8 +247,6 @@ bool plan_reset (void) if(block_buffer == NULL) return false; -#endif - if(block_buffer_tail) { // Free memory for any pending messages and output commands after soft reset while(block_buffer_tail != block_buffer_head) { @@ -380,6 +355,23 @@ void plan_update_velocity_profile_parameters (void) pl.previous_nominal_speed = prev_nominal_speed; // Update prev nominal speed for next incoming block. } +#if N_AXIS > 3 && ROTARY_FIX + +static inline float convert_delta_vector_to_magnitude (float *vector) +{ + uint_fast8_t idx = N_AXIS; + float magnitude = 0.0f; + + do { + if (vector[--idx] != 0.0f) + magnitude += vector[idx] * vector[idx]; + } while(idx); + + return sqrtf(magnitude); +} + +#endif + static inline float limit_acceleration_by_axis_maximum (float *unit_vec) { uint_fast8_t idx = N_AXIS; @@ -428,6 +420,9 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data) int32_t target_steps[N_AXIS], position_steps[N_AXIS], delta_steps; uint_fast8_t idx; float unit_vec[N_AXIS]; +#if N_AXIS > 3 && ROTARY_FIX + axes_signals_t motion = {0}; +#endif // plan_cleanup(block); memset(block, 0, sizeof(plan_block_t) - 2 * sizeof(plan_block_t *)); // Zero all block values (except linked list pointers). @@ -452,10 +447,17 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data) // NOTE: Computes true distance from converted step values. target_steps[idx] = lroundf(target[idx] * settings.axis[idx].steps_per_mm); - delta_steps = target_steps[idx] - position_steps[idx]; - block->steps[idx] = labs(delta_steps); - block->step_event_count = max(block->step_event_count, block->steps[idx]); - unit_vec[idx] = (float)delta_steps / settings.axis[idx].steps_per_mm; // Store unit vector numerator + if((delta_steps = target_steps[idx] - position_steps[idx])) { + block->steps[idx] = labs(delta_steps); + block->step_event_count = max(block->step_event_count, block->steps[idx]); + unit_vec[idx] = (float)delta_steps / settings.axis[idx].steps_per_mm; // Store unit vector numerator +#if N_AXIS > 3 && ROTARY_FIX + motion.mask |= bit(idx); +#endif + } else { + block->steps[idx] = 0; + unit_vec[idx] = 0.0f; // Store unit vector numerator + } // Set direction bits. Bit enabled always means direction is negative. if (delta_steps < 0) @@ -487,6 +489,36 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data) pl_data->message = NULL; // Indicate message is already queued for display on execution pl_data->output_commands = NULL; // Indicate commands are already queued for execution +#if N_AXIS > 3 && ROTARY_FIX + + if(!block->condition.inverse_time && + /*!block->condition.rapid_motion &&*/ + (motion.mask & settings.steppers.is_rotational.mask) && + (motion.mask & ~settings.steppers.is_rotational.mask)) { + + float delta_vec[N_AXIS]; + + idx = A_AXIS; + motion.mask &= settings.steppers.is_rotational.mask; + motion.mask >>= 3; + memcpy(delta_vec, unit_vec, sizeof(delta_vec)); + + while(motion.mask) { + if(motion.mask & 0x01) + unit_vec[idx] = delta_vec[idx] = 0.0f; + motion.mask >>= 1; + idx++; + } + + // feed rate for laser mode has to be the actual speed of the controlled + // point over the surface of the object to engrave? +// pl_data->feed_rate = 1.0f / (convert_delta_vector_to_magnitude(delta_vec) / pl_data->feed_rate); + pl_data->feed_rate = 1.0f / ((block->millimeters = convert_delta_vector_to_unit_vector(unit_vec)) / pl_data->feed_rate); + block->condition.inverse_time = On; + } else + +#endif + // Calculate the unit vector of the line move and the block maximum feed rate and acceleration scaled // down such that no individual axes maximum values are exceeded with respect to the line direction. // NOTE: This calculation assumes all axes are orthogonal (Cartesian) and works with ABC-axes, @@ -604,7 +636,7 @@ float *plan_get_position (void) void plan_sync_position (void) { memcpy(pl.position, sys.position, sizeof(pl.position)); -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION mc_sync_backlash_position(); #endif } @@ -632,16 +664,25 @@ void plan_cycle_reinitialize (void) // Set feed overrides void plan_feed_override (uint_fast8_t feed_override, uint_fast8_t rapid_override) { + bool feedrate_changed = false, rapidrate_changed = false; + if(sys.override.control.feed_rate_disable) return; feed_override = constrain(feed_override, MIN_FEED_RATE_OVERRIDE, MAX_FEED_RATE_OVERRIDE); - if ((feed_override != sys.override.feed_rate) || (rapid_override != sys.override.rapid_rate)) { - sys.override.feed_rate = (uint8_t)feed_override; - sys.override.rapid_rate = (uint8_t)rapid_override; - sys.report.overrides = On; // Set to report change immediately - plan_update_velocity_profile_parameters(); - plan_cycle_reinitialize(); + if ((feedrate_changed = feed_override != sys.override.feed_rate) || + (rapidrate_changed = rapid_override != sys.override.rapid_rate)) { + sys.override.feed_rate = (uint8_t)feed_override; + sys.override.rapid_rate = (uint8_t)rapid_override; + sys.report.overrides = On; // Set to report change immediately + plan_update_velocity_profile_parameters(); + plan_cycle_reinitialize(); + if(grbl.on_override_changed) { + if(feedrate_changed) + grbl.on_override_changed(OverrideChanged_FeedRate); + if(rapidrate_changed) + grbl.on_override_changed(OverrideChanged_RapidRate); + } } } diff --git a/plugins_init.h b/plugins_init.h index 086c2b1..1e686ff 100644 --- a/plugins_init.h +++ b/plugins_init.h @@ -7,7 +7,7 @@ Part of grblHAL - Copyright (c) 2021-2022 Terje Io + Copyright (c) 2021-2023 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -60,6 +60,11 @@ keypad_init(); #endif +#if MACROS_ENABLE + extern bool macros_init (void); + macros_init(); +#endif + #if LASER_COOLANT_ENABLE extern void laser_coolant_init (void); laser_coolant_init(); diff --git a/protocol.c b/protocol.c index 3ab5fc9..3840d84 100644 --- a/protocol.c +++ b/protocol.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -232,7 +232,7 @@ bool protocol_main_loop (void) line[char_counter] = '\0'; // Set string termination character. - #ifdef REPORT_ECHO_LINE_RECEIVED + #if REPORT_ECHO_LINE_RECEIVED report_echo_line_received(line); #endif @@ -389,7 +389,7 @@ bool protocol_execute_realtime (void) if (sys.suspend) protocol_exec_rt_suspend(); - #ifdef BUFFER_NVSDATA + #if NVSDATA_BUFFER_ENABLE if((state_get() == STATE_IDLE || (state_get() & (STATE_ALARM|STATE_ESTOP))) && settings_dirty.is_dirty && !gc_state.file_run) nvs_buffer_sync_physical(); #endif @@ -677,6 +677,8 @@ bool protocol_exec_rt_system (void) if(coolant_state.value != gc_state.modal.coolant.value) { coolant_set_state(coolant_state); // Report flag set in coolant_set_state(). gc_state.modal.coolant = coolant_state; + if(grbl.on_override_changed) + grbl.on_override_changed(OverrideChanged_CoolantState); } if (spindle_stop && state_get() == STATE_HOLD && gc_state.modal.spindle.on) { @@ -767,18 +769,21 @@ ISR_CODE bool ISR_FUNC(protocol_enqueue_realtime_command)(char c) break; #endif - case CMD_STATUS_REPORT_ALL: // Add all statuses on to report + case CMD_STATUS_REPORT_ALL: // Add all statuses to report { bool tlo = sys.report.tool_offset; sys.report.value = (uint32_t)-1; sys.report.tool_offset = tlo; sys.report.m66result = sys.var5399 > -2; } - // no break + system_set_exec_state_flag(EXEC_STATUS_REPORT); + drop = true; + break; case CMD_STATUS_REPORT: case 0x05: - system_set_exec_state_flag(EXEC_STATUS_REPORT); + if(!sys.flags.auto_reporting) + system_set_exec_state_flag(EXEC_STATUS_REPORT); drop = true; break; @@ -843,6 +848,11 @@ ISR_CODE bool ISR_FUNC(protocol_enqueue_realtime_command)(char c) stream_mpg_enable(false); break; + case CMD_AUTO_REPORTING_TOGGLE: + if(settings.report_interval) + sys.flags.auto_reporting = !sys.flags.auto_reporting; + break; + case CMD_OVERRIDE_FEED_RESET: case CMD_OVERRIDE_FEED_COARSE_PLUS: case CMD_OVERRIDE_FEED_COARSE_MINUS: diff --git a/report.c b/report.c index 55ec566..3437a61 100644 --- a/report.c +++ b/report.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC Grbl is free software: you can redistribute it and/or modify @@ -44,34 +44,6 @@ #include #endif -#ifndef REPORT_OVERRIDE_REFRESH_BUSY_COUNT -#define REPORT_OVERRIDE_REFRESH_BUSY_COUNT 20 // (1-255) -#endif -#ifndef REPORT_OVERRIDE_REFRESH_IDLE_COUNT -#define REPORT_OVERRIDE_REFRESH_IDLE_COUNT 10 // (1-255) Must be less than or equal to the busy count -#endif -#ifndef REPORT_WCO_REFRESH_BUSY_COUNT -#define REPORT_WCO_REFRESH_BUSY_COUNT 30 // (2-255) -#endif -#ifndef REPORT_WCO_REFRESH_IDLE_COUNT -#define REPORT_WCO_REFRESH_IDLE_COUNT 10 // (2-255) Must be less than or equal to the busy count -#endif - -// Compile-time sanity check of defines - -#if (REPORT_WCO_REFRESH_BUSY_COUNT < REPORT_WCO_REFRESH_IDLE_COUNT) - #error "WCO busy refresh is less than idle refresh." -#endif -#if (REPORT_OVERRIDE_REFRESH_BUSY_COUNT < REPORT_OVERRIDE_REFRESH_IDLE_COUNT) - #error "Override busy refresh is less than idle refresh." -#endif -#if (REPORT_WCO_REFRESH_IDLE_COUNT < 2) - #error "WCO refresh must be greater than one." -#endif -#if (REPORT_OVERRIDE_REFRESH_IDLE_COUNT < 1) - #error "Override refresh must be greater than zero." -#endif - static char buf[(STRLEN_COORDVALUE + 1) * N_AXIS]; static char *(*get_axis_values)(float *axis_values); static char *(*get_axis_value)(float value); @@ -554,7 +526,7 @@ void report_home_position (void) void report_tool_offsets (void) { hal.stream.write("[TLO:"); -#ifdef TOOL_LENGTH_OFFSET_AXIS +#if TOOL_LENGTH_OFFSET_AXIS >= 0 hal.stream.write(get_axis_value(gc_state.tool_length_offset[TOOL_LENGTH_OFFSET_AXIS])); #else hal.stream.write(get_axis_values(gc_state.tool_length_offset)); @@ -648,7 +620,7 @@ void report_ngc_parameters (void) hal.stream.write(get_axis_values(gc_state.g92_coord_offset)); hal.stream.write("]" ASCII_EOL); -#ifdef N_TOOLS +#if N_TOOLS for (idx = 1; idx <= N_TOOLS; idx++) { hal.stream.write("[T:"); hal.stream.write(uitoa((uint32_t)idx)); @@ -858,7 +830,7 @@ void report_build_info (char *line, bool extended) if(hal.driver_cap.mist_control) *append++ = 'M'; -#ifdef COREXY +#if COREXY *append++ = 'C'; #endif @@ -892,19 +864,19 @@ void report_build_info (char *line, bool extended) if(hal.signals_cap.safety_door_ajar) *append++ = '+'; - #ifdef DISABLE_RESTORE_NVS_WIPE_ALL // NOTE: Shown when disabled. + #if !ENABLE_RESTORE_NVS_WIPE_ALL // NOTE: Shown when disabled. *append++ = '*'; #endif - #ifdef DISABLE_RESTORE_NVS_DEFAULT_SETTINGS // NOTE: Shown when disabled. + #if !ENABLE_RESTORE_NVS_DEFAULT_SETTINGS // NOTE: Shown when disabled. *append++ = '$'; #endif - #ifdef DISABLE_RESTORE_NVS_CLEAR_PARAMETERS // NOTE: Shown when disabled. + #if !ENABLE_RESTORE_NVS_CLEAR_PARAMETERS // NOTE: Shown when disabled. *append++ = '#'; #endif - #ifdef DISABLE_BUILD_INFO_WRITE_COMMAND // NOTE: Shown when disabled. + #if DISABLE_BUILD_INFO_WRITE_COMMAND // NOTE: Shown when disabled. *append++ = 'I'; #endif @@ -926,7 +898,7 @@ void report_build_info (char *line, bool extended) hal.stream.write(","); hal.stream.write(uitoa((uint32_t)N_AXIS)); hal.stream.write(","); - #ifdef N_TOOLS + #if N_TOOLS hal.stream.write(uitoa((uint32_t)N_TOOLS)); #else hal.stream.write("0"); @@ -987,7 +959,7 @@ void report_build_info (char *line, bool extended) strcat(buf, "EXPR,"); #endif - #ifdef N_TOOLS + #if N_TOOLS if(hal.driver_cap.atc && hal.tool.change) strcat(buf, "ATC,"); else @@ -1358,9 +1330,14 @@ void report_realtime_status (void) grbl.on_realtime_report(hal.stream.write_all, sys.report); #if COMPATIBILITY_LEVEL <= 1 - if(sys.report.all) + if(sys.report.all) { hal.stream.write_all("|FW:grblHAL"); - else + if(settings.report_interval) { + hal.stream.write_all(sys.flags.auto_reporting ? "|AR:" : "|AR"); + if(sys.flags.auto_reporting) + hal.stream.write_all(uitoa(settings.report_interval)); + } + } else #endif if(settings.status_report.parser_state) { @@ -1510,7 +1487,7 @@ static void report_settings_detail (settings_format_t format, const setting_deta #ifndef NO_SETTINGS_DESCRIPTIONS // Add description if driver is capable of outputting it... if(hal.stream.write_n) { - const char *description = setting_get_description(setting->id + offset); + const char *description = setting_get_description((setting_id_t)(setting->id + offset)); if(description && *description != '\0') { char *lf; hal.stream.write(ASCII_EOL); @@ -1559,6 +1536,8 @@ static void report_settings_detail (settings_format_t format, const setting_deta hal.stream.write(setting->max_value); hal.stream.write(vbar); hal.stream.write(uitoa(setting->flags.reboot_required)); + hal.stream.write(vbar); + hal.stream.write(uitoa(setting->flags.allow_null)); hal.stream.write("]"); break; @@ -1690,8 +1669,9 @@ static void report_settings_detail (settings_format_t format, const setting_deta hal.stream.write(setting->max_value); hal.stream.write("\t"); - hal.stream.write(uitoa(setting->flags.reboot_required)); + hal.stream.write("\t"); + hal.stream.write(uitoa(setting->flags.allow_null)); } break; } diff --git a/settings.c b/settings.c index 677ad1a..c387f96 100644 --- a/settings.c +++ b/settings.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2015 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -28,34 +28,18 @@ #include #include "hal.h" -#include "defaults.h" +#include "config.h" #include "machine_limits.h" #include "nvs_buffer.h" #include "tool_change.h" #include "state_machine.h" -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION #include "motion_control.h" #endif #ifdef ENABLE_SPINDLE_LINEARIZATION #include #endif -#ifndef SETTINGS_RESTORE_DEFAULTS -#define SETTINGS_RESTORE_DEFAULTS 1 -#endif -#ifndef SETTINGS_RESTORE_PARAMETERS -#define SETTINGS_RESTORE_PARAMETERS 1 -#endif -#ifndef SETTINGS_RESTORE_STARTUP_LINES -#define SETTINGS_RESTORE_STARTUP_LINES 1 -#endif -#ifndef SETTINGS_RESTORE_BUILD_INFO -#define SETTINGS_RESTORE_BUILD_INFO 1 -#endif -#ifndef SETTINGS_RESTORE_DRIVER_PARAMETERS -#define SETTINGS_RESTORE_DRIVER_PARAMETERS 1 -#endif - settings_t settings; const settings_restore_t settings_all = { @@ -73,20 +57,14 @@ PROGMEM const settings_t defaults = { .junction_deviation = DEFAULT_JUNCTION_DEVIATION, .arc_tolerance = DEFAULT_ARC_TOLERANCE, .g73_retract = DEFAULT_G73_RETRACT, -#ifdef BLOCK_BUFFER_DYNAMIC - #ifdef PLANNER_BUFFER_BLOCKS - .planner_buffer_blocks = PLANNER_BUFFER_BLOCKS, - #elif defined(BLOCK_BUFFER_SIZE) - .planner_buffer_blocks = BLOCK_BUFFER_SIZE, - #else - .planner_buffer_blocks = 35, - #endif -#endif + .report_interval = DEFAULT_AUTOREPORT_INTERVAL, + .timezone = DEFAULT_TIMEZONE_OFFSET, + .planner_buffer_blocks = DEFAULT_PLANNER_BUFFER_BLOCKS, .flags.legacy_rt_commands = DEFAULT_LEGACY_RTCOMMANDS, .flags.report_inches = DEFAULT_REPORT_INCHES, .flags.sleep_enable = DEFAULT_SLEEP_ENABLE, .flags.compatibility_level = COMPATIBILITY_LEVEL, -#if DISABLE_G92_PERSISTENCE +#if DEFAULT_DISABLE_G92_PERSISTENCE .flags.g92_is_volatile = 1, #else .flags.g92_is_volatile = 0, @@ -102,27 +80,29 @@ PROGMEM const settings_t defaults = { #endif .flags.restore_after_feed_hold = DEFAULT_RESTORE_AFTER_FEED_HOLD, .flags.force_initialization_alarm = DEFAULT_FORCE_INITIALIZATION_ALARM, + .flags.restore_overrides = DEFAULT_RESET_OVERRIDES, + .flags.no_restore_position_after_M6 = DEFAULT_TOOLCHANGE_NO_RESTORE_POSITION, - .probe.disable_probe_pullup = DISABLE_PROBE_BIT_PULL_UP, - .probe.allow_feed_override = ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES, - .probe.invert_probe_pin = DEFAULT_INVERT_PROBE_BIT, + .probe.disable_probe_pullup = DEFAULT_PROBE_SIGNAL_DISABLE_PULLUP, + .probe.allow_feed_override = DEFAULT_ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES, + .probe.invert_probe_pin = DEFAULT_PROBE_SIGNAL_INVERT, .steppers.pulse_microseconds = DEFAULT_STEP_PULSE_MICROSECONDS, .steppers.pulse_delay_microseconds = DEFAULT_STEP_PULSE_DELAY, .steppers.idle_lock_time = DEFAULT_STEPPER_IDLE_LOCK_TIME, - .steppers.step_invert.mask = DEFAULT_STEPPING_INVERT_MASK, - .steppers.dir_invert.mask = DEFAULT_DIRECTION_INVERT_MASK, + .steppers.step_invert.mask = DEFAULT_STEP_SIGNALS_INVERT_MASK, + .steppers.dir_invert.mask = DEFAULT_DIR_SIGNALS_INVERT_MASK, .steppers.ganged_dir_invert.mask = DEFAULT_GANGED_DIRECTION_INVERT_MASK, #if COMPATIBILITY_LEVEL <= 2 - .steppers.enable_invert.mask = INVERT_ST_ENABLE_MASK, -#elif INVERT_ST_ENABLE_MASK + .steppers.enable_invert.mask = DEFAULT_ENABLE_SIGNALS_INVERT_MASK, +#elif DEFAULT_ENABLE_SIGNALS_INVERT_MASK .steppers.enable_invert.mask = 0, #else .steppers.enable_invert.mask = AXES_BITMASK, #endif - .steppers.deenergize.mask = ST_DEENERGIZE_MASK, + .steppers.deenergize.mask = DEFAULT_STEPPER_DEENERGIZE_MASK, #if N_AXIS > 3 - .steppers.is_rotational.mask = (ST_ROTATIONAL_MASK & AXES_BITMASK) & 0b11111000, + .steppers.is_rotational.mask = (DEFAULT_AXIS_ROTATIONAL_MASK & AXES_BITMASK) & 0b11111000, #endif #if DEFAULT_HOMING_ENABLE .homing.flags.enabled = DEFAULT_HOMING_ENABLE, @@ -131,6 +111,7 @@ PROGMEM const settings_t defaults = { .homing.flags.force_set_origin = HOMING_FORCE_SET_ORIGIN, .homing.flags.manual = DEFAULT_HOMING_ALLOW_MANUAL, .homing.flags.override_locks = DEFAULT_HOMING_OVERRIDE_LOCKS, + .homing.flags.keep_on_reset = DEFAULT_HOMING_KEEP_STATUS_ON_RESET, #else .homing.flags.value = 0, #endif @@ -140,14 +121,14 @@ PROGMEM const settings_t defaults = { .homing.debounce_delay = DEFAULT_HOMING_DEBOUNCE_DELAY, .homing.pulloff = DEFAULT_HOMING_PULLOFF, .homing.locate_cycles = DEFAULT_N_HOMING_LOCATE_CYCLE, - .homing.cycle[0].mask = HOMING_CYCLE_0, - .homing.cycle[1].mask = HOMING_CYCLE_1, - .homing.cycle[2].mask = HOMING_CYCLE_2, - .homing.dual_axis.fail_length_percent = DUAL_AXIS_HOMING_FAIL_AXIS_LENGTH_PERCENT, - .homing.dual_axis.fail_distance_min = DUAL_AXIS_HOMING_FAIL_DISTANCE_MIN, - .homing.dual_axis.fail_distance_max = DUAL_AXIS_HOMING_FAIL_DISTANCE_MAX, + .homing.cycle[0].mask = DEFAULT_HOMING_CYCLE_0, + .homing.cycle[1].mask = DEFAULT_HOMING_CYCLE_1, + .homing.cycle[2].mask = DEFAULT_HOMING_CYCLE_2, + .homing.dual_axis.fail_length_percent = DEFAULT_DUAL_AXIS_HOMING_FAIL_AXIS_LENGTH_PERCENT, + .homing.dual_axis.fail_distance_min = DEFAULT_DUAL_AXIS_HOMING_FAIL_DISTANCE_MIN, + .homing.dual_axis.fail_distance_max = DEFAULT_DUAL_AXIS_HOMING_FAIL_DISTANCE_MAX, - .status_report.machine_position = DEFAULT_REPORT_BUFFER_STATE, + .status_report.machine_position = DEFAULT_REPORT_MACHINE_POSITION, .status_report.buffer_state = DEFAULT_REPORT_BUFFER_STATE, .status_report.line_numbers = DEFAULT_REPORT_LINE_NUMBERS, .status_report.feed_speed = DEFAULT_REPORT_CURRENT_FEED_SPEED, @@ -158,25 +139,25 @@ PROGMEM const settings_t defaults = { .status_report.sync_on_wco_change = DEFAULT_REPORT_SYNC_ON_WCO_CHANGE, .status_report.parser_state = DEFAULT_REPORT_PARSER_STATE, .status_report.alarm_substate = DEFAULT_REPORT_ALARM_SUBSTATE, - + .status_report.run_substate = DEFAULT_REPORT_RUN_SUBSTATE, .limits.flags.hard_enabled = DEFAULT_HARD_LIMIT_ENABLE, .limits.flags.soft_enabled = DEFAULT_SOFT_LIMIT_ENABLE, .limits.flags.jog_soft_limited = DEFAULT_JOG_LIMIT_ENABLE, .limits.flags.check_at_init = DEFAULT_CHECK_LIMITS_AT_INIT, .limits.flags.two_switches = DEFAULT_LIMITS_TWO_SWITCHES_ON_AXES, - .limits.invert.mask = INVERT_LIMIT_BIT_MASK, - .limits.disable_pullup.mask = DISABLE_LIMIT_BITS_PULL_UP_MASK, + .limits.invert.mask = DEFAULT_LIMIT_SIGNALS_INVERT_MASK, + .limits.disable_pullup.mask = DEFAULT_LIMIT_SIGNALS_PULLUP_DISABLE_MASK, - .control_invert.mask = INVERT_CONTROL_PIN_MASK, - .control_disable_pullup.mask = DISABLE_CONTROL_PINS_PULL_UP_MASK, + .control_invert.mask = DEFAULT_CONTROL_SIGNALS_INVERT_MASK, + .control_disable_pullup.mask = DEFAULT_DISABLE_CONTROL_PINS_PULL_UP_MASK, .spindle.rpm_max = DEFAULT_SPINDLE_RPM_MAX, .spindle.rpm_min = DEFAULT_SPINDLE_RPM_MIN, .spindle.flags.pwm_disable = false, .spindle.flags.enable_rpm_controlled = DEFAULT_SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED, - .spindle.invert.on = INVERT_SPINDLE_ENABLE_PIN, - .spindle.invert.ccw = INVERT_SPINDLE_CCW_PIN, - .spindle.invert.pwm = INVERT_SPINDLE_PWM_PIN, + .spindle.invert.on = DEFAULT_INVERT_SPINDLE_ENABLE_PIN, + .spindle.invert.ccw = DEFAULT_INVERT_SPINDLE_CCW_PIN, + .spindle.invert.pwm = DEFAULT_INVERT_SPINDLE_PWM_PIN, .spindle.pwm_freq = DEFAULT_SPINDLE_PWM_FREQ, .spindle.pwm_off_value = DEFAULT_SPINDLE_PWM_OFF_VALUE, .spindle.pwm_min_value = DEFAULT_SPINDLE_PWM_MIN_VALUE, @@ -200,90 +181,90 @@ PROGMEM const settings_t defaults = { .spindle.pwm_piece[3] = { .rpm = NAN, .start = 0.0f, .end = 0.0f }, #endif - .coolant_invert.flood = INVERT_COOLANT_FLOOD_PIN, - .coolant_invert.mist = INVERT_COOLANT_MIST_PIN, + .coolant_invert.flood = DEFAULT_INVERT_COOLANT_FLOOD_PIN, + .coolant_invert.mist = DEFAULT_INVERT_COOLANT_MIST_PIN, .axis[X_AXIS].steps_per_mm = DEFAULT_X_STEPS_PER_MM, .axis[X_AXIS].max_rate = DEFAULT_X_MAX_RATE, - .axis[X_AXIS].acceleration = DEFAULT_X_ACCELERATION, + .axis[X_AXIS].acceleration = (DEFAULT_X_ACCELERATION * 60.0f * 60.0f), .axis[X_AXIS].max_travel = (-DEFAULT_X_MAX_TRAVEL), .axis[X_AXIS].dual_axis_offset = 0.0f, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION .axis[X_AXIS].backlash = 0.0f, #endif .axis[Y_AXIS].steps_per_mm = DEFAULT_Y_STEPS_PER_MM, .axis[Y_AXIS].max_rate = DEFAULT_Y_MAX_RATE, .axis[Y_AXIS].max_travel = (-DEFAULT_Y_MAX_TRAVEL), - .axis[Y_AXIS].acceleration = DEFAULT_Y_ACCELERATION, + .axis[Y_AXIS].acceleration = (DEFAULT_Y_ACCELERATION * 60.0f * 60.0f), .axis[Y_AXIS].dual_axis_offset = 0.0f, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION .axis[Y_AXIS].backlash = 0.0f, #endif .axis[Z_AXIS].steps_per_mm = DEFAULT_Z_STEPS_PER_MM, .axis[Z_AXIS].max_rate = DEFAULT_Z_MAX_RATE, - .axis[Z_AXIS].acceleration = DEFAULT_Z_ACCELERATION, + .axis[Z_AXIS].acceleration = (DEFAULT_Z_ACCELERATION * 60.0f * 60.0f), .axis[Z_AXIS].max_travel = (-DEFAULT_Z_MAX_TRAVEL), .axis[Z_AXIS].dual_axis_offset = 0.0f, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION .axis[Z_AXIS].backlash = 0.0f, #endif #ifdef A_AXIS .axis[A_AXIS].steps_per_mm = DEFAULT_A_STEPS_PER_MM, .axis[A_AXIS].max_rate = DEFAULT_A_MAX_RATE, - .axis[A_AXIS].acceleration = DEFAULT_A_ACCELERATION, + .axis[A_AXIS].acceleration =(DEFAULT_A_ACCELERATION * 60.0f * 60.0f), .axis[A_AXIS].max_travel = (-DEFAULT_A_MAX_TRAVEL), .axis[A_AXIS].dual_axis_offset = 0.0f, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION .axis[A_AXIS].backlash = 0.0f, #endif - .homing.cycle[3].mask = HOMING_CYCLE_3, + .homing.cycle[3].mask = DEFAULT_HOMING_CYCLE_3, #endif #ifdef B_AXIS .axis[B_AXIS].steps_per_mm = DEFAULT_B_STEPS_PER_MM, .axis[B_AXIS].max_rate = DEFAULT_B_MAX_RATE, - .axis[B_AXIS].acceleration = DEFAULT_B_ACCELERATION, + .axis[B_AXIS].acceleration = (DEFAULT_B_ACCELERATION * 60.0f * 60.0f), .axis[B_AXIS].max_travel = (-DEFAULT_B_MAX_TRAVEL), .axis[B_AXIS].dual_axis_offset = 0.0f, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION .axis[B_AXIS].backlash = 0.0f, #endif - .homing.cycle[4].mask = HOMING_CYCLE_4, + .homing.cycle[4].mask = DEFAULT_HOMING_CYCLE_4, #endif #ifdef C_AXIS .axis[C_AXIS].steps_per_mm = DEFAULT_C_STEPS_PER_MM, - .axis[C_AXIS].acceleration = DEFAULT_C_ACCELERATION, + .axis[C_AXIS].acceleration = (DEFAULT_C_ACCELERATION * 60.0f * 60.0f), .axis[C_AXIS].max_rate = DEFAULT_C_MAX_RATE, .axis[C_AXIS].max_travel = (-DEFAULT_C_MAX_TRAVEL), .axis[C_AXIS].dual_axis_offset = 0.0f, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION .axis[C_AXIS].backlash = 0.0f, #endif - .homing.cycle[5].mask = HOMING_CYCLE_5, + .homing.cycle[5].mask = DEFAULT_HOMING_CYCLE_5, #endif #ifdef U_AXIS .axis[U_AXIS].steps_per_mm = DEFAULT_U_STEPS_PER_MM, - .axis[U_AXIS].acceleration = DEFAULT_U_ACCELERATION, + .axis[U_AXIS].acceleration = (DEFAULT_U_ACCELERATION * 60.0f * 60.0f), .axis[U_AXIS].max_rate = DEFAULT_U_MAX_RATE, .axis[U_AXIS].max_travel = (-DEFAULT_U_MAX_TRAVEL), .axis[U_AXIS].dual_axis_offset = 0.0f, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION .axis[U_AXIS].backlash = 0.0f, #endif #endif #ifdef V_AXIS .axis[V_AXIS].steps_per_mm = DEFAULT_V_STEPS_PER_MM, - .axis[V_AXIS].acceleration = DEFAULT_V_ACCELERATION, + .axis[V_AXIS].acceleration = (DEFAULT_V_ACCELERATION * 60.0f * 60.0f), .axis[V_AXIS].max_rate = DEFAULT_V_MAX_RATE, .axis[V_AXIS].max_travel = (-DEFAULT_V_MAX_TRAVEL), .axis[V_AXIS].dual_axis_offset = 0.0f, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION .axis[V_AXIS].backlash = 0.0f, #endif #endif @@ -303,8 +284,10 @@ PROGMEM const settings_t defaults = { .parking.pullout_rate = DEFAULT_PARKING_PULLOUT_RATE, .parking.pullout_increment = DEFAULT_PARKING_PULLOUT_INCREMENT, - .safety_door.spindle_on_delay = SAFETY_DOOR_SPINDLE_DELAY, - .safety_door.coolant_on_delay = SAFETY_DOOR_COOLANT_DELAY + .safety_door.flags.ignore_when_idle = DEFAULT_DOOR_IGNORE_WHEN_IDLE, + .safety_door.flags.keep_coolant_on = DEFAULT_DOOR_KEEP_COOLANT_ON, + .safety_door.spindle_on_delay = DEFAULT_SAFETY_DOOR_SPINDLE_DELAY, + .safety_door.coolant_on_delay = DEFAULT_SAFETY_DOOR_COOLANT_DELAY }; PROGMEM static const setting_group_detail_t setting_group_detail [] = { @@ -327,7 +310,7 @@ PROGMEM static const setting_group_detail_t setting_group_detail [] = { { Group_Axis, Group_XAxis, "X-axis"}, { Group_Axis, Group_YAxis, "Y-axis"}, { Group_Axis, Group_ZAxis, "Z-axis"}, -#ifndef AXIS_REMAP_ABC2UVW +#if !AXIS_REMAP_ABC2UVW #ifdef A_AXIS { Group_Axis, Group_AAxis, "A-axis"}, #endif @@ -382,6 +365,7 @@ static status_code_t set_tool_change_probing_distance (setting_id_t id, float va static status_code_t set_tool_restore_pos (setting_id_t id, uint_fast16_t int_value); static status_code_t set_ganged_dir_invert (setting_id_t id, uint_fast16_t int_value); static status_code_t set_stepper_deenergize_mask (setting_id_t id, uint_fast16_t int_value); +static status_code_t set_report_interval (setting_id_t setting, uint_fast16_t int_value); #ifndef NO_SAFETY_DOOR_SUPPORT static status_code_t set_parking_enable (setting_id_t id, uint_fast16_t int_value); static status_code_t set_restore_overrides (setting_id_t id, uint_fast16_t int_value); @@ -528,7 +512,7 @@ PROGMEM static const setting_detail_t setting_detail[] = { { Setting_AxisMaxRate, Group_Axis0, "?-axis maximum rate", axis_rate, Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL }, { Setting_AxisAcceleration, Group_Axis0, "?-axis acceleration", axis_accel, Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL }, { Setting_AxisMaxTravel, Group_Axis0, "?-axis maximum travel", axis_dist, Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL }, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION { Setting_AxisBacklash, Group_Axis0, "?-axis backlash compensation", axis_dist, Format_Decimal, "#####0.000", NULL, NULL, Setting_IsExtendedFn, set_axis_setting, get_float, NULL }, #endif { Setting_AxisAutoSquareOffset, Group_Axis0, "?-axis dual axis offset", "mm", Format_Decimal, "-0.000", "-10", "10", Setting_IsExtendedFn, set_axis_setting, get_float, is_setting_available }, @@ -545,7 +529,7 @@ PROGMEM static const setting_detail_t setting_detail[] = { #if COMPATIBILITY_LEVEL <= 1 { Setting_DisableG92Persistence, Group_General, "Disable G92 persistence", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_g92_disable_persistence, get_int, NULL }, #endif -#ifndef AXIS_REMAP_ABC2UVW +#if !AXIS_REMAP_ABC2UVW #if N_AXIS == 4 { Settings_Axis_Rotational, Group_Stepper, "Rotational axes", NULL, Format_Bitfield, "A-Axis", NULL, NULL, Setting_IsExtendedFn, set_rotational_axes, get_int, NULL }, #elif N_AXIS == 5 @@ -572,9 +556,9 @@ PROGMEM static const setting_detail_t setting_detail[] = { #endif { Setting_SpindleOnDelay, Group_Spindle, "Spindle on delay", "s", Format_Decimal, "#0.0", "0.5", "20", Setting_IsExtended, &settings.safety_door.spindle_on_delay, NULL, is_setting_available }, { Setting_SpindleType, Group_Spindle, "Default spindle", NULL, Format_RadioButtons, spindle_types, NULL, NULL, Setting_IsExtendedFn, set_spindle_type, get_int, is_setting_available }, -#ifdef BLOCK_BUFFER_DYNAMIC { Setting_PlannerBlocks, Group_General, "Planner buffer blocks", NULL, Format_Int16, "####0", "30", "1000", Setting_IsExtended, &settings.planner_buffer_blocks, NULL, NULL, { .reboot_required = On } }, -#endif + { Setting_AutoReportInterval, Group_General, "Autoreport interval", "ms", Format_Int16, "###0", "100", "1000", Setting_IsExtendedFn, set_report_interval, get_int, NULL, { .reboot_required = On, .allow_null = On } }, +// { Setting_TimeZoneOffset, Group_General, "Timezone offset", NULL, Format_Decimal, "-#0.00", "0", "12", Setting_IsExtended, &settings.timezone, NULL, NULL }, }; #ifndef NO_SETTINGS_DESCRIPTIONS @@ -690,11 +674,11 @@ PROGMEM static const setting_descr_t setting_descr[] = { { Setting_PositionDGain, "" }, { Setting_PositionIMaxError, "Spindle sync PID max integrator error." }, { Setting_AxisStepsPerMM, "Travel resolution in steps per millimeter." }, - { Setting_AxisStepsPerMM + 1, "Travel resolution in steps per degree." }, // "Hack" to get correct description for rotary axes + { (setting_id_t)(Setting_AxisStepsPerMM + 1), "Travel resolution in steps per degree." }, // "Hack" to get correct description for rotary axes { Setting_AxisMaxRate, "Maximum rate. Used as G0 rapid rate." }, { Setting_AxisAcceleration, "Acceleration. Used for motion planning to not exceed motor torque and lose steps." }, { Setting_AxisMaxTravel, "Maximum axis travel distance from homing switch. Determines valid machine space for soft-limits and homing search distances." }, -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION { Setting_AxisBacklash, "Backlash distance to compensate for." }, #endif { Setting_AxisAutoSquareOffset, "Offset between sides to compensate for homing switches inaccuracies." }, @@ -725,9 +709,9 @@ PROGMEM static const setting_descr_t setting_descr[] = { { Setting_DoorSpindleOnDelay, "Delay to allow spindle to spin up when spindle at speed tolerance is > 0." }, #endif { Setting_SpindleType, "Spindle selected on startup." }, -#ifdef BLOCK_BUFFER_DYNAMIC { Setting_PlannerBlocks, "Number of blocks in the planner buffer." }, -#endif + { Setting_AutoReportInterval, "Interval the real time report will be sent, set to 0 to disable." }, + { Setting_TimeZoneOffset, "Offset in hours from UTC." } }; #endif @@ -861,6 +845,14 @@ static status_code_t set_stepper_deenergize_mask (setting_id_t id, uint_fast16_t return Status_OK; } +static status_code_t set_report_interval (setting_id_t setting, uint_fast16_t int_value) +{ + if((settings.report_interval = int_value) == 0) + sys.flags.auto_reporting = Off; + + return Status_OK; +} + static status_code_t set_report_mask (setting_id_t id, uint_fast16_t int_value) { #if COMPATIBILITY_LEVEL <= 1 @@ -1062,7 +1054,7 @@ static status_code_t set_parking_enable (setting_id_t id, uint_fast16_t int_valu static status_code_t set_restore_overrides (setting_id_t id, uint_fast16_t int_value) { - settings.flags.restore_overrides = int_value != 0;; + settings.flags.restore_overrides = int_value != 0; return Status_OK; } @@ -1275,7 +1267,7 @@ static status_code_t set_axis_setting (setting_id_t setting, float value) break; case Setting_AxisAcceleration: - settings.axis[idx].acceleration = override_backup.acceleration[idx] = value * 60.0f * 60.0f; // Convert to mm/min^2 for grbl internal use. + settings.axis[idx].acceleration = override_backup.acceleration[idx] = value * 60.0f * 60.0f; // Convert to mm/sec^2 for grbl internal use. break; case Setting_AxisMaxTravel: @@ -1289,7 +1281,7 @@ static status_code_t set_axis_setting (setting_id_t setting, float value) break; case Setting_AxisBacklash: -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(settings.axis[idx].backlash != value) { axes_signals_t axes; axes.mask = bit(idx); @@ -1342,7 +1334,7 @@ static float get_float (setting_id_t setting) value = -settings.axis[idx].max_travel; // Store as negative for grbl internal use. break; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION case Setting_AxisBacklash: value = settings.axis[idx].backlash; break; @@ -1507,6 +1499,10 @@ static uint32_t get_int (setting_id_t id) value = settings.spindle.flags.type; break; + case Setting_AutoReportInterval: + value = settings.report_interval; + break; + #if N_AXIS > 3 case Settings_Axis_Rotational: value = (settings.steppers.is_rotational.mask & AXES_BITMASK) >> 3; @@ -1770,6 +1766,14 @@ static bool is_setting_available (const setting_detail_t *setting) available = !hal.signals_cap.safety_door_ajar && hal.spindle.cap.at_speed; break; + case Setting_AutoReportInterval: + available = hal.get_elapsed_ticks != NULL; + break; + + case Setting_TimeZoneOffset: + available = hal.rtc.set_datetime != NULL; + break; + default: break; } @@ -1853,7 +1857,7 @@ bool settings_read_coord_data (coord_system_id_t id, float (*coord_data)[N_AXIS] // Write selected tool data to persistent storage. bool settings_write_tool_data (tool_data_t *tool_data) { -#ifdef N_TOOLS +#if N_TOOLS assert(tool_data->tool > 0 && tool_data->tool <= N_TOOLS); // NOTE: idx 0 is a non-persistent entry for tools not in tool table if(hal.nvs.type != NVS_None) @@ -1868,7 +1872,7 @@ bool settings_write_tool_data (tool_data_t *tool_data) // Read selected tool data from persistent storage. bool settings_read_tool_data (uint32_t tool, tool_data_t *tool_data) { -#ifdef N_TOOLS +#if N_TOOLS assert(tool > 0 && tool <= N_TOOLS); // NOTE: idx 0 is a non-persistent entry for tools not in tool table if (!(hal.nvs.type != NVS_None && hal.nvs.memcpy_from_nvs((uint8_t *)tool_data, NVS_ADDR_TOOL_TABLE + (tool - 1) * (sizeof(tool_data_t) + NVS_CRC_BYTES), sizeof(tool_data_t), true) == NVS_TransferResult_OK && tool_data->tool == tool)) { @@ -1895,17 +1899,15 @@ bool read_global_settings () if(settings.spindle.flags.type >= spindle_get_count()) settings.spindle.flags.type = 0; -#ifdef BLOCK_BUFFER_DYNAMIC if(settings.planner_buffer_blocks < 30 || settings.planner_buffer_blocks > 1000) settings.planner_buffer_blocks = 35; -#endif sys.mode = settings.mode; if(!(hal.driver_cap.spindle_sync || hal.driver_cap.spindle_pid)) settings.spindle.ppr = 0; -#if COMPATIBILITY_LEVEL > 1 && DISABLE_G92_PERSISTENCE +#if COMPATIBILITY_LEVEL > 1 && DEFAULT_DISABLE_G92_PERSISTENCE settings.flags.g92_is_volatile = On; #endif @@ -1950,7 +1952,7 @@ void settings_restore (settings_restore_t restore) settings.control_invert.mask &= hal.signals_cap.mask; settings.spindle.invert.ccw &= spindle_get_caps().direction; settings.spindle.invert.pwm &= spindle_get_caps().pwm_invert; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(sys.driver_started) mc_backlash_init((axes_signals_t){AXES_BITMASK}); #endif @@ -1966,7 +1968,7 @@ void settings_restore (settings_restore_t restore) settings_write_coord_data(CoordinateSystem_G92, &coord_data); // Clear G92 offsets -#ifdef N_TOOLS +#if N_TOOLS tool_data_t tool_data; memset(&tool_data, 0, sizeof(tool_data_t)); for (idx = 1; idx <= N_TOOLS; idx++) { @@ -2583,7 +2585,7 @@ void settings_init (void) #endif } else { memset(&tool_table, 0, sizeof(tool_data_t)); // First entry is for tools not in tool table -#ifdef N_TOOLS +#if N_TOOLS uint_fast8_t idx; for (idx = 1; idx <= N_TOOLS; idx++) settings_read_tool_data(idx, &tool_table[idx]); diff --git a/settings.h b/settings.h index 1f97541..73c7336 100644 --- a/settings.h +++ b/settings.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -28,9 +28,8 @@ #include "system.h" #include "plugins.h" -// Version of the persistent storage data. Will be used to migrate existing data from older versions of Grbl -// when firmware is upgraded. Always stored in byte 0 of non-volatile storage -#define SETTINGS_VERSION 21 // NOTE: Check settings_reset() when moving to next version. +// Version of the persistent storage data. Always stored in byte 0 of non-volatile storage. +#define SETTINGS_VERSION 22 // NOTE: Check settings_reset() when moving to next version. // Define axis settings numbering scheme. Starts at Setting_AxisSettingsBase, every INCREMENT, over N_SETTINGS. #define AXIS_SETTINGS_INCREMENT 10 // Must be greater than the number of axis settings. @@ -301,6 +300,31 @@ typedef enum { Setting_VFD_21 = 473, Setting_Fan0OffDelay = 480, + Setting_AutoReportInterval = 481, + Setting_TimeZoneOffset = 482, + Setting_FanToSpindleLink = 483, + + Setting_Macro0 = 490, + Setting_Macro1 = 491, + Setting_Macro2 = 492, + Setting_Macro3 = 493, + Setting_Macro4 = 494, + Setting_Macro5 = 495, + Setting_Macro6 = 496, + Setting_Macro7 = 497, + Setting_Macro8 = 498, + Setting_Macro9 = 499, + + Setting_MacroPort0 = 500, + Setting_MacroPort1 = 501, + Setting_MacroPort2 = 502, + Setting_MacroPort3 = 503, + Setting_MacroPort4 = 504, + Setting_MacroPort5 = 505, + Setting_MacroPort6 = 506, + Setting_MacroPort7 = 507, + Setting_MacroPort8 = 508, + Setting_MacroPort9 = 509, Setting_SettingsMax, Setting_SettingsAll = Setting_SettingsMax, @@ -365,7 +389,7 @@ typedef union { unused1 :1, g92_is_volatile :1, compatibility_level :4, - no_restore_position_after_M6 :1, + no_restore_position_after_M6 :1, unassigned :1; }; } settingflags_t; @@ -493,9 +517,9 @@ typedef union { } homing_settings_flags_t; typedef struct { - float fail_length_percent; // DUAL_AXIS_HOMING_FAIL_AXIS_LENGTH_PERCENT - float fail_distance_max; // DUAL_AXIS_HOMING_FAIL_DISTANCE_MAX - float fail_distance_min; // DUAL_AXIS_HOMING_FAIL_DISTANCE_MIN + float fail_length_percent; // DEFAULT_DUAL_AXIS_HOMING_FAIL_AXIS_LENGTH_PERCENT + float fail_distance_max; // DEFAULT_DUAL_AXIS_HOMING_FAIL_DISTANCE_MAX + float fail_distance_min; // DEFAULT_DUAL_AXIS_HOMING_FAIL_DISTANCE_MIN } homing_dual_axis_t; typedef struct { @@ -517,7 +541,7 @@ typedef struct { axes_signals_t enable_invert; axes_signals_t deenergize; #if N_AXIS > 3 - axes_signals_t is_rotational; // rotational axes are not scaled in imperial mode + axes_signals_t is_rotational; // rotational axes distances are not scaled in imperial mode #endif float pulse_microseconds; float pulse_delay_microseconds; @@ -530,7 +554,7 @@ typedef struct { float acceleration; float max_travel; float dual_axis_offset; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION float backlash; #endif } axis_settings_t; @@ -598,9 +622,9 @@ typedef struct { float junction_deviation; float arc_tolerance; float g73_retract; -#ifdef BLOCK_BUFFER_DYNAMIC + float timezone; + uint16_t report_interval; uint16_t planner_buffer_blocks; -#endif machine_mode_t mode; tool_change_settings_t tool_change; axis_settings_t axis[N_AXIS]; @@ -753,7 +777,7 @@ typedef char *(*setting_get_string_ptr)(setting_id_t id); typedef bool (*setting_output_ptr)(const setting_detail_t *setting, uint_fast16_t offset, void *data); /*! \brief Pointer to callback function to be called when settings are loaded or changed. -\param pointer to \a settings_t struct containing the settings. +\param settings pointer to \a settings_t struct containing the settings. */ typedef void (*settings_changed_ptr)(settings_t *settings); diff --git a/spindle_control.c b/spindle_control.c index e22206c..e438050 100644 --- a/spindle_control.c +++ b/spindle_control.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2012-2015 Sungeun K. Jeon Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -144,6 +144,24 @@ uint8_t spindle_get_count (void) return n_spindle; } +bool spindle_enumerate_spindles (spindle_enumerate_callback_ptr callback) +{ + if(callback == NULL || n_spindle == 0) + return false; + + uint_fast8_t idx = n_spindle; + spindle_info_t spindle; + + do { + spindle.id = --idx; + spindle.hal = spindles[idx]; + spindle.is_current = spindle.hal == current_spindle; + callback(&spindle); + } while(idx); + + return true; +} + // // Null (dummy) spindle, automatically installed if no spindles are registered. // @@ -211,9 +229,14 @@ void spindle_set_override (uint_fast8_t speed_override) spindle_set_state(0, gc_state.modal.spindle, gc_state.spindle.rpm); else sys.step_control.update_spindle_rpm = On; - sys.report.overrides = On; // Set to report change immediately + + sys.report.overrides = On; // Set to report change immediately + if(grbl.on_spindle_programmed) grbl.on_spindle_programmed(gc_state.modal.spindle, spindle_set_rpm(gc_state.spindle.rpm, sys.override.spindle_rpm), gc_state.modal.spindle_rpm_mode); + + if(grbl.on_override_changed) + grbl.on_override_changed(OverrideChanged_SpindleRPM); } } diff --git a/spindle_control.h b/spindle_control.h index 4d2721f..2b8d268 100644 --- a/spindle_control.h +++ b/spindle_control.h @@ -26,6 +26,7 @@ typedef int8_t spindle_id_t; +// if changed to > 8 bits planner_cond_t needs to be changed too typedef union { uint8_t value; uint8_t mask; @@ -162,6 +163,12 @@ typedef struct { spindle_reset_data_ptr reset_data; //!< Optional handler for resetting spindle data. Required for spindle sync. } spindle_ptrs_t; +typedef struct { + spindle_id_t id; + bool is_current; + const spindle_ptrs_t *hal; +} spindle_info_t; + typedef struct { float rpm; float start; @@ -182,6 +189,8 @@ typedef struct { pwm_piece_t piece[SPINDLE_NPWM_PIECES]; } spindle_pwm_t; +typedef void (*spindle_enumerate_callback_ptr)(spindle_info_t *spindle); + void spindle_set_override (uint_fast8_t speed_override); // Called by g-code parser when setting spindle state and requires a buffer sync. @@ -228,6 +237,7 @@ void spindle_add_null (void); uint8_t spindle_get_count (void); bool spindle_select (spindle_id_t spindle_id); + spindle_cap_t spindle_get_caps (void); /*! \brief Update PWM spindle capabilities with run-time determined parameters. @@ -236,6 +246,10 @@ spindle_cap_t spindle_get_caps (void); */ void spindle_update_caps (spindle_pwm_t *pwm_caps); +const spindle_ptrs_t *spindle_get (spindle_id_t spindle_id); + spindle_id_t spindle_get_current (void); +bool spindle_enumerate_spindles (spindle_enumerate_callback_ptr callback); + #endif diff --git a/state_machine.c b/state_machine.c index d8b7fdb..530a9c0 100644 --- a/state_machine.c +++ b/state_machine.c @@ -5,7 +5,7 @@ Part of grblHAL - Copyright (c) 2018-2022 Terje Io + Copyright (c) 2018-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -262,6 +262,8 @@ void state_suspend_manager (void) sys.override.spindle_stop.value = 0; // Clear stop override state spindle_set_state(0, (spindle_state_t){0}, 0.0f); // De-energize sys.override.spindle_stop.enabled = On; // Set stop override state to enabled, if de-energized. + if(grbl.on_override_changed) + grbl.on_override_changed(OverrideChanged_SpindleState); } // Handles restoring of spindle state @@ -272,6 +274,8 @@ void state_suspend_manager (void) else spindle_set_state(0, restore_condition.spindle, restore_spindle_rpm); sys.override.spindle_stop.value = 0; // Clear stop override state + if(grbl.on_override_changed) + grbl.on_override_changed(OverrideChanged_SpindleState); } } else if (sys.step_control.update_spindle_rpm && hal.spindle.get_state().on) { @@ -561,7 +565,9 @@ static void state_await_resume (uint_fast16_t rt_exec) // Restart cycle if (!(sys_state & (STATE_SLEEP|STATE_SAFETY_DOOR))) { + step_control_t step_control = sys.step_control; state_set(STATE_IDLE); + sys.step_control = step_control; state_set(STATE_CYCLE); } diff --git a/stepper.c b/stepper.c index 38d3d3c..a0bbbdd 100644 --- a/stepper.c +++ b/stepper.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2016-2022 Terje Io + Copyright (c) 2016-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -35,15 +35,10 @@ //! \cond -#ifndef ACCELERATION_TICKS_PER_SECOND -#define ACCELERATION_TICKS_PER_SECOND 100 -#endif - // Some useful constants. -#define DT_SEGMENT (1.0f/(ACCELERATION_TICKS_PER_SECOND*60.0f)) // min/segment +#define DT_SEGMENT (1.0f / (ACCELERATION_TICKS_PER_SECOND * 60.0f)) // min/segment #define REQ_MM_INCREMENT_SCALAR 1.25f - typedef enum { Ramp_Accel, Ramp_Cruise, @@ -289,7 +284,7 @@ ISR_CODE void ISR_FUNC(st_go_idle)(void) ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) { -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION static bool backlash_motion; #endif @@ -324,7 +319,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) st.exec_block = st.exec_segment->exec_block; st.step_event_count = st.exec_block->step_event_count; st.new_block = true; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION backlash_motion = st.exec_block->backlash_motion; #endif @@ -446,7 +441,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) if (st.counter_x > st.step_event_count) { step_outbits.x = On; st.counter_x -= st.step_event_count; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(!backlash_motion) #endif sys.position[X_AXIS] = sys.position[X_AXIS] + (st.dir_outbits.x ? -1 : 1); @@ -456,7 +451,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) if (st.counter_y > st.step_event_count) { step_outbits.y = On; st.counter_y -= st.step_event_count; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(!backlash_motion) #endif sys.position[Y_AXIS] = sys.position[Y_AXIS] + (st.dir_outbits.y ? -1 : 1); @@ -466,7 +461,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) if (st.counter_z > st.step_event_count) { step_outbits.z = On; st.counter_z -= st.step_event_count; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(!backlash_motion) #endif sys.position[Z_AXIS] = sys.position[Z_AXIS] + (st.dir_outbits.z ? -1 : 1); @@ -477,7 +472,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) if (st.counter_a > st.step_event_count) { step_outbits.a = On; st.counter_a -= st.step_event_count; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(!backlash_motion) #endif sys.position[A_AXIS] = sys.position[A_AXIS] + (st.dir_outbits.a ? -1 : 1); @@ -489,7 +484,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) if (st.counter_b > st.step_event_count) { step_outbits.b = On; st.counter_b -= st.step_event_count; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(!backlash_motion) #endif sys.position[B_AXIS] = sys.position[B_AXIS] + (st.dir_outbits.b ? -1 : 1); @@ -501,7 +496,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) if (st.counter_c > st.step_event_count) { step_outbits.c = On; st.counter_c -= st.step_event_count; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(!backlash_motion) #endif sys.position[C_AXIS] = sys.position[C_AXIS] + (st.dir_outbits.c ? -1 : 1); @@ -513,7 +508,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) if (st.counter_u > st.step_event_count) { step_outbits.u = On; st.counter_u -= st.step_event_count; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(!backlash_motion) #endif sys.position[U_AXIS] = sys.position[U_AXIS] + (st.dir_outbits.u ? -1 : 1); @@ -525,7 +520,7 @@ ISR_CODE void ISR_FUNC(stepper_driver_interrupt_handler)(void) if (st.counter_v > st.step_event_count) { step_outbits.v = On; st.counter_v -= st.step_event_count; -#ifdef ENABLE_BACKLASH_COMPENSATION +#if ENABLE_BACKLASH_COMPENSATION if(!backlash_motion) #endif sys.position[V_AXIS] = sys.position[V_AXIS] + (st.dir_outbits.v ? -1 : 1); diff --git a/stepper.h b/stepper.h index c394644..46e1f2a 100644 --- a/stepper.h +++ b/stepper.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2019-2022 Terje Io + Copyright (c) 2019-2023 Terje Io Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC Copyright (c) 2009-2011 Simen Svale Skogsrud @@ -26,10 +26,6 @@ #ifndef _STEPPER_H_ #define _STEPPER_H_ -#ifndef SEGMENT_BUFFER_SIZE -#define SEGMENT_BUFFER_SIZE 10 -#endif - typedef enum { SquaringMode_Both = 0, //!< 0 SquaringMode_A, //!< 1 diff --git a/stream.h b/stream.h index dab00db..c7b7a1c 100644 --- a/stream.h +++ b/stream.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2019-2022 Terje Io + Copyright (c) 2019-2023 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -108,13 +108,13 @@ typedef void (*stream_write_ptr)(const char *s); /*! \brief Pointer to function for writing a \a n character long string to the output stream. \param s pointer to string. -\param c number of characters to write. +\param len number of characters to write. */ typedef void (*stream_write_n_ptr)(const char *s, uint16_t len); /*! \brief Pointer to function for writing a single character to the output stream. -\param \a n characters to write. +\param c the character to write. */ typedef bool (*stream_write_char_ptr)(const char c); @@ -138,13 +138,13 @@ typedef bool (*enqueue_realtime_command2_ptr)(char c); /*! \brief Pointer to function for setting the enqueue realtime commands handler. -\param enqueue_realtime_command_ptr pointer to the new handler function. +\param handler a \a enqueue_realtime_command_ptr pointer to the new handler function. \returns \a enqueue_realtime_command_ptr pointer to the replaced function. __NOTE:__ Stream implementations should hold a pointer to the handler in a local variable and typically set it to protocol_enqueue_realtime_command() on initialization. */ -typedef enqueue_realtime_command_ptr (*set_enqueue_rt_handler_ptr)(enqueue_realtime_command_ptr); +typedef enqueue_realtime_command_ptr (*set_enqueue_rt_handler_ptr)(enqueue_realtime_command_ptr handler); /*! \brief Pointer to function for setting the stream baud rate. diff --git a/system.c b/system.c index 75e0eb1..091f95d 100644 --- a/system.c +++ b/system.c @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC Grbl is free software: you can redistribute it and/or modify @@ -205,7 +205,7 @@ PROGMEM static const sys_command_t sys_commands[] = { { "HX", false, home_x }, { "HY", false, home_y }, { "HZ", false, home_z }, -#ifdef AXIS_REMAP_ABC2UVW +#if AXIS_REMAP_ABC2UVW #ifdef A_AXIS { "HU", false, home_a }, #endif @@ -288,7 +288,7 @@ void system_command_help (void) hal.stream.write("$RST=$ - restore default settings" ASCII_EOL); if(settings_get_details()->next) hal.stream.write("$RST=& - restore driver and plugin default settings" ASCII_EOL); -#ifdef N_TOOLS +#if N_TOOLS hal.stream.write("$RST=# - reset offsets and tool data" ASCII_EOL); #else hal.stream.write("$RST=# - reset offsets" ASCII_EOL); @@ -743,7 +743,7 @@ static status_code_t enter_sleep (sys_state_t state, char *args) static status_code_t set_tool_reference (sys_state_t state, char *args) { -#ifdef TOOL_LENGTH_OFFSET_AXIS +#if TOOL_LENGTH_OFFSET_AXIS >= 0 if(sys.flags.probe_succeeded) { sys.tlo_reference_set.mask = bit(TOOL_LENGTH_OFFSET_AXIS); sys.tlo_reference[TOOL_LENGTH_OFFSET_AXIS] = sys.probe_position[TOOL_LENGTH_OFFSET_AXIS]; // - gc_state.tool_length_offset[Z_AXIS])); @@ -796,7 +796,7 @@ static status_code_t build_info (sys_state_t state, char *args) settings_read_build_info(info); report_build_info(info, false); } - #ifndef DISABLE_BUILD_INFO_WRITE_COMMAND + #if !DISABLE_BUILD_INFO_WRITE_COMMAND else if (strlen(args) < (sizeof(stored_line_t) - 1)) settings_write_build_info(args); #endif @@ -826,25 +826,25 @@ static status_code_t settings_reset (sys_state_t state, char *args) else switch (*args) { - #ifndef DISABLE_RESTORE_NVS_DEFAULT_SETTINGS + #if ENABLE_RESTORE_NVS_DEFAULT_SETTINGS case '$': restore.defaults = On; break; #endif - #ifndef DISABLE_RESTORE_NVS_CLEAR_PARAMETERS + #if ENABLE_RESTORE_NVS_CLEAR_PARAMETERS case '#': restore.parameters = On; break; #endif - #ifndef DISABLE_RESTORE_NVS_WIPE_ALL + #if ENABLE_RESTORE_NVS_WIPE_ALL case '*': restore.mask = settings_all.mask; break; #endif - #ifndef DISABLE_RESTORE_DRIVER_PARAMETERS + #if ENABLE_RESTORE_NVS_DRIVER_PARAMETERS case '&': restore.driver_parameters = On; break; diff --git a/system.h b/system.h index b5282b2..aecb245 100644 --- a/system.h +++ b/system.h @@ -3,7 +3,7 @@ Part of grblHAL - Copyright (c) 2017-2022 Terje Io + Copyright (c) 2017-2023 Terje Io Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC Grbl is free software: you can redistribute it and/or modify @@ -210,7 +210,8 @@ typedef union { optional_stop_disable :1, single_block :1, //!< Set to true to disable M1 (optional stop), via realtime command. keep_input :1, //!< Set to true to not flush stream input buffer on executing STOP. - unused :6; + auto_reporting :1, //!< Set to true when auto real time reporting is enabled. + unused :5; }; } system_flags_t; diff --git a/tool_change.c b/tool_change.c index ce5932d..6a99fdf 100644 --- a/tool_change.c +++ b/tool_change.c @@ -5,7 +5,7 @@ Part of grblHAL - Copyright (c) 2020-2022 Terje Io + Copyright (c) 2020-2023 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -92,7 +92,7 @@ static void reset (void) { if(next_tool) { //TODO: move to gc_xxx() function? // Restore previous tool if reset is during change -#ifdef N_TOOLS +#if N_TOOLS if((sys.report.tool = current_tool.tool != next_tool->tool)) memcpy(gc_state.tool, ¤t_tool, sizeof(tool_data_t)); #else @@ -305,7 +305,7 @@ static status_code_t tool_change (parser_state_t *parser_state) return Status_GcodeUnsupportedCommand; #endif -#ifdef TOOL_LENGTH_OFFSET_AXIS +#if TOOL_LENGTH_OFFSET_AXIS >= 0 plane.axis_linear = TOOL_LENGTH_OFFSET_AXIS; #if TOOL_LENGTH_OFFSET_AXIS == X_AXIS plane.axis_0 = Y_AXIS; diff --git a/wall_plotter.c b/wall_plotter.c index 841da10..7f4e130 100644 --- a/wall_plotter.c +++ b/wall_plotter.c @@ -26,7 +26,7 @@ #include "grbl.h" -#ifdef WALL_PLOTTER +#if WALL_PLOTTER #include #include