30 #if NGC_EXPRESSIONS_ENABLE
45 #define EXEC_STATUS_REPORT bit(0)
46 #define EXEC_CYCLE_START bit(1)
47 #define EXEC_CYCLE_COMPLETE bit(2)
48 #define EXEC_FEED_HOLD bit(3)
49 #define EXEC_STOP bit(4)
50 #define EXEC_RESET bit(5)
51 #define EXEC_SAFETY_DOOR bit(6)
52 #define EXEC_MOTION_CANCEL bit(7)
53 #define EXEC_SLEEP bit(8)
54 #define EXEC_TOOL_CHANGE bit(9)
55 #define EXEC_PID_REPORT bit(10)
56 #define EXEC_GCODE_REPORT bit(11)
57 #define EXEC_TLO_REPORT bit(12)
58 #define EXEC_RT_COMMAND bit(13)
59 #define EXEC_DOOR_CLOSED bit(14)
75 #define STATE_ALARM bit(0)
76 #define STATE_CHECK_MODE bit(1)
77 #define STATE_HOMING bit(2)
78 #define STATE_CYCLE bit(3)
79 #define STATE_HOLD bit(4)
80 #define STATE_JOG bit(5)
81 #define STATE_SAFETY_DOOR bit(6)
82 #define STATE_SLEEP bit(7)
83 #define STATE_ESTOP bit(8)
84 #define STATE_TOOL_CHANGE bit(9)
164 float target[PID_LOG];
165 float actual[PID_LOG];
320 typedef const char *(*sys_help_ptr)(
const char *command);
368 #define system_set_exec_state_flag(mask) hal.set_bits_atomic(&sys.rt_exec_state, (mask))
369 #define system_clear_exec_state_flag(mask) hal.clear_bits_atomic(&sys.rt_exec_state, (mask))
370 #define system_clear_exec_states() hal.set_value_atomic(&sys.rt_exec_state, 0)
371 #define system_set_exec_alarm(code) hal.set_value_atomic(&sys.rt_exec_alarm, (uint_fast16_t)(code))
372 #define system_clear_exec_alarm() hal.set_value_atomic(&sys.rt_exec_alarm, 0)
alarm_code_t
Definition: alarms.h:28
#define N_AXIS
Defines number of axes supported - minimum 3, maximum 8. If more than 3 axes are configured a complia...
Definition: config.h:42
uint_fast16_t override_t
Definition: grbl.h:236
probing_state_t
Definition: probe.h:27
Limit switches struct, consists of four packed axes_signals_t structs in 32 bits.
Definition: nuts_bolts.h:157
override_t rapid_rate
Rapids override value in percent.
Definition: system.h:225
override_t spindle_rpm
NOTE: Not used by the core, it maintain per spindle override in spindle_param_t
Definition: system.h:226
gc_override_flags_t control
Tracks override control states.
Definition: system.h:228
override_t feed_rate
Feed rate override value in percent.
Definition: system.h:224
spindle_stop_t spindle_stop
Tracks spindle stop override states.
Definition: system.h:227
limit_signals_t limits
Definition: system.h:261
control_signals_t control
Definition: system.h:260
sys_command_flags_t flags
Definition: system.h:336
sys_command_ptr execute
Definition: system.h:335
const char * command
Definition: system.h:334
sys_help_ptr fn
Definition: system.h:339
const char * str
Definition: system.h:338
const uint8_t n_commands
Definition: system.h:344
struct sys_commands_str * next
Definition: system.h:346
const sys_command_t * commands
Definition: system.h:345
Global system variables struct.
Definition: system.h:271
axes_signals_t tlo_reference_set
Axes with tool length reference offset set.
Definition: system.h:279
axes_signals_t homed
Indicates which axes has been homed.
Definition: system.h:302
float home_position[N_AXIS]
Home position for homed axes.
Definition: system.h:303
int32_t probe_position[N_AXIS]
Last probe position in machine coordinates and steps.
Definition: system.h:292
int32_t var5399
Last result from M66 - wait on input.
Definition: system.h:296
parking_state_t parking_state
Tracks parking state.
Definition: system.h:289
system_override_delay_t override_delay
Flags for delayed overrides.
Definition: system.h:287
volatile probing_state_t probing_state
Probing state value. Used to coordinate the probing cycle with stepper ISR.
Definition: system.h:293
bool blocking_event
Set when a blocking event that requires reset to clear is active.
Definition: system.h:277
system_flags_t flags
Assorted state flags.
Definition: system.h:282
bool position_lost
Set when mc_reset is called when machine is moving.
Definition: system.h:275
bool reset_pending
Set when reset processing is underway.
Definition: system.h:276
volatile bool steppers_deenergize
Set to true to deenergize stepperes.
Definition: system.h:278
hold_state_t holding_state
Tracks holding state.
Definition: system.h:290
axes_signals_t hard_limits
temporary?, will be removed when available in settings.
Definition: system.h:314
alarm_code_t alarm_pending
Delayed alarm, currently used for probe protection.
Definition: system.h:281
axes_signals_t homing_axis_lock
Locks axes when limits engage. Used as an axis motion mask in the stepper ISR.
Definition: system.h:284
bool suspend
System suspend state flag.
Definition: system.h:274
volatile rt_exec_t rt_exec_state
Realtime executor bitflag variable for state management. See EXEC bitmasks.
Definition: system.h:294
bool abort
System abort flag. Forces exit back to main loop for reset.
Definition: system.h:272
bool driver_started
Set to true when driver initialization is completed.
Definition: system.h:310
axes_signals_t homing
Axes with homing enabled.
Definition: system.h:285
int32_t tlo_reference[N_AXIS]
Tool length reference offset.
Definition: system.h:280
int32_t position[N_AXIS]
Real-time machine (aka home) position vector in steps.
Definition: system.h:313
bool cold_start
Set to true on boot, is false on subsequent soft resets.
Definition: system.h:309
volatile uint_fast16_t rt_exec_alarm
Realtime executor bitflag variable for setting various alarms.
Definition: system.h:295
bool mpg_mode
To be moved to system_flags_t.
Definition: system.h:311
work_envelope_t work_envelope
Work envelope, only valid for homed axes.
Definition: system.h:304
report_tracking_flags_t report
Tracks when to add data to status reports.
Definition: system.h:288
signal_event_t last_event
Last signal events (control and limits signal).
Definition: system.h:312
step_control_t step_control
Governs the step segment generator depending on system state.
Definition: system.h:283
axes_signals_t soft_limits
temporary, will be removed when available in settings.
Definition: system.h:315
alarm_code_t alarm
Current alarm, only valid if system state is STATE_ALARM.
Definition: system.h:308
bool cancel
System cancel flag.
Definition: system.h:273
coord_system_id_t probe_coordsys_id
Coordinate system in which last probe took place.
Definition: system.h:291
coord_data_t max
Definition: system.h:266
coord_data_t min
Definition: system.h:265
report_tracking_flags_t system_get_rt_report_flags(void)
Get the active realtime report addon flags for the next report.
Definition: system.c:1220
void system_clear_tlo_reference(axes_signals_t homing_cycle)
Called on homing state changes.
Definition: system.c:1123
void control_interrupt_handler(control_signals_t signals)
Pin change interrupt handler for pin-out commands, i.e. cycle start, feed hold, reset etc....
Definition: system.c:61
void system_execute_startup(void)
Executes user startup scripts, if stored.
Definition: system.c:132
hold_state_t
Definition: system.h:101
@ Hold_Pending
2
Definition: system.h:104
@ Hold_Complete
1
Definition: system.h:103
@ Hold_NotHolding
0
Definition: system.h:102
const char *(* sys_help_ptr)(const char *command)
Definition: system.h:320
status_code_t(* sys_command_ptr)(sys_state_t state, char *args)
Definition: system.h:319
void system_output_help(const sys_command_t *commands, uint32_t num_commands)
Definition: system.c:978
void system_command_help(void)
Definition: system.c:988
void system_register_commands(sys_commands_t *commands)
Definition: system.c:941
void system_init_switches(void)
Definition: system.c:46
void system_flag_wco_change(void)
Called on a work coordinate (WCO) changes.
Definition: system.c:1146
system_t sys
System global variable structure.
Definition: grbllib.c:86
struct system system_t
Global system variables struct.
machine_mode_t
Definition: system.h:87
@ Mode_Standard
Definition: system.h:88
@ Mode_Lathe
Definition: system.h:90
@ Mode_Laser
Definition: system.h:89
parking_state_t
Definition: system.h:93
@ Parking_Retracting
2
Definition: system.h:96
@ Parking_Cancel
3
Definition: system.h:97
@ Parking_DoorClosed
0
Definition: system.h:94
@ Parking_DoorAjar
1
Definition: system.h:95
@ Parking_Resuming
4
Definition: system.h:98
bool system_xy_at_fixture(coord_system_id_t id, float tolerance)
Checks if XY position is within coordinate system XY with given tolerance.
Definition: system.c:1182
uint_fast16_t rt_exec_t
See rt_exec.
Definition: system.h:107
report_tracking_t
Definition: system.h:170
@ Report_PWM
Definition: system.h:184
@ Report_Scaling
Definition: system.h:173
@ Report_Homed
Definition: system.h:174
@ Report_ClearAll
Definition: system.h:171
@ Report_GWCO
Definition: system.h:181
@ Report_WCO
Definition: system.h:180
@ Report_Overrides
Definition: system.h:178
@ Report_CycleStart
Definition: system.h:191
@ Report_Motor
Definition: system.h:185
@ Report_All
Definition: system.h:192
@ Report_MPGMode
Definition: system.h:172
@ Report_LatheXMode
Definition: system.h:175
@ Report_TLOReference
Definition: system.h:187
@ Report_SpindleId
Definition: system.h:189
@ Report_ForceWCO
Definition: system.h:190
@ Report_Encoder
Definition: system.h:186
@ Report_Fan
Definition: system.h:188
@ Report_Coolant
Definition: system.h:177
@ Report_Spindle
Definition: system.h:176
@ Report_ToolOffset
Definition: system.h:182
@ Report_Tool
Definition: system.h:179
@ Report_M66Result
Definition: system.h:183
void system_convert_array_steps_to_mpos(float *position, int32_t *steps)
Sets machine position. Must be sent a 'step' array.
Definition: system.c:1164
status_code_t system_execute_line(char *line)
Directs and executes one line of input from protocol_process.
Definition: system.c:1014
void system_add_rt_report(report_tracking_t report)
Set(s) or clear all active realtime report addon flag(s) for the next report.
Definition: system.c:1230
void system_raise_alarm(alarm_code_t alarm)
Raise and report a system alarm.
Definition: system.c:1199
struct sys_commands_str sys_commands_t
uint_fast16_t sys_state_t
See sys_state.
Definition: system.h:108
Definition: nuts_bolts.h:130
uint16_t probe_overtravel
Definition: system.h:140
uint16_t stop_disable
Definition: system.h:132
uint16_t limits_override
Definition: system.h:137
uint16_t cycle_start
Definition: system.h:129
uint16_t unassigned
Definition: system.h:139
uint16_t feed_hold
Definition: system.h:128
uint16_t probe_disconnected
Definition: system.h:134
uint16_t reset
Definition: system.h:127
uint16_t safety_door_ajar
Definition: system.h:130
uint16_t motor_fault
Definition: system.h:135
uint16_t motor_warning
Definition: system.h:136
uint16_t deasserted
used for probe protection
Definition: system.h:142
uint16_t mask
Definition: system.h:125
uint16_t e_stop
M1.
Definition: system.h:133
uint16_t block_delete
Definition: system.h:131
uint16_t value
Definition: system.h:124
uint16_t probe_triggered
used for probe protection
Definition: system.h:141
uint16_t single_block
Definition: system.h:138
Coordinate data.
Definition: gcode.h:342
Override flags.
Definition: gcode.h:329
uint32_t tlo_reference
Tool length offset reference changed.
Definition: system.h:213
uint32_t force_wco
Add work coordinates (due to WCO changed during motion).
Definition: system.h:217
uint32_t tool
Tool changed.
Definition: system.h:205
uint32_t wco
Add work coordinates.
Definition: system.h:206
uint32_t cycle_start
Cycle start signal triggered. NOTE: do NOT add to Report_All enum above!
Definition: system.h:218
uint32_t unassigned
Definition: system.h:216
uint32_t gwco
Add work coordinate.
Definition: system.h:207
uint32_t fan
Fan on/off changed.
Definition: system.h:214
uint32_t mpg_mode
MPG mode changed.
Definition: system.h:198
uint32_t all
Set when CMD_STATUS_REPORT_ALL is requested, may be used by user code.
Definition: system.h:219
uint32_t motor
Add motor information (optional: to be added by driver).
Definition: system.h:211
uint32_t spindle_id
Spindle changed.
Definition: system.h:215
uint32_t tool_offset
Tool offsets changed.
Definition: system.h:208
uint32_t m66result
M66 result updated.
Definition: system.h:209
uint32_t spindle
Spindle state changed.
Definition: system.h:202
uint32_t homed
Homed state changed.
Definition: system.h:200
uint32_t scaling
Scaling (G50/G51) changed.
Definition: system.h:199
uint32_t pwm
Add PWM information (optional: to be added by driver).
Definition: system.h:210
uint32_t encoder
Add encoder information (optional: to be added by driver).
Definition: system.h:212
uint32_t value
Definition: system.h:196
uint32_t coolant
Coolant state changed.
Definition: system.h:203
uint32_t overrides
Overrides changed.
Definition: system.h:204
uint32_t xmode
Lathe radius/diameter mode changed.
Definition: system.h:201
uint8_t enabled
Definition: system.h:150
uint8_t restore_cycle
Definition: system.h:153
uint8_t unassigned
Definition: system.h:154
uint8_t value
Definition: system.h:148
uint8_t initiate
Definition: system.h:151
uint8_t restore
Definition: system.h:152
uint8_t end_motion
Definition: system.h:114
uint8_t unassigned
Definition: system.h:118
uint8_t execute_sys_motion
Definition: system.h:116
uint8_t flags
Definition: system.h:112
uint8_t update_spindle_rpm
Definition: system.h:117
uint8_t execute_hold
Definition: system.h:115
uint8_t help_fn
Definition: system.h:327
uint8_t flags
Definition: system.h:323
uint8_t allow_blocking
System command can be used when blocking event is active.
Definition: system.h:326
uint8_t noargs
System command does not handle arguments.
Definition: system.h:325
uint8_t unused
Definition: system.h:328
uint16_t exit
System exit flag. Used in combination with abort to terminate main loop.
Definition: system.h:247
uint16_t feed_hold_pending
Definition: system.h:249
uint16_t keep_input
Set to true to not flush stream input buffer on executing STOP.
Definition: system.h:252
uint16_t optional_stop_disable
Definition: system.h:250
uint16_t unused
Definition: system.h:255
uint16_t synchronizing
Set to true when protocol_buffer_synchronize() is running.
Definition: system.h:254
uint16_t soft_limit
Tracks soft limit errors for the state machine.
Definition: system.h:246
uint16_t value
Definition: system.h:242
uint16_t probe_succeeded
Tracks if last probing cycle was successful.
Definition: system.h:245
uint16_t auto_reporting
Set to true when auto real time reporting is enabled.
Definition: system.h:253
uint16_t mpg_mode
MPG mode flag. Set when switched to secondary input stream. (unused for now).
Definition: system.h:244
uint16_t block_delete_enabled
Set to true to enable block delete.
Definition: system.h:248
uint16_t single_block
Set to true to disable M1 (optional stop), via realtime command.
Definition: system.h:251
uint8_t spindle
Definition: system.h:236
uint8_t feedrate
Definition: system.h:234
uint8_t coolant
Definition: system.h:235
uint8_t flags
Definition: system.h:232
uint8_t unused
Definition: system.h:237