Setting up macro files for common tasks
Overview
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.
Examples
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:
1_Off
2_Half On
3_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:
Off
Half On
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 brush 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:
from Duet Web Control
Duet Web Control has an interface for managing, editing and uploading macros.
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:
from the Panel Due
Macros can be selected from the macro page on the Panel Due:
A number of macros can be displayed on the control page as well for quick access:
(4.3 inch screen pictured)
See the previous section on how to choose the order that the macros are displayed.
5 Comments
Looking to execute a macro on start up
Brianux UX - Reply
Hey, best to discuss thin on the forum (forum.duet3d.com). but you can put a call to the macro at the end of config.g if you want it to run on startup every time.
Tony -
Yes, I’m looking for the command
M98 P”mymacro”
or
M98 P”mymacro.g”
Brianux UX - Reply
Hee, Hee - would suggest that the typo “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) “ could lead to misunderstandings. Go for a brush instead eh?
Steve Sims - Reply
Thanks, fixed, finally!
Ian A-S -