For a general guide to configuring RepRapFirmware, see Configuring RepRapFirmware for a Cartesian printer. Only the differences for IDEX printers are described here.
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.
The easiest way to generate these files is using the RepRapFirmware configuration tool.
RepRapFirmware 1.16 and later allow you to configure up to four X-carriages. The common case is two X-carriages on one set of rails, which home to opposite ends of the X axis. When one head is printing, the other is parked at or near its home position. This arrangement is sometimes referred to as IDEX.
For each additional X-carriage, you need to:
A machine with 2 independent X carriages needs 4 axis motors and 2 extruder motors, total 6. As the Duet 2 WiFi and Duet 2 Ethernet have only 5 motor drivers, you will need to add a 6th stepper driver via the expansion connector. The easiest way is to use a Duex 2 or Duex 5 expansion board.
NOTE: the U axis uses the E0 endstop input, and the V axis uses E1.
Create a new axis by defining the motors it uses in a M584 command. Example for an IDEX machine:
M584 X0 Y1 Z2 U3 E4:5 ; create the U axis and assign stepper driver 3 to it
Note: if you create axis V then axis U will also be created even if you didn't ask for one. Similarly, if you create the W axis then U and V will also be created. But the motor assignments for the extra new axes will probably not be what you want.
The M584 command should come before every other command that needs to refer to the new axes, because axis letters U, V and W are not recognised in other G and M commands until the corresponding axes have been created. So put it at the beginning of the movement section of config.g.
Your new axes should be configured in your M201, M203, M208, M350, M566, M574 and M906 commands in config.g exactly as for the other axes. For most of these commands, you just need to add the additional axis parameters. For example, if you were using M203 X15000 Y15000 Z100 in your single carriage machine, change it to M203 X15000 Y15000 U15000 Z100 for IDEX.
The M208 commands will be slightly different, because on an IDEX machine the movement ranges of the two carriages will be different, for example:
M208 X200 Y200 U250 Z200 M208 S1 X-50 Y0 U0 Z0
In this example, the X carriage moves along the X axis from -50 to 200 and the U carriage moves from 0 to 250. So there is a printable zone accessible to both carriages from 0 to 200.
For an IDEX machine, the X endstop will be at the low end and the U endstop will be at the high end. Remember to declare this in the M574 command.
Here is a sample Drives section of config.g for an IDEX machine:
; Drives M569 P0 S1 ; Drive 0 goes forwards (change to S0 to reverse it) M569 P1 S1 ; Drive 1 goes forwards M569 P2 S1 ; Drive 2 goes forwards M569 P3 S1 ; Drive 3 goes forwards M569 P4 S1 ; Drive 4 goes forwards M569 P5 S1 ; Drive 5 goes forwards M584 X0 Y1 Z2 U3 E4:5 ; Create U axis for second X carriage before we try to configure it M574 X1 Y1 Z0 U2 S1 ; Set endstop configuration (X and Y endstops at low end, U endstop at high end, active high, no Z endstop) M906 X800 Y800 U800 Z800 E1000 ; Set motor currents (mA) M201 X800 Y800 U800 Z15 E1000 ; Accelerations (mm/s^2) M203 X15000 Y15000 U15000 Z100 E3600 ; Maximum speeds (mm/min) M566 X600 Y600 U600 Z30 E20 ; Maximum jerk speeds mm/minute M208 X200 Y200 U250 Z200 ; Set axis maxima (adjust to suit your machine) M208 X-50 Y0 U0 Z-0.2 S1 ; Set axis minimum (adjust to make X=0 and Y=0 the edge of the bed) M92 X80 Y80 U80 Z2560 ; Set axis steps/mm M92 E420:420 ; Set extruder steps per mm G21 ; Work in millimetres G90 ; Send absolute coordinates... M83 ; ...but relative extruder moves
Your new axes need their own homing files. For an IDEX machine, you need to add homeu.g. File homex.g will home to the low end and homeu.g will home to the high end.
Your homeall.g file should home the new axes as well as X, Y, Z. On a Cartesian printer you will normally be able to home your additional axes simultaneously with X and Y.
If you home Z using a Z probe, then that probe should be mounted on the X carriage and you should ensure that the X carriage is over the bed when you probe using G30. One way of doing this is to deselect all tools prior to probing. Another is to use the S2 modifier on the G1 commands, which disables axis mapping. You should also park the U carriage out of the way of where you want to probe.
Here are some sample files.
; Home X at the low end of the axis G91 G1 Z4 F200 G1 X-240 F3000 S1 G1 X4 F600 S2 G1 X-10 S1 G1 Z-4 F200 G90
; Home U at the high end of the axis G91 G1 Z4 F200 G1 U240 F3000 S1 G1 U-4 F600 S2 G1 U10 S1 G1 Z-4 F200 G90
; Home Z using the Z probe mounted on the X carriage G91 G1 Z4 F200 ; raise head 4mm to keep it clear of the bed G1 U200 F2000 ; make sure the U carriage is out of the way G90 G1 X100 Y100 F2000 S2 ; move to bed centre for probing G30 ; probe the bed and set Z height
; Home X, Y, U simultaneously G91 G1 Z4 F200 ; raise head 4mm to keep it clear of the bed G1 X-240 Y-240 U240 F3000 S1 ; coarse home X, Y and U G1 X4 Y4 U-4 F600 S2 ; move 4mm away from the homing switches G1 X-10 Y-10 U10 S1 ; fine home X, Y and U G90 ; Now home Z using the Z probe G1 X100 Y100 F2000 S2 ; move to bed centre for probing G30 ; probe the bed and set Z height
Bed probing is always done using the X carriage - so the X carriage is the one that carries your Z probe. The X coordinates in G30 commands are never mapped.
You should take the following precautions in the bed.g file for an IDEX machine:
A tool that uses the X carriage should be configured as normal:
M563 P0 D0 H1 ; tool 0 uses extruder 0 and heater 1 G10 P0 X0 Y0 Z0 S0 R0 ; set tool 0 offsets and temperatures
This assumes the print cooling fan for this tool is on F0, if not (if it's on Fan 1, for example) then add that to the mapping:
M563 P0 D0 H1 F1 ; tool 0 uses extruder 0 and heater 1 and fan channel 1
A tool that uses the U carriage for X movement need an X3 parameter in the M563 command:
M563 P1 D1 H2 X3 F2 ; tool 1 uses extruder 1 and heater 2 and maps X to U, use fan 2 as the print cooling fan G10 P1 Y0 U0 Z0 S0 R0 ; set tool 1 offsets and temperatures
This tells the firmware that the X axis should be mapped to axis #3 which is the U axis. Note that the "X offset" of tool 1 is actually a U offset, because tool offsets are applied after axis mapping. Also the third fan channel is configured to this tool. This is because many slicers will send M106 Sxxx without any fan number, When this head is selected any M106 commands will refer to the fan on channel 3.
You should adjust the Y and Z offsets of tool 1 so that both tools print at the same locations along the Y axis and at the same heights. To get both tools printing at the same place along the X axis, either adjust the homing positions of the X and U axes via the M208 commands, or adjust the G10 P0 X offset and/or the G10 P1 U offset, see the Calibration section below.
If you want to print using two or more carriages simultaneously, you will need to adjust the carriages so as to have equal nozzle heights, i.e. zero Z offset in the G10 commands. Otherwise you will only be able to get one of the nozzles at the perfect first layer height. You will also need to have a flat and level bed in at least the X direction, because bed compensation can only adjust the nozzle height for a single X position.
To print with both carriages at once you need to map X movement to both X and U, like this:
M563 P2 D0:1 H1:2 X0:3 F1:1 ; tool 2 uses both extruders and hot end heaters, maps X to both X and U, and uses both print cooling fans G10 P2 X50 Y0 U-50 S0 R0 ; set tool offsets and temperatures for tool 2
Note that axes are mapped in the order XYZUVWABC, where X=0, Y=1, Z=2, U=3 etc, not by driver number, so X0:3 means 'map axis 0 (X) and 3 (U) to X'.
In this example we want to print one object using the X carriage and another identical object 100mm further along using the U carriage. So we specify X and U offsets of 50mm in opposite directions. However, tool offsets are given as the offset of the nozzle relative to the print head reference point, so the signs are opposite to what you might expect because tool offsets are subtracted from the required printing locations during printing. So we need to use an X offset of +50mm to force the X carriage to be 50mm lower along the X axis, and a U offset of -50mm to force the U carriage to print 50mm higher along the X axis.
To get the firmware to extrude on both extruders equally, we use the M567 and M568 commands, which were originally provided to support mixing hot ends:
M567 P2 E1:1 ; set mix ratio 100% on both extruders M568 P2 S1 ; turn on mixing for tool 2
; Tool configuration section of config.g ; Create a tool that uses the low end (X) carriage M563 P0 D0 H1 F0 ; tool 0 uses extruder 0, heater 1 and fan 0 G10 P0 X0 Y0 Z0 S0 R0 ; set tool 0 offsets and temperatures ; Create a tool that uses the high end (U) carriage M563 P1 D1 H2 X3 F2 ; tool 1 uses extruder 1, heater 2, fan 2, and maps X to U G10 P1 Y0 U0 Z0 S0 R0 ; set tool 1 offsets and temperatures ; Create a tool that prints 2 copies of the object using both carriages M563 P2 D0:1 H1:2 X0:3 F0:2 ; tool 2 uses both extruders, hot end heaters and fans, and maps X to both X and U G10 P2 X50 Y0 U-50 S0 R0 ; set tool offsets and temperatures M567 P2 E1:1 ; set mix ratio 100% on both extruders
You can also create a 'mirror' mode, by using the same tool settings as the '2 copies', but with different X offsets, and setting M579 U-1 in the tool's tpost.g macro, and M579 U1 in the tfree.g tool change macros (see below). M579 changes the direction of the axis. See this thread on the forum for details.
To do dual-colour or dual-material prints, you need to make sure that the unused carriage is always parked out of the way. Start by including a G28 or a G28 X U command in your slicer start gcode, to ensure that both tools are homed initially. Then use the tfree#.g files (where # is the tool number) to park a tool when you stop using it. To park a tool you could just home it, but you may prefer to move it to 1mm or so short of the homing position so that you can use a fast travel move to get there. To control oozing, you can use a lower standby temperature than active temperature, and retract a little filament.
Here are some sample tool change files for tools 0, 1 and 2 of an IDEX machine configured as above.
NOTE: these examples show how to do retraction and unretraction using the tool change files however depending on your results you may prefer to remove the retraction and unretraction and configure them in the slicer instead. Slicers will unretract just before starting to print, after moving the tool to the start point, which gives better ooze performance.
M83 ; relative extruder movement G1 E-2 F3600 ; retract 2mm M106 S0 ; turn off our print cooling fan G91 ; relative axis movement G1 Z3 F500 ; up 3mm G90 ; absolute axis movement G1 S2 X-48 F6000 ; park the X carriage at -48mm
M83 ; relative extruder movement G1 E-2 F3600 ; retract 2mm M106 S0 ; turn off our print cooling fan G91 ; relative axis movement G1 Z3 F500 ; up 3mm G90 ; absolute axis movement G1 S2 U248 F6000 ; park the U carriage at +248mm
M83 ; relative extruder movement G1 E-2 F3600 ; retract 2mm M106 S0 ; turn off our print cooling fan G91 ; relative axis movement G1 Z3 F500 ; up 3mm G90 ; absolute axis movement G28 X U ; home the X and U carriages
M106 R2 ; restore print cooling fan speed M116 P0 ; wait for tool 0 heaters to reach operating temperature M83 ; relative extruder movement G1 E2 F3600 ; extrude 2mm
M106 R2 ; restore print cooling fan speed M116 P1 ; wait for tool 1 heaters to reach operating temperature M83 ; relative extruder movement G1 E2 F3600 ; extrude 2mm
M106 R2 ; restore print cooling fan speed M116 P2 ; wait for tool 2 heaters to reach operating temperature M83 ; relative extruder movement M567 P2 E1:1 ; set tool mix ratio M568 P2 S1 ; turn on mixing G1 E2 F3600 ; extrude 2mm from both extruders
When you pause a print, either or both heads may be printing, so you should park both of them in your pause.g file. Use the G1 command with the S2 modifier to do this. Here is an example pause.g file:
M83 ; relative extrusion G1 E-2 F3600 ; retract 2mm G91 ; relative movement G1 Z2 F500 ; raise head 2mm G90 ; absolute movement G1 S2 X-48 U248 F6000 ; park both heads
Your resume.g file needs to restore the position and undo any retraction:
G1 R1 X0 Y0 Z2 F5000 ; move to 2mm above the resume location G1 R1 X0 Y0 Z0 F500 ; move to the resume location M83 ; relative extrusion G1 E2 F3600 ; undo the retraction
To calibrate the printer so that both extruders print at the same point follow these principles:
With both tools at the same Z height, or the difference accounted for in the G10 P1 Zn.n command, the heads need to be aligned in X and Y. Start by getting them in the right ballpark (~1mm) in the following manner:
Now the tools are roughly aligned, fine alignment can be conducted in a number of ways. One method is to print a dual extruder print with lines, or triangles of varying spacing and then work out where they align:
the two parts of this file are printed with the two tools and the line that most closely aligned is selected. If the line 3 left from the center is the closes, and the variation is 0.2mm then the U axis is 0.6mm too far to the left.
The process is repeated with the model rotated 90 degrees for the Y axis.
The STL files and OpenScad document are available on the Think3dPrint3d Github as IDEXcalibration_reg.stl and IDEXcalibration_var.stl. Print the 'reg' one with the X axis and the 'var' one with the U axis.
Note: This process is similar to that used by BCN3D with their SIGMA printer.