The firmware is more and more used to control aother things then extruders as well. With the new modular concept it might get even more used for different usages. Therefore we now do not assume the it only handles extruders. As a result we now have tools that can be active. There is always at least one tool online. It is also possible to have several tools active at the same time, e.g. to extruders with an offset big enough to print a object twice. Other tools can be cnc mills and lasers and z-probes.
All tools are mounted at a known position. These are defined by offsets to a virtual reference point. Single tool systems should use offset of 0. In multiple tool systems the first tool is often the reference. For deltas the reference point is the cente rof the carriage. Here you can not freely choose it.
Tools get selected by the Tx command with x being the index in the TOOLS list in Configuration.h:
#define NUM_TOOLS 2
#define TOOLS \
{ &ToolExtruder1, &ToolExtruder2 }
When you select a tool the following sequence gets executed:
Defines a standard extruder. Abstract definition of an extruder is a heater combined with a stepper driver and a fan pwm output. The fan is controlled exactly by move, so if you change intensity between 2 moves the intensity will change exactly between them. There will be of course some delay for the fan to change the intensity. Thsi fan is meant to cool the filament and gets controlled with the M106/M107 commands.
If you need a cooler for the extruder body to reduce heating zone, you simply add a cooler based on the extruder heater.
TOOL_EXTRUDER(name, offx, offy, offz, heater, stepper, diameter, resolution, yank, maxSpeed, acceleration, advance, startScript, endScript, fan)
Parameter | Function |
---|---|
name | The variable name of the tool. |
offx | Offset x direction in mm. |
offy | Offset y direction in mm. |
offz | Offset z direction in mm. |
heater | Heater for output. |
stepper | Stepper module for this extruder. |
diameter | Filament diameter in mm. |
resolution | Steps per mm to suck in 1mm of filament. |
yank | 200% of the possible start speed. |
maxSpeed | Maximum speed in mm/s. This is for retracting and not for extruding! |
acceleration | Max. acceleration for extrusion moves. |
advance | The variable name of the tool. |
startScript | G-code string to execute, when tool gets activated. Multiple commands get seperated by \n. |
endScript | G-code string to execute, when tool gets deactivated. Gets called before the next tool gets activated. Multiple commands get seperated by \n. |
fan | Address of the fan pwm (&pwmName) or nullptr if no fan is attached. |
None.
Handles a laser device. In fact it only manages a PWM output during moves. This intensity gets defined by M4 or M5 and gets adjusted to the current speed. So during acceerations it will increase the intensity. At some speed it is not possible to get enough energy, then it will limit it to full power. The laser power is defined in milli watt. The energy you want is milli watt * second / mm. Multiplied with the current velocity [mm/s] we get the milli watt setting required. So we assume here a linear dependency, also this is not necessarily true.
The laser supports a biased gamma correction. You can set the correction using M3/M4. Parameter B is bias correction and C is gamma coefficient.
Some lasers have a slight delay when getting powered after been disabled. To overcome this problem you can also set a warmup time during which the laser will be on without moving the laser. Set it to 0 if your laser(driver) does not need this.
TOOL_LASER(name, offx, offy, offz, output, toolPin, activePin, milliWatt, warmupUS, warmupPWM, bias, gamma, startScript, endScript)
Parameter | Function |
---|---|
name | The variable name of the tool. |
offx | Offset x direction in mm. |
offy | Offset y direction in mm. |
offz | Offset z direction in mm. |
output | PWM for output. |
toolPin | Output that gets high when tool is active. Use a fake output if not needed. |
activePin | Output that gets high after M3/M4 and low after M5. Use fake output if not needed. |
milliWatt | Laser power at full intensity in milli watt. |
warmupUS | Warmup time in micro seconds. |
warmupPWM | PWM setting (0..255) during warmup sequence. |
bias | Minimum energy to get a result in milli watt. 0 = no bias. |
gamma | Gamma correction for energy curve. 1.0 = linear behaviour. |
startScript | G-code string to execute, when tool gets activated. Multiple commands get seperated by \n. |
endScript | G-code string to execute, when tool gets deactivated. Gets called before the next tool gets activated. Multiple commands get seperated by \n. |
None.
Handles a CNC mill. Support a pwm signal and a direction pin. The enable pin is activated when a rpm value is set. So in case oyu have no RPM only full speed, you can use this pin instead and use a fake PWM output.
TOOL_CNC(name, offx, offy, offz, output, dirPin, toolPin, enablePin, rpm, startStopDelay, startScript, endScript)
Parameter | Function |
---|---|
name | The variable name of the tool. |
offx | Offset x direction in mm. |
offy | Offset y direction in mm. |
offz | Offset z direction in mm. |
output | PWM for output. |
dirPin | Output that gets high when tool should turn CW. Off for CCW. Use a fake output if not needed. |
toolPin | Output that gets high when tool is active. Use a fake output if not needed. |
activePin | Output that gets high on M3/M4 and low after M5. Use fake output if not needed. |
RPM | Rotations per minute when PWM is at max. level 255. |
startStopDelay | Delay in milli seconds before the first moves will be executed. |
startScript | G-code string to execute, when tool gets activated. Multiple commands get seperated by \n. |
endScript | G-code string to execute, when tool gets deactivated. Gets called before the next tool gets activated. Multiple commands get seperated by \n. |
None.
You can bind additional functionality to tools. This allows a more flexible approach to fullfill all needs.
This sensor type uses a input signal that switches signal every x steps when extruder moves. If a extruder is jammed the signal will not switch any more also the extruder is still turning. That way the jam can be detected. The same condition also happens if the filament ha srun out. The signal will not switch and it will be reported to stop the print.
The sensor is coupled to an extruder motor. To make it work, it needs to have a position of the motor which stepper drivers normally do not provide. Use the STEPPER_OBSERVEABLE module to create a driver where the position can be observed.
For a reliable work you need 3 input parameter. Most important is the average number of steps between signal changes. At the signal change position the signal might switch fast if it is on the edge. So we require a minimum movement until we consider a change to be a change. And lastly you need to define a jam error percentage. A value of 200% means only if you need more then 200% of the average distance we consider this a jam. Do not set this too low or you will get many false signals. When you debug your signals you will often see that the number of steps varies. So select a value big enough to come outside these variations.
The jam control can be enabled with M602 P0 and disabled with M601 P1. M602 S1 sets it into debug mode. Then firmware will not trigger an error, but instead writes the distance between signal changes into the log. Use this to find the average and expected range of steps for the configuration.
JAM_DETECTOR_HW(name, observer, inputPin, tool, distanceSteps, jitterSteps, jamPercentage)
Parameter | Function |
---|---|
name | The variable name of the jam detector. |
observer | Observed stepper driver name. |
inputPin | Pin class for the signal (IO_INPUT_...). |
tool | Tool variable the detector belongs to. |
distanceSteps | Average number of steps between signal changes. |
jitterSteps | Signal changes within this step count will be ignored. |
jamPercentage | Required deviation of the distanceSteps to trigger the jam procedure. |
None.
This sensor type uses a input signal that is high if a filament is loaded and low when it is removed. If there is no filament loaded when firmware starts, no error will be triggered!
The filament sensor can be enabled with M602 P0 and disabled with M601 P1. This is also shared with the jam function.
FILAMENT_DETECTOR(name, inputPin, tool)
Parameter | Function |
---|---|
name | The variable name of the filament detector. |
inputPin | Pin class for the signal (IO_INPUT_...). |
tool | Tool variable the detector belongs to. |
None.