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.
There are normally three specified tool change macros (any of which can contain no commands if desired) that execute in this order:
- Actions to do with the old tool before it is released - macro name: tfreeN.g where N is the tool number;
- Actions to do with the new tool before it is selected - macro name: tpreN.g where N is the tool number;
- Actions to do with the new tool after it is selected - macro name: tpostN.g where N is the tool number.
If Tn is used to select tool n but that tool is already active, the command does nothing. Otherwise, the sequence followed is:
- If the new tool number is not the same as the old tool number, including if either old or new tool number is -1 (i.e. no tool), the current coordinates are saved to memory slot 2 automatically (see G60).
- Run macro tfree#.g where # is the number of the old tool.
- If a tool is already selected, deselect it and set its heaters to their standby temperatures (as defined by the R parameter in the most recent G10/M568 command for that tool)
- Run macro tpre#.g where # is the number of the new tool
- Set the new tool to its operating temperatures specified by the S parameter in the most recent G10/M568 command for that tool
- Run macro tpost#.g where # is the number of the new tool. Typically this file would contain at least a M116 command to wait for its temperatures to stabilise.
- Apply any X, Y, Z offset for the new tool specified by G10
- Use the new tool.
Important notes:
- When a tool change is requested, RRF will run the tool change macros tfree#.g, tpre#.g and tpost#.g, where # is the appropriate tool number. If a tool-number-specific file is not found, RRF tries to run tfree.g, tpre.g or tpost.g (without a tool number), regardless of the tool number.
- Prior to RRF 3.3, when changing tools, tool change macro files are not run unless all axes have been homed. In RRF 3.3 and later, tool change macro files are run regardless of whether axes have been homed or not. You can use meta GCode to choose which commands are executed if axes have been homed/not homed.
- G28 should not be used to home axes in tool change macros. If you do need to home axes, it is best to put the homing commands directly in the tool change macro.
- In RRF 3.7.1 and later, meta Gcode command 'abort' in a tool change macro, or in any macro called from one, ends the tool change: the remaining tool change macros are not run and the tools stay where the change had got to. After an abort in tfree#.g the old tool is still selected, after an abort in tpre#.g no tool is selected, and after an abort in tpost#.g the new tool is selected. The tool change is not marked as failed, so there is no way yet to react to it afterwards. In earlier versions 'abort' should not be used in tool change macros, as it leaves the tool change process in an unknown state.
Example of using conditional Gcode in a tool change macro (this would usually go in tpre#.g):
if (move.axes[0].homed) ; check if X axis is homed
echo "X axis homed, continuing with tool change"
; rest of tool change commands here
else
echo "Tool change FAILED, X not homed!"
Prior to RRF 3.3, 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.
In RRF 3.3 and later, tool change macro files are run regardless of whether axes have been homed or not, and will run if Tn is in config.g. You can either put T0 P0 in config.g (to select the tool without running any tool change files), or use conditional GCode to choose which commands are executed.
- From RRF 3.6.0, for tool changers and similar machines: when input shaping is used, there is a slight overlap between successive movement commands. This can cause problems if one of the moves performs a tool lock or unlock operation. For example, if the preceding move lines the tool up with the pickup head then that move may not be complete when the move to engage the lock commences. Therefore you should either disable input shaping before performing these sequences of moves, or use M400 before and after every movement command that controls a tool locking motor.
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 starting up you can arrange for both tools to start heating as shown in the following example
G10 P0 S200 R150 ; Set tool 0 active and standby temperatures
G10 P1 S200 R150 ; Set tool 1 active and standby temperatures
T1 P0 ; Select tool 1 to turn it on but don't execute tool change scripts
T0 ; Select tool 0
M116 ; Wait for all temperatures to be reached
This will turn both heaters on, heating tool 0 heater to 200C and tool 1 heater to 150C. This could go in the sys/start.g file, or be generated by the slicer at the beginning of the gcode.