grblHAL core
20260206
grbl.h
Go to the documentation of this file.
1
/*
2
grbl.h - main grblHAL include file for compile time configuration
3
4
Part of grblHAL
5
6
Copyright (c) 2017-2026 Terje Io
7
Copyright (c) 2015-2016 Sungeun K. Jeon for Gnea Research LLC
8
9
grblHAL is free software: you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or
12
(at your option) any later version.
13
14
grblHAL is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with grblHAL. If not, see <http://www.gnu.org/licenses/>.
21
*/
22
23
#ifndef _GRBL_H_
24
#define _GRBL_H_
25
26
#ifdef __SAM3X8E__
27
#define _WIRING_CONSTANTS_
// for shutting up compiler warnings due to bad framework code for Arduino Due
28
#endif
29
30
#include <stdint.h>
31
#include <stdbool.h>
32
33
#ifdef ARDUINO
34
#include <Arduino.h>
35
#endif
36
37
#include "
config.h
"
38
39
// grblHAL versioning system
40
#if COMPATIBILITY_LEVEL == 0
41
#define GRBL_VERSION "1.1f"
42
#else
43
#define GRBL_VERSION "1.1f"
44
#endif
45
#define GRBL_BUILD 20260206
46
47
#define GRBL_URL "https://github.com/grblHAL"
48
49
// The following symbols are set here if not already set by the compiler or in config.h
50
// Do NOT change here!
51
52
#ifndef DCRAM
53
//#if defined(__IMXRT1062__)
54
//#define DCRAM DMAMEM
55
//#else
56
#define DCRAM
57
//#endif
58
#endif
59
60
#ifdef GRBL_ESP32
61
#include "esp_attr.h"
62
#define ISR_CODE IRAM_ATTR
63
#elif !defined(ISR_CODE)
64
// #define ISR_CODE __attribute__((long_call, section(".data")))
65
// Used to decorate code run in interrupt context.
66
// Do not remove or change unless you know what you are doing.
67
#define ISR_CODE
68
#endif
69
70
#ifdef RP2040
71
#include "pico.h"
72
#define ISR_FUNC(fn) __not_in_flash_func(fn)
73
#else
74
#define ISR_FUNC(fn) fn
75
#endif
76
77
#ifndef __IMXRT1062__
78
#define FLASHMEM
79
#endif
80
81
#ifndef PROGMEM
82
#define PROGMEM
83
#endif
84
85
#ifndef __STATIC_FORCEINLINE
86
#define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline
87
#endif
88
89
#if (COREXY || WALL_PLOTTER || DELTA_ROBOT || POLAR_ROBOT || MASLOW_ROUTER) && !defined(KINEMATICS_API)
90
#define KINEMATICS_API
91
#endif
92
93
// The following symbols are default values that are unlikely to be changed
94
// Do not change unless you know what you are doing!
95
96
// Define realtime command special characters. These characters are 'picked-off' directly from the
97
// serial read data stream and are not passed to the grblHAL line execution parser. Select characters
98
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
99
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
100
// g-code programs, maybe selected for interface programs.
101
// NOTE: If changed, manually update help message in report.c.
102
103
#define CMD_EXIT 0x03
104
#define CMD_REBOOT 0x14
105
#define CMD_RESET 0x18
106
#define CMD_STOP 0x19
107
#define CMD_STATUS_REPORT_LEGACY '?'
108
#define CMD_CYCLE_START_LEGACY '~'
109
#define CMD_FEED_HOLD_LEGACY '!'
110
#define CMD_PROGRAM_DEMARCATION '%'
111
112
// NOTE: All realtime commands must be in the extended ASCII character set, starting
113
// at character value 128 (0x80) and up to 191 (0xBF). Do not assign values > 191 since those
114
// are for the first character in UTF-8 code points.
115
#define CMD_STATUS_REPORT 0x80
// (128) TODO: use 0x05 ctrl-E ENQ instead?
116
#define CMD_CYCLE_START 0x81
// (129) TODO: use 0x06 ctrl-F ACK instead? or SYN/DC2/DC3?
117
#define CMD_FEED_HOLD 0x82
// (130) TODO: use 0x15 ctrl-U NAK instead?
118
#define CMD_GCODE_REPORT 0x83
// (131)
119
#define CMD_SAFETY_DOOR 0x84
// (132)
120
#define CMD_JOG_CANCEL 0x85
// (133)
121
//#define CMD_DEBUG_REPORT 0x86 // Only when DEBUG enabled, sends debug report in '{}' braces.
122
#define CMD_STATUS_REPORT_ALL 0x87
// (135)
123
#define CMD_OPTIONAL_STOP_TOGGLE 0x88
// (136)
124
#define CMD_SINGLE_BLOCK_TOGGLE 0x89
// (137)
125
#define CMD_OVERRIDE_FAN0_TOGGLE 0x8A
126
#define CMD_MPG_MODE_TOGGLE 0x8B
127
#define CMD_AUTO_REPORTING_TOGGLE 0x8C
128
#define CMD_OVERRIDE_FEED_RESET 0x90
129
#define CMD_OVERRIDE_FEED_COARSE_PLUS 0x91
// (145)
130
#define CMD_OVERRIDE_FEED_COARSE_MINUS 0x92
// (146)
131
#define CMD_OVERRIDE_FEED_FINE_PLUS 0x93
// (147)
132
#define CMD_OVERRIDE_FEED_FINE_MINUS 0x94
// (148)
133
#define CMD_OVERRIDE_RAPID_RESET 0x95
134
#define CMD_OVERRIDE_RAPID_MEDIUM 0x96
// (150)
135
#define CMD_OVERRIDE_RAPID_LOW 0x97
// (151)
136
// #define CMD_OVERRIDE_RAPID_EXTRA_LOW 0x98 // *NOT SUPPORTED*
137
#define CMD_OVERRIDE_SPINDLE_RESET 0x99
// (153) Restores spindle override value to 100%.
138
#define CMD_OVERRIDE_SPINDLE_COARSE_PLUS 0x9A
// (154)
139
#define CMD_OVERRIDE_SPINDLE_COARSE_MINUS 0x9B
// (155)
140
#define CMD_OVERRIDE_SPINDLE_FINE_PLUS 0x9C
// (156)
141
#define CMD_OVERRIDE_SPINDLE_FINE_MINUS 0x9D
// (157)
142
#define CMD_OVERRIDE_SPINDLE_STOP 0x9E
// (158)
143
#define CMD_OVERRIDE_COOLANT_FLOOD_TOGGLE 0xA0
// (160)
144
#define CMD_OVERRIDE_COOLANT_MIST_TOGGLE 0xA1
// (161)
145
#define CMD_PID_REPORT 0xA2
// (162)
146
#define CMD_TOOL_ACK 0xA3
// (163)
147
#define CMD_PROBE_CONNECTED_TOGGLE 0xA4
// (164)
148
// The following character codes are reserved for plugin use
149
#define CMD_MACRO_0 0xB0
// (176)
150
#define CMD_MACRO_1 0xB1
// (177)
151
#define CMD_MACRO_2 0xB2
// (178)
152
#define CMD_MACRO_3 0xB3
// (179)
153
#define CMD_MACRO_4 0xB4
// (180)
154
#define CMD_MACRO_5 0xB5
// (181)
155
#define CMD_MACRO_6 0xB6
// (182)
156
#define CMD_MACRO_7 0xB7
// (183)
157
158
// System motion line numbers must be zero.
159
#define JOG_LINE_NUMBER 0
160
161
// Number of blocks grblHAL executes upon startup. These blocks are stored in non-volatile storage, where the size
162
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
163
// be stored and executed in order. These startup blocks would typically be used to set the g-code
164
// parser state depending on user preferences.
165
#define N_STARTUP_LINE 2
// Integer (1-2)
166
167
// Number of decimal places (scale) output by grblHAL for certain value types. These settings
168
// are determined by realistic and commonly observed values in CNC machines. For example, position
169
// values cannot be less than 0.001mm or 0.0001in, because machines can not be physically more
170
// precise this. So, there is likely no need to change these, but you can if you need to here.
171
// NOTE: Must be an integer value from 0 to ~4. More than 4 may exhibit round-off errors.
172
#define N_DECIMAL_COORDVALUE_INCH 4
// Coordinate or position value in inches
173
#define N_DECIMAL_COORDVALUE_MM 3
// Coordinate or position value in mm
174
#define N_DECIMAL_RATEVALUE_INCH 1
// Rate or velocity value in in/min
175
#define N_DECIMAL_RATEVALUE_MM 0
// Rate or velocity value in mm/min
176
#define N_DECIMAL_SETTINGVALUE 3
// Floating point setting values
177
#define N_DECIMAL_RPMVALUE 0
// RPM value in rotations per min
178
#define N_DECIMAL_PIDVALUE 3
// PID value
179
180
// ---------------------------------------------------------------------------------------
181
// ADVANCED CONFIGURATION OPTIONS:
182
183
// Enables code for debugging purposes. Not for general use and always in constant flux.
184
// #define DEBUG // Uncomment to enable. Default disabled.
185
186
// Configure rapid, feed, and spindle override settings. These values define the max and min
187
// allowable override values and the coarse and fine increments per command received. Please
188
// note the allowable values in the descriptions following each define.
189
#define DEFAULT_FEED_OVERRIDE 100
// 100%. Don't change this value.
190
#ifndef MAX_FEED_RATE_OVERRIDE
191
#define MAX_FEED_RATE_OVERRIDE 200
// Percent of programmed feed rate (100-65535). Usually 120% or 200%
192
#endif
193
#ifndef MIN_FEED_RATE_OVERRIDE
194
#define MIN_FEED_RATE_OVERRIDE 10
// Percent of programmed feed rate (1-100). Usually 50% or 1%
195
#endif
196
#define FEED_OVERRIDE_COARSE_INCREMENT 10
// (1-99). Usually 10%.
197
#define FEED_OVERRIDE_FINE_INCREMENT 1
// (1-99). Usually 1%.
198
199
#define DEFAULT_RAPID_OVERRIDE 100
// 100%. Don't change this value.
200
#define RAPID_OVERRIDE_MEDIUM 50
// Percent of rapid (1-99). Usually 50%.
201
#define RAPID_OVERRIDE_LOW 25
// Percent of rapid (1-99). Usually 25%.
202
// #define RAPID_OVERRIDE_EXTRA_LOW 5 // *NOT SUPPORTED* Percent of rapid (1-99). Usually 5%.
203
204
#define DEFAULT_SPINDLE_RPM_OVERRIDE 100
// 100%. Don't change this value.
205
#ifndef MAX_SPINDLE_RPM_OVERRIDE
206
#define MAX_SPINDLE_RPM_OVERRIDE 200
// Percent of programmed spindle speed (100-65535). Usually 200%.
207
#endif
208
#ifndef MIN_SPINDLE_RPM_OVERRIDE
209
#define MIN_SPINDLE_RPM_OVERRIDE 10
// Percent of programmed spindle speed (1-100). Usually 10%.
210
#endif
211
#define SPINDLE_OVERRIDE_COARSE_INCREMENT 10
// (1-99). Usually 10%.
212
#define SPINDLE_OVERRIDE_FINE_INCREMENT 1
// (1-99). Usually 1%.
213
214
// Adaptive Multi-Axis Step Smoothing (AMASS) is an advanced feature that does what its name implies,
215
// smoothing the stepping of multi-axis motions. This feature smooths motion particularly at low step
216
// frequencies below 10kHz, where the aliasing between axes of multi-axis motions can cause audible
217
// noise and shake your machine. At even lower step frequencies, AMASS adapts and provides even better
218
// step smoothing. See stepper.c for more details on the AMASS system works.
219
#ifndef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
220
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING 1
// Default enabled. Set to 0 to disable.
221
#endif
222
223
// Define Adaptive Multi-Axis Step-Smoothing(AMASS) levels and cutoff frequencies. The highest level
224
// frequency bin starts at 0Hz and ends at its cutoff frequency. The next lower level frequency bin
225
// starts at the next higher cutoff frequency, and so on. The cutoff frequencies for each level must
226
// be considered carefully against how much it over-drives the stepper ISR, the accuracy of the 16-bit
227
// timer, and the CPU overhead. Level 0 (no AMASS, normal operation) frequency bin starts at the
228
// Level 1 cutoff frequency and up to as fast as the CPU allows (over 30kHz in limited testing).
229
// NOTE: AMASS cutoff frequency multiplied by ISR overdrive factor must not exceed maximum step frequency.
230
// NOTE: Current settings are set to overdrive the ISR to no more than 16kHz, balancing CPU overhead
231
// and timer accuracy. Do not alter these settings unless you know what you are doing.
232
#if ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
233
#ifndef MAX_AMASS_LEVEL
234
#define MAX_AMASS_LEVEL 3
235
#endif
236
#if MAX_AMASS_LEVEL <= 0
237
error
"AMASS must have 1 or more levels to operate correctly."
238
#endif
239
#endif
240
241
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
242
// the selected axis with the tool oriented toward the negative direction. In other words, a positive
243
// tool length offset value is subtracted from the current location.
244
#if COMPATIBILITY_LEVEL > 2 && TOOL_LENGTH_OFFSET_AXIS == -1
245
#undef TOOL_LENGTH_OFFSET_AXIS
246
#define TOOL_LENGTH_OFFSET_AXIS Z_AXIS
// Default z-axis. Valid values are X_AXIS, Y_AXIS, or Z_AXIS.
247
#endif
248
249
// Max length of gcode lines (blocks) stored in non-volatile storage
250
#if N_AXIS == 6 && COMPATIBILITY_LEVEL <= 1
251
#define MAX_STORED_LINE_LENGTH 60
// do not change!
252
#else
253
#define MAX_STORED_LINE_LENGTH 70
// do not set > 70 unless less than 5 axes are enabled or COMPATIBILITY_LEVEL > 1
254
#endif
255
256
#if N_SPINDLE > 4
257
#define N_SPINDLE_SELECTABLE 4
// Max 4. for now!
258
#else
259
#define N_SPINDLE_SELECTABLE N_SPINDLE
260
#endif
261
262
typedef
uint_fast16_t
override_t
;
263
264
#endif
config.h
This file contains compile-time and run-time configurations for grblHAL's internal system....
override_t
uint_fast16_t override_t
Definition:
grbl.h:262
STM
grblHAL Driver STM32F756
grbl
grbl.h
Generated by
1.9.1