Macros are a short series of gcodes and commands. You can define macros in your config file. These are usually associated with controller buttons and events. Macros can also be defined separately in the WebUI, pendants and gcode senders. See the documentation on those for help with that.
Macros can be used to execute some commands with the click of a button. These commands can be most gcode and FluidNC commands including running a file from the SD card. If you have more than one command, separate them with an ampersand "&". The use of "&" to split a line into multiple GCode commands only works for startup lines; it is not a general GCode feature.
Macros are generally intended for use with gcode. Some $ commands can be used in macros but you need to be careful when mixing it with gcode. $ commands typically require an Idle state. Otherwise they will be rejected.
If you want to execute a $ command after a gcode command it is best to add a short delay (G4) to wait force to complete the motion first.
Many commands cannot be used in macros. These are typically things that change the configuration of FluidNC
Realtime characters are single byte commands the FluidNC typically processed immediately. They are typically none ASCII printable characters, so there is a special method to include them in macros.
Send the # character, then the 2 letter abreviation for the command. Below is the list.
"fr" Feedrate Override Reset
"f>" Feedrate override Coarse Increase
"f<" Feedrate override Coarse Decrease
"f+" Feedrate override Fine Increase
"f-" Feedrate override Fine Decrease
"rr" Rapid Override Reset
"rm" Rapid Override Medium
"rl" Rapid Override Low
"rx" Rapid Override Extra Low
"sr" Spindle Override Reset
"s>" Spindle Override Coarse Plus
"s<" Spindle Override Coarse Minus
"s+" Spindle Override Fine Plus
"s-" Spindle Override Fine Minus
"ss" Spindle Override Stop
"ft" Flood coolant Toggle
"mt" Mist coolant Toggle
Gcode can also be used as a simple programming language when you add paramters and expressions
startup_line0: & startup_line1: These are legacy features from Grbl, which called them $N0 and $N1. These run when the firmware enters idle for the first time.
macro0 through macro3 This is the text of the macro that will run when the associated control switch is activated. These switches must not be in the active state at startup. You need to deactivate the switch before you clear the alarm.
after_homing (as of v3.7.6) This macro runs after homing is complete, i.e. after every axis that has homing enabled has been homed.
after_reset (as of v3.7.6) This macro runs after the system has been reset, either from an initial power on/startup, or after a CTRL-X realtime reset, but only if the system is in Idle state immediately after the reset.
after_unlock (as of v3.7.6) This macro runs after a $X unlock command.
macros:
startup_line0:
startup_line1:
macro0: G90&G53G0Z-1&G0X0Y0
macro1: $SD/Run=drill.nc
macro2:
macro3:
after_homing: g0 x1 y1
after_reset: g20
after_unlock: g91
Send $Macros/Run=<macro number>
or $RM=<macro number>
like $Macros/Run=0
or $RM=0
. See the commands page. Unnumbered macros cannot be run from a command, except by triggering the associated event (e.g. you could send $x
to run after_unlock
).
Setup a macro<switch>_pin:
in the control section.