- Main configuration file
- Prologue and communications section
- Movement section
- Z probe section
- Heater and thermistor section
- Tool definition section
- Homing files
- The homeall.g file
- Bed probing file
- Tool change files
- Pause, resume and cancel files
- User-defined macro files
RepRapFirmware is configured at run-time by means of files in the /sys folder of the on-board SD card. This means that you must have an SD card in the on-board socket to use RepRapFirmware. You do not have to recompile RepRapFirmware to configure it, so if you wish to update the firmware on your Duet or other compatible electronics board, you can download a ready-built binary.
For the changes you need to make for other types of printer, see:
- Configuring RepRapFirmware for a Delta printer
- Configuring RepRapFirmware for a CoreXY printer
- Configuring RepRapFirmware for an IDEX printer
- Configuring RepRapFirmware for a SCARA printer
- Configuring RepRapFirmware for a CNC machine
- Configuring RepRapFirmware for a Polar printer
- Configuring RepRapFirmware for a Hangprinter printer
The easiest way to generate these files is using the RepRapFirmware configuration tool .
Main configuration file
The main configuration file is sys/config.g. This file is read when RepRapFirmware starts up.
The order of commands in the config.g file is generally immaterial, with the following exceptions:
- The G31 command must come after the M558 command. This is because separate G31 parameters are stored for each possible probe type.
- Any M584 commands used to remap drivers must come before M350 and M906 commands. M584 commands that create new axes must also come before the M92, M201, M203, M208 and M566 that set parameters for those axes.
- The M92 commands to set steps/mm should either come after any M350 command to set microstepping, or else the M92 parameters should be correct for the default x16 microstepping. This is because when you change microstepping, the steps/mm are automatically adjusted to take account of the change in microstepping.
- If you use M307 to define a model for a heater and you also use M301 to adjust the PID parameters for that heater, the M301 command must come after the M307 command. This is because default PID parameters are set when you execute M307.
- M501 to load values stored in config-override.g should be at or near the end, so that the commands in config-override.g don't get overridden themselves.
- M671 if used must come after any M667 or M669 command to define the kinematics
Summary: M558 before G31, and M584 before other motion-related commands. M501 at the end.
The config.g file is typically organised into sections along the following lines.
Prologue and communications section
Example for Duet 2 WiFi:
M111 S0 ; Debug off M550 PMyOrmerod ; Machine name (can be anything you like) M551 Preprap ; Machine password (used when you connect Duet Web Control or via FTP) M552 S1 ; Enable WiFi M555 P2 ; Set output to look like Marlin M575 P1 B57600 S1 ; Set auxiliary serial port baud rate and require checksum (for PanelDue)
Example for Duet 0.6, Duet 0.8.5 or Duet 2 Ethernet:
M111 S0 ; Debug off M550 PMyOrmerod ; Machine name (can be anything you like) M551 Preprap ; Machine password (used when you connect Duet Web Control or via FTP) M540 PBE:EF:DE:AD:FE:ED ; MAC Address (only needed if you have more than one Duet 0.6 or 0.8.5 on the same network) M552 P0.0.0.0 ; IP address (0 = use DHCP) M554 P192.168.1.254 ; Gateway (not used yet) M553 P255.255.255.0 ; Netmask M555 P2 ; Set output to look like Marlin M575 P1 B57600 S1 ; Set auxiliary serial port baud rate and require checksum (for PanelDue)
On the older Duets, the machine name is used as a basis for the netbios name, so in the above example if your router supports netbios then you can attach to the web interface by typing "MyOrmerod/" into your browser. The password is used when connecting via FTP or the web interface (if you leave the password set as "reprap" then the web interface will not ask for a password).
When using more than one legacy Duet on a wired network, you must given them all different MAC addresses. Change the final ED in the M540 command to a unique 2-digit hex number for each one.
M569 P0 S1 ; Drive 0 goes forwards (change to S0 to reverse it) M569 P1 S0 ; Drive 1 goes backwards M569 P2 S1 ; Drive 2 goes forwards M569 P3 S1 ; Drive 3 goes forwards M569 P4 S1 ; Drive 4 goes forwards M350 X16 Y16 Z16 E16 I1 ; set 16x microstepping with interpolation M574 X0 Y1 Z0 S1 ; set homing switch configuration (Y homing switch only, at low end, active high) M906 X800 Y1000 Z800 E800 ; Set motor currents (mA) M201 X800 Y800 Z15 E1000 ; Accelerations (mm/s^2) M203 X15000 Y15000 Z100 E3600 ; Maximum speeds (mm/min) M566 X600 Y600 Z30 E20 ; Maximum jerk speeds mm/minute M208 X200 Y200 Z200 ; set axis maxima and high homing switch positions (adjust to suit your machine) M208 X-8 Y0 Z-0.5 S1 ; set axis minima and low homing switch positions (adjust to make X=0 and Y=0 the edges of the bed) M92 X80 Y80 Z4000 ; set axis steps/mm M92 E420:420 ; set extruder 0 and 1 steps/mm G21 ; Work in millimetres G90 ; Send absolute coordinates... M83 ; ...but relative extruder moves
The M569 commands are optional, drives go forward by default. In the M569 command you can also change the polarity of the driver Enable signal or lengthen the step pulse time, which you may need to do if you use external stepper motor drivers. See the list of supported gcodes for details.
The M350 command to set microstepping should come before the M92 commands to set steps/mm, because the steps/mm are adjusted automatically when microstepping is changed. Microstepping is fixed at 16x on the Duet 0.6 and Duet 0.8.5. On the Duet 2 you can choose microstepping of 1, 2, 4, 6, 16, 32, 128 or 256; and when using 16x microstepping only, the I1 parameter causes the microstepping to be interpolated to 256x.
Note on M350 microstepping settings: In general we recommend that you use the default x16 microstepping with interpolation. However, if you use ungeared extruders (which typically have 80-90 steps/mm @ x16 microstepping) then you may get better prints if you increase the microstepping for extruder drives to bring the extruder steps/mm into the 400 to 1000 range.
The XYZ parameters to the M574 command are 0 if there is no homing switch for the axis, 1 if there is a low-end homing switch, and 2 if there is a high-end homing switch. S1 indicates active high inputs (e.g. normally-closed switches), while S0 indicates active low inputs.
The M208 command with parameter S0 or no S parameter defines the maximum coordinate of each axis. These are also the coordinates at which the head is assumed to be when a high-end homing switch is triggered. The M208 command with S1 parameter sets the minimum axis coordinates and low-end homing switch positions in the same way.
The M906 command is required. Without it, motor currents will remain at zero. It also takes an optional I parameter, which is the percentage of normal current used to hold the motors in position when the motors have been idle for 30 seconds, default 30%.
It is possible to remap axes and extruders to different driver numbers. In firmware 1.14 and later it is done using the M584 command.
Z probe section
The M558 command enables the Z probe, defines which axes (if any) it it used to home, and the dive height. The G31 command defines the probe threshold and the X, Y and Z offsets of the probe relative to the tip of the nozzle. Here is an example:
M558 P1 X0 Y0 Z1 H3 F200 T5000 R0 ; smart IR Z probe, used for homing Z axis only, dive height 3mm, probe speed 200mm/min, travel speed 5000mm/min, no recovery time G31 P500 X11.0 Y0.5 Z1.65 ; set threshold and offsets
The P parameter of the M558 command specifies the type of Z probe, as follows:
P0 - no Z probe installed
P1 - analog sensor feeding the AD10 pin on the expansion connector (also brought out as the S pin on the 4-pin Z probe connector on the Duet Shield and on the Duet 0.8.5). Suitable for an unmodulated IR sensor (not recommended), smart IR sensor, and many other types. Pin D52 on the Duet is driven high.
P2 - simple modulated IR sensor. RepRapFirmware generates a modulation signal on pin D52 (also brought out as the T pin on the 4-pin Z probe connector on the Duet shield and Duet 0.8.5) for use by the sensor.
P3 - as P1 but pin D52 is driven low instead of high. Allows a compatible Z probe to be switched to a different mode.
P4 - microswitch (normally-closed by default) connected to the E0 endstop connector, or anything that emulates one. For a normally-open microswitch or NPN-output inductive sensor, use M574 E0 S0 to invert the sense of all the extruder endstop inputs.
The XYZ parameters in the M558 command define which axes the Z probe is used to home (0 = Z probe not used to home this axis, 1 = Z probe used). By default, RepRapFirmware for the Duet 0.8/0.8.5 (but not the Duet 2) uses the Z probe to home the X and Z axes.
The H parameter defines the Z probe dive height, which is the height above the trigger height from which probing starts. The default is 3mm or 5mm depending on firmware version. You may wish to increase it during initial calibration.
The G31 command sets the Z probe offset, trigger height and threshold. It must come after the M558 command, because you can have multiple Z probe types with different G31 parameters. The P parameter sets the threshold. For a smart IR probe such as my own differential IR height sensor, use 500. For a switch I also suggest 500, although a lower value may provide faster triggering if the switch has intermittent contact when first triggered..
The Z parameter sets the trigger height (the nozzle height above the bed at which the Z probe output exceeds the threshold). For a Z probe which relies on the nozzle pushing the bed down, the trigger height will be negative.
The G31 command also has also optional X and Y parameters to define the horizontal offset of the Z probe from the nozzle..
The speed of Z probing is set by the F parameter in the M558 command. The probing speed should be slow enough that the probe does not overshoot the trigger height. When using an analog Z probe, the probing speed is reduced by 2/3 when the probe detects that the trigger height is approaching, so that you can use a higher initial speed.
The T parameter of the M558 command sets the speed at which the head travels to the Z probe coordinates specified for bed probing.
The R parameter defines the Z probe recovery time in seconds. The printer will pause for this time just before starting the probing move, to allow any vibration caused by the previous travel move to settle down. It is useful if you have a Z probe mechanism that is sensitive to vibration or sharp head movement.
Heater and thermistor section
Here is an example for a 2-extruder machine:
M305 P0 T100000 B3950 R4700 H0 L0 ; Put your own H and/or L values here to set the bed thermistor ADC correction M305 P1 T100000 B4388 R4700 H0 L0 ; Put your own H and/or L values here to set the first nozzle thermistor ADC correction M305 P2 T100000 B4388 R4700 H0 L0 ; Put your own H and/or L values here to set the second nozzle thermistor ADC correction '''M143 H0 S275 ; Un-comment this to set maximum extruder temperature, default is 262C''' '''M141 H3 ; Un-comment this to set chamber heater/thermistor channel'''
The M305 commands define the thermistor resistance at 25C (T parameter), thermistor B value (B parameter), thermistor C parameter (in firmware 1.17 and later), thermistor series resistance (R value), and ADC high and low end corrections (H and L parameters).
You can get the thermistor resistance and B value from the thermistor datasheet. Note that the B value is typically given on the datasheet over quite a low temperature range, for example 25C to 85C. If the manufacturer publishes a resistance vs. temperature chart, it is better to use it to calculate the B value from 25C to the average extrusion temperature you use, for example 220C. The Semitec 104GT-2 thermistor supplied with the E3Dv6 hot end has a quoted B value of 4267, but the actual value over 25C to 220C is 4388. For greater accuracy, use a C parameter as well (note, the correct B value to use will be higher with a C parameter than without one). The config file generator at https://configurator.reprapfirmware.org/ includes a calculator to help you determine the B and C parameters.
The R value depends on which version of the Duet you have:
- Duet 2 WiFi, Duet 2 Ethernet, Duex 2 and Duex 5 expansion boards, and Duet 085: 4700
- Duet 2 Maestro: 2200
- Duet 06: older boards 1000, newer boards 4700
- Duex 4 version 0.2: 1000
- Duex 4 version 0.2a: older boards 1000, newer boards 4700.
The H and L values allow you to compensate for ADC offsets at the high and low ends of the ADC input voltage range. The H parameter adjusts the high end offset, which affects the reading at low temperatures; whereas L adjusts the low end offset which affects readings at high temperatures. At room temperature, if your temperature readings are lower than actual, use a positive H parameter to bring the readings up to the correct value. If the readings are too high, use a negative H parameter. You should not need to use an H parameter outside the range -100 to +100, and in theory all channels should need the same H value. Note: the Duet 2 has automatic ADC calibration so you should not need to use the H or L parameter.
The M305 command also takes an optional X parameter (not shown in the example) to allow temperature sensor channel remapping. For example, if in the M305 P0 command you add parameter X3, this means use the thermistor channel normally associated with heater 3 to read the temperature of heater 0 (i.e. the bed). RepRapFirmware uses temperature sensor channel numbers 100 to 103 to denote readings from thermocouples, and 200 to 203 to denote reading from PT100 sensors - see Connecting thermocouples and Connecting PT100 temperature sensors for details.
M305 P1 X200
This tells the firmware that for heater 1 (which is normally the first hot end heater) it should sense the temperature using the first channel on the PT100 board . The B C H L R and T parameters are ignored when using a thermocouple or PT100 sensor.
If you have a chamber heater, use the M141 command to define which heater channel it uses. You will also need to use M305 to define thermistor parameters for that channel, and M307 to define a heater model
Tool definition section
A tool is a combination of zero or more extruder drives and zero or more heaters. A standard single-extrusion printer has a single tool that uses one extruder drive and one heater. It should be defined like this:
M563 P0 D0 H1 ; tool 0 uses extruder drive 0 and heater 1 G10 P0 S0 R0 X0 Y0 ; set tool 0 temperatures and offsets
The M563 command in this example defines tool 0 (P parameter) as using extruder drive 0 (D parameter), heater 1 (H parameter) and Fan 0 (F parameter). The G10 command sets the active (S parameter) and standby (R parameter) temperatures to zero, and defines the X and Y nozzle offsets from the head origin as zero.
The tool definition for a typical dual nozzle printer would look like this:
M563 P0 D0 H1 ; tool 0 uses extruder drive 0 and heater 1 G10 P0 S0 R0 X-10 Y0 ; set tool 0 temperatures and offsets M563 P1 D1 H2 F2 ; tool 1 uses extruder drive 1 and heater 2. Fan 2 is mapped to fan 0 G10 P1 S0 R0 X10 Y0 ; set tool 1 temperatures and offsets
This defines a second tool, which uses extruder drive 1, heater 2 and fan 2 mapped to fan 0. Equally Fan 1 could be used however fan 1 is often used as a thermostatically controlled heatsink cooling fan on hotends as it defaults to switched on not off on powerup. The first tool has the nozzle offset by -10mm from the head origin in the X direction, and the second tool has the nozzle offset by +10mm from head origin in the X direction. You can define the head origin to be wherever you like.
The tool definition section for a switching hot end (i.e. two filaments extruding through the same nozzle, but not at the same time) would look like this:
M563 P0 D0 H1 ; define tool 0 G10 P0 S0 R0 X0 Y0 ; set tool 0 temperatures and offsets M563 P1 D1 H1 ; define tool 1 G10 P1 S0 R0 X0 Y0 ; set tool 0 temperatures and offsets
In this case, the two tools use different extruder drives but share heater 1.
The tool definition section for a mixing hot end (i.e. two filaments extruding through the same nozzle at the same time) would look like this:
M563 P0 D0:1 H1 ; define tool 0 G10 P0 S0 R0 X0 Y0 ; set tool 0 temperatures and offsets
In this case there is a single tool but it uses two extruder drives.
A typical epilogue would look like this:
M556 S100 X0 Y0 Z0 ; Put your axis compensation here M912 P0 S0 ; Put your CPU temperature sensor correction here M501 ; Run config-override.g T0 ; Select the first head
Axis compensation allows you to compensate in the firmware for the X, Y and Z axes not being exactly at right angles. The X parameter describes the error in the angle between X and Y axes, the Y parameter describes the angular error between Y and Z axes, and the Z parameter describes the angular error between Z and X axes. All these values get divided by the S parameter. For example, a parameter of Y1.5 with S100 would mean at 100mm height the Y position needs to be shifted by 1.5mm to make the print orthogonal. A calibration procedure for orthogonal axis compensation can be found at http://reprapltd.com/reprappro/documenta....
The M501 command executes the commands in config-override.g. This is where firmware versions 1.17 and later save heater models, delta printer calibration parameters and similar settings when you run M500.
The T0 at the end selects tool 0. It is optional. It is recommended that you also put the T0 command in the start gcode of your slicing program.
Homing X and Y
The homing files for a Cartesian or CoreXY printer are sys/homex.g, sys/homey.g, sys/homez.g and sys/homeall.g. Here is a typical homex.g file for a machine with an X axis homing switch at the low end:
G91 ; relative mode G1 S2 Z4 F200 ; raise head to avoid dragging nozzle over the bed G1 S1 X-240 F3000 ; move up to 240mm in the -X direction, stopping if the homing switch is triggered G1 X4 F600 ; move slowly 4mm in the +X direction G1 S1 X-10 ; move slowly 10mm in the -X direction, stopping at the homing switch G1 S2 Z-4 F200 ; lower the head again G90 ; back to absolute mode
Note the S1 parameter on some of the G1 commands. This parameter means stop moving an axis motor when the corresponding homing switch is triggered. On a Cartesian printer, the other axes continue moving. If your printer has an X axis longer than 240mm, you will need to to increase the value 240 in the G1 X-240 command to be longer than your printer's X axis travel.
Note the S2 parameter on the G1 Z4 command. This allows movement of that axis before it has been homed, which is otherwise prohibited by default.
For a machine with a homing switch at the high end of the axis, homex.g would look like this instead:
G91 ; relative mode G1 S2 Z4 F200 ; raise head to avoid dragging nozzle over the bed G1 S1 X240 F3000 ; move up to 240mm in the +X direction, stopping if the homing switch is triggered G1 X-4 F600 ; move slowly 4mm in the -X direction G1 S1 X10 ; move slowly 10mm in the +X direction, stopping at the homing switch G1 S2 Z-4 F200 ; lower the head again G90 ; back to absolute mode
You must also tell the firmware which end the homing switch is at, using the M574 command in config.g. Again, increase the value 240 in the G1 S1 command if you have a larger printer.
The homey.g file is similar to homex.g except that all instances of X are replaced by Y.
For homing Z, you can use either a Z probe or an endstop switch. You need to adjust the homez.g file (and the Z homing section of homeall.g) according to which method you use.
Homing Z using a Z probe
Z homing is often done using the Z probe. Here is a typical homez.g file for homing using a Z probe:
G91 ; relative mode G1 S2 Z4 F200 ; raise head 4mm to ensure it is above the Z probe trigger height G90 ; back to absolute mode G1 X100 Y100 F2000 ; put head over the centre of the bed, or wherever you want to probe G30 ; lower head, stop when probe triggered and set Z to trigger height
Adjust the X and Y coordinates in the second G1 command according to where you want to probe when Z homing. You need to have set up the Z probe type, trigger height and threshold as described earlier.
Homing Z to a Z max endstop switch
To home Z using a microswitch at the Z max position, use a pattern similar to homex.g and homey.g with a maximum endstop switch. As usual, the axis length specified in the M208 command specifies the trigger position of the switch. Here is an example:
G91 ; relative mode G1 S1 Z250 F300 ; move Z towards the switch until it triggers G1 S2 Z-5 F100 ; move Z back 5mm G1 S1 Z10 F100 ; move Z slowly towards the switch until it triggers G90 ; back to absolute mode
Homing Z using a Z min endstop switch
Use a pattern similar to homex.g and homey.g with a minimum endstop switch. However, if your switch that triggers a little before Z=0, then you can't use M208 to define the homing position, because it would prevent you moving below the trigger height. You can use a G92 command after homing instead. Here is an example, for the case where you have a low-end homing switch that triggers at Z=0.3mm:
G91 ; relative mode G1 S2 Z4 F200 ; raise head 4mm to ensure it is above the switch trigger height G90 ; back to absolute mode G1 X0 Y0 F2000 ; put the head wherever you want it to be when you home Z (omit this line if it doesn't matter) G91 ; relative mode G1 S1 Z-200 F100 ; move Z down until the switch triggers G90 ; back to absolute mode G92 Z0.3 ; tell the firmware that we are at Z=0.3mm
The homeall.g file
The homeall.g file is used when all axes are to be homed. You could make it by concatenating homex.g, homey.g and homez.g, but some optimisations are possible. For example, you need only raise the head by 4mm once, and you can do simultaneous X and Y homing.
Note: you must not use a G28 command within homeall.g (or any other homing file). But you can invoke one of your other homing files using the M98 command, for example:
Here is a sample homeall.g file for a machine with X and Y endstop switches at the low end and using a Z probe for Z homing:
G91 ; relative mode G1 S2 Z4 F200 ; raise head 4mm G1 S1 X-240 Y-240 F3000 ; move up to 240mm in the -X and -Y directions until the homing switches are triggered G1 S2 X4 Y4 F600; move slowly 6mm in +X and +Y directions G1 S1 X-10 Y-10 ; move up to 10mm in the -X and -Y directions until the homing switches are triggered G90 ; back to absolute mode G1 X100 Y100 F2000 ; put head over the centre of the bed, or wherever you want to probe G30 ; lower head, stop when probe triggered and set Z to trigger height
Bed probing file
If you use mesh bed compensation (which is recommended in most cases) or no bed compensation, you can skip this section. This section is about using the older 3, 4 and 5 point bed compensation, using probe points defined in the bed.g file.
The commands in bed.g are executed when you send the G32 command. So this file should contain your bed probing script. Here is a typical 5-point bed.g file for a printer with a 200 x 200mm bed:
M561 ; clear any existing bed transform M401 ; deploy Z probe if necessary G30 P0 X10 Y10 Z-99999 ; define 4 points in a clockwise direction around the bed, starting near (0,0) G30 P1 X10 Y190 Z-99999 G30 P2 X190 Y190 Z-99999 G30 P3 X190 Y10 Z-99999 G30 P4 X100 Y100 Z-99999 S0 ; finally probe bed centre, and calculate compensation M402 ; retract the Z probe G1 X0 Y0 F5000 ; move the head to the corner (optional)
The Z-99999 parameter on each G30 command tells the firmware to probe at the given XY point and save the reading in the index given by the P command. The S0 parameter on the final G30 command tells the firmware to apply compensation based on the number of points probed (in this case, 5 points). The bed probe points must be in a clockwise order around the bed starting with the point nearest (0, 0) and when using 5-point probing the centre point must be last.
You may include an H parameter on each G30 command, This is the value that needs to be added to the G31 Z parameter to get the trigger height at that position. This is to correct for Z probes whose trigger heights vary slightly with XY position.
To use 4-point compensation, omit the final G30 command and put the S0 parameter on the G30 P3 command instead.
To use manual compensation instead of a Z probe, replace the -99999 in each G30 command by the actual bed height error at that XY position.
Tool change files
RepRapFirmware handles multiple extruders through a tool definition mechanism. If you have multiple nozzles, you will normally define one tool for each nozzle. There is nothing to stop you defining several tools that use the same nozzle if you want, or a single tool that uses more than one nozzle.
Only one tool is active at a time. To switch between tools, use the T command. Tools are conventionally numbered from zero, so in a dual nozzle printer the tools would normally be T0 and T1. The current PanelDue firmware expects the tools to be numbered T0, T1 and so on; but the web interface doesn't mind if the tools are not numbered consecutively.
When the firmware receives a T command and the requested tool number is not already active, it goes through the following sequence:
- If another tool is active, run file sys/tfree#.g where # is the number of the active tool (e.g. tfree0.g).
- If another tool is active, set its heaters to their standby temperatures.
- Run file sys/tpre#.g where # is the number of the new tool being activated.
- Set the heaters associated to the new tool to their active temperatures.
- Run file sys/tpost#.g where # is the number of the new tool being activated.
The tool change macro files are not run if the printer has not been homed since power up. This allows you to put a T0 command at the end of config.g, which is convenient if you have only one tool.
Here is a sample tfree0.g file:
''' Put G/M Codes in here to run when Tool 0 is freed''' M83 ; relative extruder mode G1 E-4 F2500 ; retract 4mm
Here is a sample tpre0.g file:
''' Put G/M Codes in here to run when Tool 0 is about to be activated''' G1 X0 Y0 F6000 ; move the head away from the print
Here is a sample tpost0.g file
''' Put G/M Codes in here to run after Tool 0 is activated''' M116 P0 ; wait for tool 0 only to reach operating temperature M83 ; relative extruder mode G1 E4 F2500 ; undo retraction
You may not need to include the commands to retract and un-retract the filament if your slicer does that for you. As when any macro file is run, the absolute/relative axis and extruder movement states are restored to their original values when the macro file completes.
The tfree1.g, tpre1.g and tpost1.g files would be similar, except that tpost1.g would use command M116 P1. The purpose of the P parameter on the M116 command is to allow you to wait for the new tool to heat up to active temperature without also waiting for the previously-selected tool to cool down to standby temperature.
Pause, resume and cancel files
When you pause a print, macro file sys/pause.g is executed. Typically you will want to retract filament a little and move the head out of the way of the print. Here is a sample pause.g file:
M83 ; relative extruder moves G1 E-4 F2500 ; retract 4mm G91 ; relative moves G1 Z2 F5000 ; raise nozzle 2mm G90 ; absolute moves G1 X0 Y200 F5000 ; move head out of the way of the print
Note that when executing any macro file, various parameters are saved, such as the absolute/relative axis movement flag, the absolute/relative extruder movement flag, and the feed rate. These parameters are restored when the macro completes.
Macro file sys/resume.g is executed when you resume a paused print. Here is a typical resume.g file:
G1 R1 Z2 F5000 ; move to 2mm above resume point G1 R1 ; lower nozzle to resume point M83 ; relative extruder moves G1 E4 F2500 ; undo the retraction
The R1 parameter in the G1 command causes the coordinates at which the print was paused to be added to any XYZ parameters in the command.
If you cancel a paused print, file sys/cancel.g is run if it exists, otherwise all tools are deselected and all heaters are turned off. Your cancel.g file can either deselect all tools by sending T-1, or leave the current tool enabled ready to try the print again. On a delta printer, you might want to include a G28 homing command in cancel.g to get the print head out of the way.
User-defined macro files
You can define your own macro files. Create a directory called /macros on the on-board SD card and upload your macro files to it. The name of each macro file should be the text that you want to appear in the menu displayed on the web interface and PanelDue (no need for a .g or .gcode extension), and the file contents should be ordinary Gcode commands supported by RepRapFirmware. If you want a lot of macros with a hierarchical menu structure, use subdirectories of /macros.
The following parameters are always saved before running a macro, and restored afterwards; so any changes to them that you make in a macro will not be permanent:
- feed rate
- relative/absolute axis coordinate mode
- relative/absolute extruder coordinate mode