This page describes how to set up the configuration files for Cartesian printers, and forms the basis for setting up all printer types. However, the same firmware binary also supports Delta, CoreXY and other printers kinematics.
You do not have to recompile RepRapFirmware to configure it; the same firmware binary also supports Delta, CoreXY and other printers kinematics. If you wish to update the firmware on your Duet or other compatible electronics board, you can download a ready-built binary.
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.
The easiest way to generate these files is using the RepRapFirmware configuration tool.
This page walks you through a typical configuration for a cartesian 3D printer, using RepRapFirmware v3, generated by the configuration tool. There are notes for differences between Duet 3 and Duet 2 boards, and between RRF 3.x and RRF 2.x.
For the changes you need to make for other types of machine, see:
Configuring RepRapFirmware for a CoreXY printer
Configuring RepRapFirmware for a Linear Delta printer
Configuring RepRapFirmware for an IDEX printer
Configuring RepRapFirmware for a DLP printer controlled by nanoDLP
Configuring RepRapFirmware for a Hangprinter
Configuring RepRapFirmware for a Polar printer
Configuring RepRapFirmware for a Rotary Delta
Configuring RepRapFirmware for a Serial SCARA printer
Configuring RepRapFirmware for a 5 bar parallel scara
Configuring RepRapFirmware for a CNC machine
Configuring RepRapFirmware for a Laser engraver/cutter
Configuring RepRapFirmware for OpenPnP
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:
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.
The General preferences section sets some basic preferences such as display support and machine name.
; General preferences
M575 P1 S1 B57600 ; support for PanelDue
G90 ; send absolute coordinates...
M83 ; ...but relative extruder moves
M550 P"My Printer" ; set machine name (can be anything you like)
The network section enables the networking functions for the firmware.
Example for Duet mainboards with WiFi:
; Network
M551 P"reprap" ; set password (used when you connect Duet Web Control or via FTP)
M552 S1 ; enable WiFi (Use DHCP or set IP address with M587)
M586 P0 S1 ; enable HTTP
M586 P1 S0 ; disable FTP
M586 P2 S0 ; disable Telnet
Example Duet mainboards with Ethernet:
; Network
M551 P"reprap" ; set password (used when you connect Duet Web Control or via FTP)
M552 P0.0.0.0 S1 ; enable network and acquire dynamic address via DHCP
M586 P0 S1 ; enable HTTP
M586 P1 S0 ; disable FTP
M586 P2 S0 ; disable Telnet
The Drives section sets up the connected stepper motors, maps them to axes, and sets the axis speeds and accelerations. For more information, or customising this, see Configuring stepper motors.
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.
Use the M584 command to map motors to axes and extruders.
In RepRapFirmware 3.x, no motors are mapped to axes by default, so you must have an M584 command.
In RepRapFirmware 2.x, the axes are mapped X0 Y1 Z2 E3:4. If your machine uses this standard mapping, you don't need an M584 command.
Multiple motors can be configured on the same axis, for example you may have two or three motors on your Z axis. This can't be configured in the Configuration tool currently; you will have to add this manually to your config.g. See Configuring stepper motors. However, you can configure multiple extruders.
Example of machine with 1 motor for X, Y and Z, and 2 extruder motors:
; Drives
M569 P0 S1 ; physical drive 0 goes forwards (change to S0 to reverse it)
M569 P1 S0 ; physical drive 1 goes backwards
M569 P2 S1 ; physical drive 2 goes forwards
M569 P3 S0 ; physical drive 3 goes backwards
M569 P4 S1 ; physical drive 4 goes forwards
M584 X0 Y1 Z2 E3:4 ; drive mapping
With Duet 3 boards, the M569 P parameter used to identify the stepper driver is formatted board_number.drive_number, where the board_number relates to the CAN address of the board. A board_number of 0 (or not specified) relates to the mainboard, and additional drivers on toolboards and/or expansion boards will have a different board_number. For example, the default board_number for a Duet 3 Expansion 3HC is 1, while the default board_number for Duet 3 Toolboard 1LC is 121.
With all the motors defined by M569, they are assigned to their axes using M584.
Example of machine with 1 motor for X, Y and Z, and 2 extruder motors on separate toolboards:
; Drives
M569 P0.0 S1 ; physical drive 0.0 goes forwards
M569 P0.1 S0 ; physical drive 0.1 goes backwards
M569 P0.2 S0 ; physical drive 0.2 goes backwards
M569 P121.0 S1 ; physical drive 121.0 goes forwards
M569 P122.0 S1 ; physical drive 121.0 goes forwards
M584 X0.0 Y0.1 Z0.2 E121.0:122:0 ; set drive mapping
Duet 2 boards with an expansion board (DueX2/5, Expansion Breakout Board or external driver for Duet 2 WiFi/Ethernet, and Dual Stepper Driver Expansion Module for Duet 2 Maestro) simply continues the motor numbering. See Configuring stepper motors.
Example of machine with 1 motor for X, Y and Z, and 4 extruder motors:
; Drives
M569 P0 S1 ; physical drive 0 goes forwards (change to S0 to reverse it)
M569 P1 S0 ; physical drive 1 goes backwards
M569 P2 S1 ; physical drive 2 goes forwards
M569 P3 S0 ; physical drive 3 goes backwards
M569 P4 S1 ; physical drive 4 goes forwards
M569 P5 S1 ; physical drive 5 goes forwards (on DueX5)
M569 P6 S1 ; physical drive 6 goes forwards (on DueX5)
M584 X0 Y1 Z2 E3:4:5:6 ; drive mapping
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. You can choose microstepping of 1, 2, 4, 6, 16, 32, 128 or 256. The I1 parameter causes the microstepping to be interpolated to 256x at all microstepping settings on Duet 3 and Duet 2 Maestro. On Duet 2 WiFi/Ethernet, interpolation is only available when using 16x microstepping.
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.
There is a built-in calculator in the Configuration tool to calculate steps per mm for M92.
Motor speed and acceleration settings will depend on your choice of motor, motion system and kinematics. For more information on setting M566, M203 and M201, see Configuring stepper motors.
The M906 command is required. Without it, motor currents will remain at zero. It can 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%.
Each axis (X, Y, Z and E) have a single drive. All the following Gcodes take a single parameter.
M584 X0 Y1 Z2 E3 ; drive mapping
M350 X16 Y16 Z16 E16 I1 ; configure microstepping with interpolation
M92 X80.00 Y80.00 Z400.00 E420.00 ; set steps per mm
M566 X900.00 Y900.00 Z60.00 E120.00 ; set maximum instantaneous speed changes (mm/min)
M203 X6000.00 Y6000.00 Z180.00 E1200.00 ; set maximum speeds (mm/min)
M201 X500.00 Y500.00 Z20.00 E250.00 ; set accelerations (mm/s^2)
M906 X800 Y800 Z800 E800 I30 ; set motor currents (mA) and motor idle factor in per cent
M84 S30 ; Set idle timeout
Additional extruder (E) axes count as individual axes. In the following Gcodes, each E parameter should have the same number of parameters as there are E axes mapped in the M584 command. Parameters for the second E axis can be different from the first, as necessary, though in this example they are the same.
M584 X0 Y1 Z2 E3:4 ; drive mapping
M350 X16 Y16 Z16 E16:16 I1 ; configure microstepping with interpolation
M92 X80.00 Y80.00 Z400.00 E420.00:420:00 ; set steps per mm
M566 X900.00 Y900.00 Z60.00 E120.00:120.00 ; set maximum instantaneous speed changes (mm/min)
M203 X6000.00 Y6000.00 Z180.00 E1200.00:1200.00 ; set maximum speeds (mm/min)
M201 X500.00 Y500.00 Z20.00 E250.00:250.00 ; set accelerations (mm/s^2)
M906 X800 Y800 Z800 E800:800 I30 ; set motor currents (mA) and motor idle factor in per cent
M84 S30 ; Set idle timeout
When multiple motors are combined into a single axis, the motors, gearing and transmission MUST be identical on that axis, because the axis parameters in M350, M92, M566, M203, M201 and M906 Gcodes can take only ONE value for each axis. This is also true for all defined axes except E (see previous example for multiple extruder axes), ie X, Y, Z, U, V, W, A, B, C, D etc.
In the following example, the Z axis has two drives, defined by M584 Z2:4. The Z parameter in the Gcodes is applied to both motors.
M584 X0 Y1 Z2:4 E3 ; drive mapping
M350 X16 Y16 Z16 E16 I1 ; configure microstepping with interpolation
M92 X80.00 Y80.00 Z400.00 E420.00 ; set steps per mm
M566 X900.00 Y900.00 Z60.00 E120.00 ; set maximum instantaneous speed changes (mm/min)
M203 X6000.00 Y6000.00 Z180.00 E1200.00 ; set maximum speeds (mm/min)
M201 X500.00 Y500.00 Z20.00 E250.00 ; set accelerations (mm/s^2)
M906 X800 Y800 Z800 E800 I30 ; set motor currents (mA) and motor idle factor in per cent
M84 S30 ; Set idle timeout
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.
; Axis Limits
M208 X200 Y200 Z200 S0 ; 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)
No endstops are defined by default. Each endstop has an M574 command.
; Endstops
M574 X1 S1 P"io0.in" ; configure switch-type (e.g. microswitch) endstop for low end on X via pin io0.in
M574 Y1 S1 P"io1.in" ; configure switch-type (e.g. microswitch) endstop for low end on Y via pin io1.in
M574 Z1 S2 ; configure Z-probe endstop for low end on Z
No endstops are defined by default. Each endstop has an M574 command.
; Endstops
M574 X1 S1 P"xstop" ; configure switch-type (e.g. microswitch) endstop for low end on X via pin io0.in
M574 Y1 S1 P"ystop" ; configure switch-type (e.g. microswitch) endstop for low end on Y via pin io1.in
M574 Z1 S2 ; configure Z-probe endstop for low end on Z
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. The S parameter indicates the switch type; 0 for active low endstop input, 1 for active high endstop input, 2 for Z probe, and 3 for motor load detection (stall).
M574 X1 Y2 Z0 S1 ; X endstop at low end, Y endstop at high end, no Z endstop, all active high
For more information on Z probes, see Choosing a Z probe, Connecting a Z probe and Test and calibrate a Z probe
The M558 command configures the Z probe.
The G31 command defines the probe threshold and the X, Y and Z offsets of the probe relative to the tip of the nozzle.
The M557 defines the grid for Mesh bed compensation
The M558 P parameter specifies the type of Z probe. Many different types of probe are supported, see M558 documentation.
The M558 C parameter, in RRF 3.x, specifies the input pin and the optional modulation pin.
The M558 H parameter defines the Z probe dive height, which is the height above the trigger height from which probing starts.
The speed of Z probing is set by the M558 F parameter. The probing speed should be slow enough that the probe does not overshoot the trigger height. In RRF 3.3 and later, you can define two values for F, eg F1000:500, where the first probe will be fast and subsequent probes will be slow slow.
The M558 T parameter of the M558 command sets the speed at which the head travels to the Z probe coordinates specified for bed probing.
There are other parameters for M558, including configuring recovery time, probing multiple times with tolerance, turn off heaters while probing, and setting probe number (for multiple defined probes).
The G31 command must come after the M558 command. It sets the Z probe offset from the nozzle in X and Y. 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 P parameter sets the threshold, default is 500.
; Z-Probe
M558 P1 C"io3.in" H5 F120 T6000 ; set Z probe type to unmodulated and the dive height + speeds
G31 P500 X-30 Y10 Z2.1 ; set Z probe trigger value, offset and trigger height
M557 X15:245 Y15:245 S20 ; define mesh grid
; Z-Probe
M558 P1 C"zprobe.in" H5 F120 T6000 ; set Z probe type to unmodulated and the dive height + speeds
G31 P500 X25 Y0 Z1.9 ; set Z probe trigger value, offset and trigger height
M557 X15:215 Y15:195 S20 ; define mesh grid
In RRF 2.x, choosing a different probe type with the M558 P parameter lets you connect certain probes to inputs other than the Z probe input. The M558 C parameter specifies the endstop input number when the probe type is P4 (RRF 2.02 and later).
M558 P1 H5 F200 T5000 ; smart IR Z probe, dive height 5mm, probe speed 200mm/min, travel speed 5000mm/min
G31 P500 X11.0 Y0.5 Z1.65 ; set threshold and offsets
M557 X15:245 Y15:245 S20 ; define mesh grid
The following show examples of setting up a BLTouch on Duet mainboards in config.g. The configuration requires an additional step, which defines the PWM pin that controls the BLTouch 'servo' that extends and retracts the pin. Further changes are required to other system configuration macros; see the BLTouch section of Connecting a Z probe for full details, including wiring for alternative setups (Duet 2 with DueX2/3 or EBoB, Duet 2 Maestro).
; Z-Probe
M950 S0 C"io4.out" ; create servo pin 0 for BLTouch (use IO_4/5/7 for 6HC, IO_1/2/3 for Mini 5+)
M558 P9 C"io4.in" H5 F120 T6000 ; set Z probe type to bltouch and the dive height + speeds
G31 P500 X25 Y0 Z2.5 ; set Z probe trigger value, offset and trigger height
M557 X15:215 Y15:195 S20 ; define mesh grid
Example for Duet 2 with BLTouch servo wire connected to Heater 3 on the expansion connector:
; Z-Probe
M950 S0 C"exp.heater3" ; create servo pin 0 for BLTouch
M558 P9 C"^zprobe.in" H5 F120 T6000 ; set Z probe type to bltouch and the dive height + speeds
G31 P500 X25 Y0 Z2.5 ; set Z probe trigger value, offset and trigger height
M557 X15:215 Y15:195 S20 ; define mesh grid
In RRF 2.x, we first disable the PWM channel that the BLTouch servo will use, with M307. Define the probe as P9 in M558, and offsets and trigger height with G31.
Example for Duet 2 with BLTouch servo wire connected to Heater 3 on the expansion connector:
; Z-Probe
M307 H3 A-1 C-1 D-1 ; disable heater on PWM channel for BLTouch
M558 P9 H5 F120 T6000 ; set Z probe type to bltouch and the dive height + speeds
G31 P500 X25 Y0 Z2.5 ; set Z probe trigger value, offset and trigger height
M557 X15:215 Y15:195 S20 ; define mesh grid
Duet boards support a number of different temperature sensor types. The temperature sensor can be a thermistor or PT1000 connected directly to the temperature inputs on the Duet, a PT100 connected to a PT100 daughterboard, or a thermocouple connected to a thermocouple daughterboard. For a comparison, see Choosing temperature sensors.
For heaters, see also:
Connecting and configuring extruder heaters
Connecting and configuring a bed heater
Connecting and configuring a chamber heater
Tuning the heater temperature control
Here is an example for Duet 3 with heated bed and 2 extruders, using thermistors:
; Heaters
M308 S0 P"temp0" Y"thermistor" T100000 B3950 ; configure sensor 0 as thermistor on pin temp0
M950 H0 C"out0" T0 ; create bed heater output on out0 and map it to sensor 0
M307 H0 B1 S1.00 ; enable bang-bang mode for the bed heater and set PWM limit
M140 H0 ; map heated bed to heater 0
M143 H0 S120 ; set temperature limit for heater 0 to 120C
M308 S1 P"temp1" Y"thermistor" T100000 B4725 C7.06e-8 ; configure sensor 1 as thermistor on pin temp1
M950 H1 C"out1" T1 ; create nozzle heater output on out1 and map it to sensor 1
M307 H1 B0 S1.00 ; disable bang-bang mode for heater and set PWM limit
M143 H1 S280 ; set temperature limit for heater 1 to 280C
M308 S2 P"temp2" Y"thermistor" T100000 B4725 C7.06e-8 ; configure sensor 2 as thermistor on pin temp2
M950 H2 C"out2" T2 ; create nozzle heater output on out2 and map it to sensor 2
M307 H2 B0 S1.00 ; disable bang-bang mode for heater and set PWM limit
M143 H2 S280 ; set temperature limit for heater 2 to 280C
Other temperature sensor examples
In the following examples, temperature sensor 0 is a PT1000 connected directly to the mainboard's temp0 pin; temperature sensor 1 is a K-type thermocouple connected to the first channel on a thermocouple daughterboard that is mounted on the mainboard; temperature sensor 2 is a PT100 connected to the first channel on a PT100 daughterboard that is mounted on an expansion board at CAN address 1.
M308 S0 P"temp0" Y"pt1000" ; configure sensor 0 as PT1000 on pin temp0
M308 S1 P"spi.cs0" Y"thermocouple-max31856" ; configure sensor 1 as thermocouple via CS pin spi.cs0
M308 S2 P"1.spi.cs0" Y"rtd-max31865" ; configure sensor 2 as PT100 on pin 1.spi.cs0
Chamber heater
Example:
M308 S3 P"temp2" Y"thermistor" T100000 B4138 ; configure sensor 3 as thermistor on pin temp2
M950 H3 C"out2" T3 ; create chamber heater output on out2 and map it to sensor 3
M307 H3 B0 S1.00 ; disable bang-bang mode for the chamber heater and set PWM limit
M141 H3 ; map chamber to heater 3
M143 H3 S100 ; set temperature limit for heater 3 to 100C
Here is an example for Duet 2 with heated bed and 2 extruders, using thermistors:
; Heaters
M308 S0 P"bedtemp" Y"thermistor" T100000 B3950 ; configure sensor 0 as thermistor on pin bedtemp
M950 H0 C"bedheat" T0 ; create bed heater output on bedheat and map it to sensor 0
M307 H0 B1 S1.00 ; enable bang-bang mode for the bed heater and set PWM limit
M140 H0 ; map heated bed to heater 0
M143 H0 S120 ; set temperature limit for heater 0 to 120C
M308 S1 P"e0temp" Y"thermistor" T100000 B4725 C7.06e-8 ; configure sensor 1 as thermistor on pin e0temp
M950 H1 C"e0heat" T1 ; create nozzle heater output on e0heat and map it to sensor 1
M307 H1 B0 S1.00 ; disable bang-bang mode for heater and set PWM limit
M143 H1 S280 ; set temperature limit for heater 1 to 280C
M308 S2 P"e1temp" Y"thermistor" T100000 B4725 C7.06e-8 ; configure sensor 2 as thermistor on pin e1temp
M950 H2 C"e1heat" T2 ; create nozzle heater output on e1heat and map it to sensor 2
M307 H2 B0 S1.00 ; disable bang-bang mode for heater and set PWM limit
M143 H2 S280 ; set temperature limit for heater 2 to 280C
Other temperature sensor examples
In the following examples, temperature sensor 0 is a PT1000 connected directly to the mainboard's bedtemp pin; temperature sensor 1 is a K-type thermocouple connected to the first channel on a thermocouple daughterboard that is mounted on the mainboard; temperature sensor 2 is a PT100 connected to the first channel on a PT100 daughterboard that is mounted on a connected Duex5.
M308 S0 P"bedtemp" Y"pt1000" ; configure sensor 0 as PT1000 on pin bedtemp
M308 S1 P"spi.cs1" Y"thermocouple-max31856" ; configure sensor 1 as thermocouple via CS pin spi.cs1
M308 S2 P"duex.cs5" Y"rtd-max31865" ; configure sensor 2 as PT100 on pin duex.cs5
Chamber heater
Example:
M308 S3 P"e1temp" Y"thermistor" T100000 B4138 ; configure sensor 3 as thermistor on pin e1temp
M950 H3 C"e1heat" T3 ; create chamber heater output on e1heat and map it to sensor 3
M307 H3 B0 S1.00 ; disable bang-bang mode for the chamber heater and set PWM limit
M141 H3 ; map chamber to heater 3
M143 H3 S100 ; set temperature limit for heater 3 to 100C
In RRF 2.x, the M305 command defines the temperature sensor parameters for each heater (P parameter). There are parameters for 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 will need to add an M307 to set the heater parameters, which uses the defaults to start with. You will need to tune the heater control during commissioning (see Tuning the heater temperature control).
Here is an example for Duet 2 with heated bed and 2 extruders, using thermistors:
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**
Other temperature sensor examples
In the following examples, the temperature sensor for heater 0 (P0, usually the bed) is a PT1000 connected directly to the mainboard's bedtemp pin; the temperature sensor for heater 1 is a K-type thermocouple connected to the first channel on a thermocouple daughterboard that is mounted on the mainboard; the temperature sensor for heater 2 is a PT100 connected to the first channel on a PT100 daughterboard that is mounted on a connected DueX5. The B C H L R and T parameters are ignored when using a thermocouple or PT100 sensor.
M305 P0 X500 R4700 ; configure PT1000 for heater 0
M305 P1 X150 ; configure thermocouple for heater 1
M305 P2 X205 ; configure PT100 for heater 2
Chamber heater
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.
M305 P2 T100000 B4138 R4700 ; set thermistor + ADC parameters for heater 2
M143 H2 S100 ; set temperature limit for heater 2 to 100C
M141 H2 ; assign chamber heater to heater 2
All Duet boards support fans. 2- 3- and 4-wire fans can be connected, and powered by on-board 5V or 12V regulators, or by VIN (the power supply voltage, may be 12-24V), or by an external power supply. Fans can configured to be always on, thermostatically controlled (ie the fan turns on when a temperature sensor reports a particular temperature), or controlled by gcode.
Generally, the first fan is the part cooling fan, and is controlled by Gcode that the slicer produces. Other fans can be for hot end cooling or cooling the mainboard, and can be thermostatically controlled or always on.
Often slicing software is unaware of multiple fans, so in a multi-tool machine a particular part cooling fan can assigned to a particular tool (see next section on Tool definistions). Then the firmware controls the correct fan for the tool, and the gcode only needs to turn it on or off as necessary. Always on and thermostatically controlled fans do not need to be assigned to a tool.
For more information on fans, see Connecting and configuring fans.
In this example, there are four fans defined. Fan 0 and 1 are the part cooling fans, and they will be mapped to Tool 0 and Tool 1 (see next section on Tool definistions). Fan 2 and 3 are thermostatically controlled hot end cooling fans. These do not need to be mapped to the tool.
; Fans
M950 F0 C"out3" Q500 ; create fan 0 on pin out3 and set its frequency
M106 P0 S0 H-1 ; set fan 0 value. Thermostatic control is turned off
M950 F1 C"out4" Q500 ; create fan 1 on pin out4 and set its frequency
M106 P1 S1 H-1 ; set fan 1 value. Thermostatic control is turned off
M950 F2 C"out5" Q500 ; create fan 2 on pin out5 and set its frequency
M106 P2 S1 H1 T45 ; set fan 2 value. Thermostatic control is turned on
M950 F3 C"out6" Q500 ; create fan 3 on pin out6 and set its frequency
M106 P3 S1 H2 T45 ; set fan 3 value. Thermostatic control is turned on
In this example, there are three fans defined. Fan 0 is the part cooling fans, and will be mapped to Tool 0 and Tool 1 (see next section on Tool definistions). Fan 2 and 3 are thermostatically controlled hot end cooling fans. These do not need to be mapped to the tool.
; Fans
M950 F0 C"fan0" Q500 ; create fan 0 on pin fan0 and set its frequency
M106 P0 S0 H-1 ; set fan 0 value. Thermostatic control is turned off
M950 F1 C"fan1" Q500 ; create fan 1 on pin fan1 and set its frequency
M106 P1 S1 H1 T45 ; set fan 1 value. Thermostatic control is turned on
M950 F2 C"fan2" Q500 ; create fan 2 on pin fan2 and set its frequency
M106 P2 S1 H2 T45 ; set fan 2 value. Thermostatic control is turned on
In RRF 2.x, fans are configured using M106.
In this example, there are three fans defined. Fan 0 is the part cooling fans, and will be mapped to Tool 0 and Tool 1 (see next section on Tool definistions). Fan 2 and 3 are thermostatically controlled hot end cooling fans. These do not need to be mapped to the tool.
; Fans
M106 P0 S0 I0 F500 H-1 ; set fan 0 value, PWM signal inversion and frequency. Thermostatic control is turned off
M106 P1 S1 I0 F500 H1 T45 ; set fan 1 value, PWM signal inversion and frequency. Thermostatic control is turned on
M106 P2 S1 I0 F500 H2 T45 ; set fan 2 value, PWM signal inversion and frequency. Thermostatic control is turned on
A tool is a combination of zero or more extruder drives and zero or more heaters.
For more information, see Multiple tools and Tool change macros.
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 F0 ; tool 0 uses extruder drive 0, heater 1 and fan 0 (part cooling fan)
G10 P0 X0 Y0 Z0 ; set tool 0 axis offsets
G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C
To map more than one fan to the tool, the definition would typically look like this :
M563 P0 D0 H1 F0:1 ; tool 0 uses extruder drive 0 and heater 1. Fan 0 and Fan 1 are mapped to tool 0
The tool definition for a typical dual nozzle printer would look like this:
M563 P0 D0 H1 F0 ; define tool 0
G10 P0 X-10 Y0 Z0 ; set tool 0 axis offsets
G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C
M563 P1 D1 H2 F2 ; define tool 2
G10 P1 X10 Y0 Z0 ; set tool 1 axis offsets
G10 P1 R0 S0 ; set initial tool 1 active and standby temperatures to 0C
This defines a second tool, which uses extruder drive 1, heater 2 and fan 2, mapped to fan 0. "Mapped to fan 0" means when the slicer attempts to control fan 0 (because it only knows about fan 0), we instead send that to the appropriate fan based on which tool is selected. This allows for a slicer which is only aware of one fan to control two different fans based upon tool (nozzle) selection. Fan 1 could be used, however fan 1 is often used as a thermostatically controlled heatsink cooling fan on hotends. 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 F0 ; define tool 0
G10 P0 X0 Y0 Z0 ; set tool 0 axis offsets
G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C
M563 P1 D1 H1 F0 ; define tool 1
G10 P1 X0 Y0 Z0 ; set tool 1 axis offsets
G10 P1 R0 S0 ; set initial tool 1 active and standby temperatures to 0C
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 X0 Y0 Z0 ; set tool 0 axis offsets
G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C
In this case there is a single tool but it uses two extruder drives.
A typical epilogue might look like this:
M556 S100 X0 Y0 Z0 ; Put your axis compensation here
M912 P0 S0 ; Put your CPU temperature sensor correction here
M501 ; load saved parameters from non-volatile memory
M911 S10 R11 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000" ; set voltage thresholds and actions to run on power loss
T0 ; select first tool
M556 axis compensation allows you to compensate in the firmware for the X, Y and Z axes not being exactly at right angles.
M912 sets the electronics temperature monitor adjustment
M501 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.
M911 configures auto-save on power loss.
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.
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 positioning
G1 H2 Z5 F6000 ; lift Z relative to current position to avoid dragging nozzle over the bed
G1 H1 X-235 F1800 ; move up to 235mm in the -X direction, stopping if the homing switch is triggered (first pass)
G1 H2 X5 F6000 ; go back a few mm
G1 H1 X-235 F360 ; move slowly to X axis endstop once more (second pass)
G1 H2 Z-5 F6000 ; lower Z again
G90 ; absolute positioning
Note the H1 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 H2 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 positioning
G1 H2 Z4 F200 ; lift Z relative to current position to avoid dragging nozzle over the bed
G1 H1 X235 F3000 ; move up to 235mm in the +X direction, stopping if the homing switch is triggered (first pass)
G1 H2 X-5 F600 ; go back a few mm
G1 H1 X10 ; move slowly to X axis endstop once more (second pass)
G1 H2 Z-4 F200 ; lower Z again
G90 ; absolute positioning
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 H1 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.
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 H2 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.
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 H1 Z250 F300 ; move Z towards the switch until it triggers
G1 H2 Z-5 F100 ; move Z back 5mm
G1 H1 Z10 F100 ; move Z slowly towards the switch until it triggers
G90 ; back to absolute mode
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 H2 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 H1 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 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:
M98 P"homex.g"
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 H2 Z4 F200 ; raise head 4mm
G1 H1 X-240 Y-240 F3000 ; move up to 240mm in the -X and -Y directions until the homing switches are triggered
G1 H2 X4 Y4 F600 ; move slowly 4mm in +X and +Y directions
G1 H1 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
Mesh bed compensation was introduced with RRF v1.17, and is generally the easiest way to compensate for an uneven bed. The bed mesh is defined, usually in config.g, by M557. An example might be:
M557 X15:245 Y15:245 S20 ; define mesh grid
The bed.g file runs when you send G32. Before running G29 Mesh bed compensation, use M561 to clear any existing mesh or transformations. Your printer should also be homed, and the Z datum should be set, ie where Z=0, usually with the nozzle touching the bed, and ideally in the centre of the build area. So bed.g might contain:
M561 ; clear any bed transform
G28 ; home all axes, establish Z datum
G29 ; probe the bed and enable compensation
This section is about using the older 3, 4 and 5 point bed compensation, using probe points defined in the bed.g file. Mesh bed compensation has effectively replaced this compensation method, and support for 3, 4 and 5 point bed compensation has been dropped from RRF 3.1.0 and later.
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.
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:
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.
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.
You can define your own macro files; see Macros and setting up macros for common tasks. 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: