Configuring RepRapFirmware for a Cartesian printer
RepRapFirmware is configured at run-time by means of files in the /sys folder of the SD card. You do not have to recompile RepRapFirmware to configure it. You must have an SD card in the on-board socket to use RepRapFirmware, it cannot operate correctly without one.
Main configuration file
The main configuration file is sys/config.g. This file is read when RepRapFirmware starts up. It is typically organised into sections along the following lines.
Prologue and communications section
M111 S0 ; Debug off M550 PMyOrmerod ; Machine name (can be anything you like) M551 Preprap ; Machine password (currently not used) M540 P0xBE:0xEF:0xDE:0xAD:0xFE:0xED ; MAC Address M552 P0.0.0.0 ; IP address (0 = use DHCP) M554 P192.168.1.1 ; 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)
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. If you have more than one Duet on your network, you must given them all different MAC addresses.
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 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) G21 ; Work in millimetres G90 ; Send absolute coordinates... M83 ; ...but relative extruder moves
The M569 commands are optional, drives go forward by default.
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 S2 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 similarly.
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%.
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 ; smart IR Z probe, used for homing Z axis only, dive height 3mm G31 P500 X11.0 Y0.5 Z1.65 ; set threshold and offsets M210 Z500 ; set Z probing speed
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.
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 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. 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 intermittant 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. On a delta printer these should be left at zero, because the calibration routine needs to know where the nozzle has been placed, not where the probe is.
The M210 command sets the speed of Z probing. It 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.
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 M301 H1 P10 I0.10 D100 T0.50 S1.0 ; PID settings for extruder 0 M301 H2 P10 I0.10 D100 T0.50 S1.0 ; PID settings for extruder 1 M570 S120 ; Increase to allow extra heating time if needed ;M141 H3 ; Uncomment this to set chamber heater/thermistor channel
The M305 commands define the thermistor resistance at 25C (T parameter), thermistor B value (B parameter), 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.
The R value depends on which version of the Duet you have. Older Duet 0.6 boards, and Duet 0.6 boards supplied by Replikeo according to recent reports, use 1K series resistors, which is the firmware default. Later Duet 0.6 boards and all Duet 0.8.5 boards and Duet Shields use 4.7K resistors. If the hot end and bed temperatures read about 60C when they are at room temperature, this generally means that you have configured the firmware for 1K series resistor but your board uses 4.7K.
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.
The M305 command also takes an optional X parameter (not shown in the example) to allow thermistor 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). Future versions of RepRapFirmware may use thermistor channel numbers 100 upwards to denote readings from thermocouples.
The M301 commands set the PID parameters for each heater channel. P, I and D are the usual PID parameters. A negative P value means use bang-bang control for that channel (which is the default for the bed). W is the maximum value of the I accumulator (0 to 255). B is the temperature band within which PID is used, for example if B is 30 then the heater will be full on or off until it is within 30C of the set temperature. T is the approximate additional PWM value (on a scale of 0 to 255) needed per 1C of additional temperature, used to pre-set the I accumulator when switching to PID. Finally, the PID output can be scaled by the S term. This allows you to adapt to a different heater power or supply voltage without having to change all of P, I, D and T.
The M570 command defines the time-to-hot timeout in seconds. When heating up the hot end, if the heater temperature is not within 2.5C of the commanded temperature within this time then the heater will be turned off and an error condition reported.
If you have a chamber heater, use the M141 command to define which heater channel it uses. You will also need to use M305 and M301 to define thermistor and PID parameters for that channel.
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) and heater 1 (H 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 ; tool 1 uses extruder drive 1 and heater 2 G10 P1 S0 R0 X10 Y0 ; set tool 1 temperatures and offsets
This defines a second tool, which uses extruder drive 1 and heater 2. 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 both extruder drives.
A typical epilogue would look like this:
M556 S100 X0 Y0 Z0 ; Put your axis compensation here 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 .
The T0 at the end selects tool 0. It is optional, but without it you will need to activate a tool before you can heat up the hot end or do extrusion. It is recommended that you also put the T0 command in the start gcode of your slicing program.
The homing files for a Cartesian 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 Z4 F200 ; raise head to avoid dragging nozzle over the bed G1 X-240 F3000 S1 ; 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 X-10 S1 ; move slowly 10mm in the -X direction, stopping at the homing switch G1 Z-4 F200 ; lower the head again G90 ; back to absolute mode
For a machine with a homing switch at the high end, it would look like this instead:
G91 ; relative mode G1 Z4 F200 ; raise head to avoid dragging nozzle over the bed G1 X240 F3000 S1 ; 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 X10 S1 ; move slowly 10mm in the +X direction, stopping at the homing switch G1 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.
The homey.g is similar to homex.g except that all instances of X are replaced by Y.
Z homing is normally done using the Z probe. Here is a typical homez.g file:
G91 ; relative mode G1 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 coordinates in the 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.
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. Here is a sample homeall.g file for a machine with X and Y endstop switches at the low end:
G91 ; relative mode G1 Z4 F200 ; raise head 4mm G1 X-240 Y-240 F3000 S1 ; move up to 240mm in the -X and -Y directions until the homing switches are triggered G1 X4 Y4 F600 ; move slowly 6mm in +X and +Y directions G1 X-10 Y-10 S1 ; 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
To be completed.
Tool change files
To be completed.
Pause and resume files
To be completed.