Skip to main content

Site Navigation

Your Account

Choose Language

Setting up macro files for common tasks


You can use macro files to automate common tasks. A macro file is simply a text file on the SD card containing a sequence of GCode commands.

If you want a macro file to appear in the list of macros shown by Duet Web Control and PanelDue, put it in the /macros folder of the SD card. If you don't want a macro to appear in the user interface, you can put it in the /sys folder. This folder already contains macros that are run automatically when certain events occur, for example the homing macros and the pause and resume macros.

The SD card shipped with your Duet may already contain some files with UPPER_CASE names in /macros. These are used by the factory for testing new Duets. You may delete them.


There are a number of examples here:


Creating macros

You can create macros easily in Duet Web Control. To create a new macro file in the /macros folder, go to the '''Macros''' page of Duet Web Control and click on Make new. To create a new macro file in the /sys folder, go to the Settings page, then the System Editor tab, and click on New File.

Naming and ordering macros

The name of a macro file in the /macros folder should be the text that you want to appear in the macro lists shown by Duet Web Control and PanelDue. You do not need a ".g" extension at the end.

By default the macros are listed in alphabetical order. You can change this by prefixing the macro names with one or more decimal digits followed by an underscore, for example:


2_Half On


The full filename will be used when the macros are sorted to display them in order, but only the text after the underscore will be displayed on the button. So the above will display as:


Half On


Note: versions of PanelDue prior to 1.20beta2 do not implement this feature.

Running Macros

From gcode

Macros can be run from any source of code:

  • From a gcode file printing from the SD card (e.g. a custom macro to wipe the tool head on a bush as part of the start gcode)
  • From a console connected by USB/telnet/DWC etc
  • From another macro - they can be nested.

To run a macro the M98 gcode is used:

M98 Pmymacro.g

from Duet Web Control

Duet Web Control has an interface for managing, editing and uploading macros.

Block Image

For more information see the Duet Web Control Manual Duet Web Control Manual

Once macros are setup then can be run from the macro page or directly from the machine control page:

Block Image

from the Panel Due

Macros can be selected from the macro page on the Panel Due:

Block Image

A number of macros can be displayed on the control page as well for quick access:

Block Image

(4.3 inch screen pictured)

See the previous section on how to choose the order that the macros are displayed.


Add Comment

View Statistics:

Past 24 Hours: 5

Past 7 Days: 36

Past 30 Days: 188

All Time: 2,911