Device Settings: Custom GCode
The Custom GCode tab of Device Settings allows for advanced GCode customization when using the Custom GCode device type.
The Custom GCode tab of Device Settings
Custom GCode Options¶
In this section, you can set some baseline options for your custom GCode profile.
| Name | Description |
|---|---|
| GCode Flavor | What flavor of GCode to use as a base |
| Dwell Units | Whether pause times are given in seconds or milliseconds |
| Comment Characters | What character(s) are used to indicate comments |
| Escape Character | The character used to escape text sequences |
| Suppress Comments | Enabling this will strip all comments from the GCode LightBurn generates |
| Verbose Output | Enabling this output will include additional detail in the generated GCode that can help with debugging |
| Save File Extension | Specify the file extension to be used, if you need something other than the default of .gc |
| Save to Single File | Enabling this will cause LightBurn to always export GCode as a single file, rather than showing the export file dialog box |
| Tool State Automatic | Enabling this will cause the tool to automatically turn on during a cut move |
| Variable Laser Power | Enabling this will allow you to control the laser's power beyond on and off |
| Enable Q-Pulse Options | Enabling this will allow you to control Q-Pulse settings. Only relevant with fiber laser sources |
| Supports G53 Command | Specify whether or not the device supports the G53 command. Disable for WeCreat devices |
| Fetch configuration on connect | Specify whether or not to fetch the device's configuration on connection. Disable for WeCreat devices |
| Check for Workpiece Offsets on Connect | Specify whether or not to check for workpiece offsets when connecting to the machine |
GCode Commands¶
This section lists each command that can be customized. Leaving a command blank will leave it unchanged from the default based on your Custom GCode Options.
- The title indicates what command you're working with.
- The text box contains the default value in gray text, if there is a default. If there is no default value, the text box is blank.
- Below the text box is a preview of what the output for the command would look like, based on current settings.
Hover over a section for more detailed information. For information on variables to use in the commands, see Custom GCode Variables.
New in LightBurn 2.1¶
- G20 (set units to imperial) and G21 (set units to metric) modals are now editable GCode blocks. They default to simply
G20andG21. - If your device uses custom error codes and/or alarm codes, you can enter those codes along with a description under Custom Error Codes and Custom Alarm Codes.
- Added Work Coordinate System to select which Work Coordinate System to use.
Custom GCode Variables¶
These variables can be used in your GCode templates. Some variables are only available for MillMage.
| Variable | Description | Availability |
|---|---|---|
x |
X Axis position | |
y |
Y Axis position | |
z |
Z Axis position | |
r, a, u, rot, rotation |
Rotary axis position | |
x_probe |
X probe offset | MillMage-only |
y_probe |
Y probe offset | MillMage-only |
z_probe |
Z probe offset | MillMage-only |
s, speed |
Movement speed | |
feed, feedrate |
Movement speed | MillMage-only |
p, power |
Laser Power | |
rpms, spindlespeed |
Spindle speed or RPM/s | MillMage-only |
dwell |
Dwell time | |
tool |
Tool number |
Custom GCode Profile Templates¶
| Template | Description |
|---|---|
| Home | Machine homing routine. |
| Focus Z | Z axis laser focus (if applicable). |
| User Start Script | Custom script to run at the start of the job. |
| User End Script | Custom script to run at the end of the job. |
| Tool On | Enable the tool. |
| 2nd Tool On | Enable the 2nd tool (if applicable). |
| Tool Off | Disable the tool. |
| Fire On | Fire the laser. |
| Fire Off | Stop firing the laser. |
| Pierce | Fire the laser initially without moving, to help pierce through difficult materials. |
| Dwell | Pause movement for a specified time. |
| Air On | Turn on air assist. |
| Air Off | Turn off air assist. |
| Layer Start | Commands to run before the start of each layer. |
| Cut Move | Command to move while cutting. Typically uses G1. |
| Raster Move | Command for moving while engraving a raster image. |
| Rapid Move | Command to move without cutting. Typically uses G0. |
| Safe Rapid | Rapid move at a safe height above the material surface. |
| Abort | Immediate abort/stop command. |
| Pause | Immediate pause command. |
| Resume | Command to resume after pausing. |
| Job End | Job completion command. |
| Get Position | Command to get current position. |
| Get Status | Command to get current status. Often the same as Get Position. |
| Metric Modal | Set the machine to metric units. |
| Imperial Modal | Set the machine to imperial units. |
| Work Coordinate System | Set the work coordinate system to use, such as G54, G55, G56, etc. |
| Custom Error Codes | Specify custom error codes, if your device uses them. |
| Custom Alarm Codes | Specify custom alarm codes, if your device uses them. |
Custom GCode Macros¶
Relative and absolute mode are controlled by the software, so if you need to change it within your GCode template, use the following macros to prevent the software overriding your changes. You must always use |RESTORE| when you're done to ensure a return to the previous mode.
| Macro | Description |
|---|---|
|REL| |
Enter relative mode |
|ABS| |
Enter absolute mode |
|RESTORE| |
Restore previous mode |
Optional and Required Values¶
Surrounding the letter before a variable with [] will tell LightBurn that this portion of the command has not changed since the last emit. Putting a * in front of any variable will tell LightBurn to skip the entire line if it has not been changed.
G1 X{x} Y{y} Z{z}will always output the X, Y, and Z values.G1 [X]{x} [Y]{y} [Z]{z}will skip any values that have not changed.M106 S{*power}this will output theM106command only if it has been changed.
Reserved / Prohibited Characters¶
Certain characters — [], <>, and {} — are reserved for use by LightBurn and MillMage and are only permitted as shown above in Optional and Required Values.
New in LightBurn 2.1¶
To escape text sequences in LightBurn 2.1 or newer, surround the text in the escape character specified in Custom GCode Options.
Non-Printable / Non-Typeable Characters¶
Control characters can be output by using \x followed by the two digit hex value of the character. For instance, \x18 represents an immediate job abort on a GRBL device.
Troubleshooting¶
- If you aren't seeing a setting you expected to see, check which tab you're in and make sure it's applicable to your laser.
Related Topics¶
For more help using LightBurn, please visit our forum to talk with LightBurn staff and users, or email support.