Configuring and calibrating a delta printer using the dc42 fork of RepRapFirmware
For a general guide to configuring RepRapFirmware, see Configuring RepRapFirmware for a Cartesian printer. The differences for delta printers are described here.
Movement section of config.g file
To tell RepRapFirmware that your printer is a delta and to define its parameters, put command M665 L### R### H### B### X### Y### Z### in your sys/config.g file on the SD card, where ### represents a number. The L parameter is the diagonal rod length. The R parameter is your estimate of the delta radius. The H parameter is the height of the nozzle above the bed when the carriages are activating the endstop switches. The B parameter is the printable radius of the bed. X Y Z are the angular offsets of the X, Y and Z towers, and may be omitted or set to zero. All these values may include decimal portions.
You can also use an M666 command to set the homing switch corrections.
You also need to tell RepRapFirmware that the endstop switches are all at the high end using the M574 command. Here is an extract from a sample config.g file for the Mini Kossel:
; Axis and motor configuration M569 P0 S1 ; Drive 0 (X) goes forwards M569 P1 S1 ; Drive 1 (Y) goes forwards M569 P2 S1 ; Drive 2 (Z) goes forwards M569 P3 S1 ; Drive 3 (E0) goes forwards M569 P4 S1 ; Drive 4 (E1) goes forwards M574 X2 Y2 Z2 S1 ; all endstops at high end, active high M665 R105.6 L215.0 B85 H235 ; set delta radius, diagonal rod length, printable radius and homed height M666 X0 Y0 Z0 ; put your endstop adjustments here M203 X18000 Y18000 Z18000 E3600 ; maximum speeds mm/minute
If your endstop switches produce active low outputs instead of active high, replace S1 in the M574 command by S0.
If your delta printer intentionally does not place the towers at the corners of an equilateral triangle, you can use additional X, Y and Z parameters in the M665 command to describe this. Consider a circle that passes through all three towers. The origin (i.e. bed centre assumed by the firmware) will be the centre of that circle. Label the towers X Y and Z moving around the circle in an anticlockwise direction as seen from above. Let X', Y' and Z' be the points on the circle where the towers would be if the towers were all 120 degrees apart and the Z tower in the +Y direction from the bed centre. Then the M665 X parameter is the angle from X' to X, the Y parameter is the angle from Y' to Y, and the Z parameter is the angle from Z' to Z, measured in degrees moving anticlockwise seen from above.
Example: a "square delta" has the towers at three of the four corners of a square. If Z is the middle tower and is at the rear left of the machine, then the M665 X Y Z parameters should be +15, +75 and +45 respectively.
The maximum usable XYZ speeds you can set in the M203 command depend on your tower steps/mm value. Version 1.09g-dc42 supports higher maximum speeds than earlier versions. As a general guide, your maximum XYZ speeds in mm/minute multiplied by your tower steps/mm should be below 2 million when running firmware version 1.09g-dc42 or 1.09h-dc42, and no more than 3.6 million when running firmware 1.09i-dc42 and later. If in doubt, try some long high-speed moves, then run command M122, then look at the MaxReps value which you should try to keep below 100. In practice, achieving the maximum speed that the firmware is capable of may require you to use 24V power instead of 12V power, in order that the driver chips can change the current in the stepper motors fast enough.
When configured for a delta printer, RepRapFirmware will always home all three towers by executing sys/homedelta.g when any G28 command is processed, ignoring any X, Y or Z parameters. Typical contents of homedelta.g would be:
G91 ; use relative positioning G1 S1 X300 Y300 Z300 F2500 ; move all carriages up 300mm, stopping at the endstops G1 S2 X-5 Y-5 Z-5 ; move all towers down 5mm G1 S1 X8 Y8 Z8 F500 ; move towers slowly up 8mm, stopping at the endstops G1 S2 X-5 Y-5 Z-5 F10000 ; move carriages down 5mm G90 ; back to absolute positioning
Adjust the “300” numbers in the first line to be somewhat greater than your maximum print height, to ensure that the carriages reach the endstops. During initial testing, you may wish to reduce the homing speed value “2500” in the second line to a lower value, to give yourself more time to press the reset or power button if something goes wrong. Alternatively, reduce the motor currents during initial testing using the M906 command.
The above works because when the S1 or S2 parameter is used in a G0 or G1 command, the X, Y and Z values in the command are used as values for the individual towers instead of the head coordinates. In the case of S1, the endstops are activated too.
Setting up the Z probe deploy and retract files
If your machine has a mechanical Z probe that needs to be deployed by moving the head in certain ways (e.g. standard Mini Kossel), then you need to set up macro files for deploying and retracting the probe. These are typically named sys/deployprobe.g and sys/retractprobe.g. Here is a sample deployprobe.g file:
M564 S0 ; don't apply limits G1 X25 Y93 Z40 F10000 ; put probe arm next to belt G1 X-5 F500 ; move probe arm slowly across belt G1 X12 F1000 ; move probe back G1 X0 Y0 F10000 ; move to somewhere sensible M564 S1 ; apply limits again
Here is a sample retractprobe.g file:
M564 S0 ; don't apply limits G1 Z40 F10000 ; raise head G1 X-59 Y66 Z35 ; move over the post G1 Z7 F500 ; push probe down on post G1 Z35 F10000 ; raise head again G1 X0 Y0 ; move to somewhere sensible M564 S1 ; apply limits again
Setting up the auto calibration file
RepRapFirmware-dc42 supports a fast auto-calibration process. From a single set of bed probe readings, the firmware uses a mathematical model of the delta geometry to calculate the corrections needed so as to minimise the sum of the squares of the height errors at the probe points. It reports the RMS (root-mean-square) of the bed probe height error before probing, and the expected RMS error when the calibration has been done. On a typical delta printer, the auto calibration process takes about 30 seconds, this being the time taken to probe the bed.
The mathematical model of delta geometry used by RepRapFirmware assumes that the bed is flat, all diagonal rods have the same lengths, and all three towers are perpendicular to the bed. If these constraints are satisfied, then a single auto calibration cycle is sufficient. If not, you may need to run auto calibration two or three times before the corrections converge.
Auto calibration is performed by sending command G32 (which is the same command used to do auto bed compensation on a Cartesian printer). This command runs macro file sys/bed.g, so all the work is done there. Here is a sample bed.g file:
M561 ; clear any bed transform, otherwise homing may be at the wrong height G31 X0 Y0 ; don't want any probe offset for this G28 ; home the printer ;*** Remove the following two lines if your Z probe does not need to be deployed M98 Pdeployprobe.g ; deploy the mechanical Z probe G30 P0 X0 Y0 Z-99999 ; dummy probe, because the mechanical probe gives inaccurate results the first time it is used after deployment ; Probe the bed and do 6-factor auto calibration G30 P0 X-73.6 Y-42.5 Z-99999 ; X tower G30 P1 X0 Y-85 Z-99999 ; between X and Y towers G30 P2 X73.6 Y-42.5 Z-99999 ; Y tower G30 P3 X73.6 Y20 Z-99999 ; between Y and Z towers G30 P4 X0 Y67 Z-99999 ; Z tower G30 P5 X-73.6 Y20 Z-99999 ; between Z and X towers G30 P6 X-36.8 Y-21.25 Z-99999 ; half way to X tower G30 P7 X36.8 Y-21.25 Z-99999 ; half way to Y tower G30 P8 X0 Y42.5 Z-99999 ; half way to Z tower G30 P9 X0 Y0 Z-99999 S6 ; centre, and auto-calibrate 6 factors ;*** Remove the following line if your Z probe does not need to be retracted M98 Pretractprobe.g ; retract the mechanical Z probe G1 X0 Y0 Z150 F15000 ; get the head out of the way of the bed
The probing is commanded by the G30 commands. You can have up to 16 probe points, numbered P0 to P15. The probe positions and order are not critical, but you should cover at least the centre and the extremities of the bed, both next to towers and opposite the towers, and some points in between the centre and the periphery. The XY coordinates are where the nozzle will be, so if the Z probe is displaced from the nozzle then you must ensure that the probe is always over the bed, even if this means moving some of the probe points in from the edge.
This example uses ten points: six around the periphery, one at the centre, and three halfway between the centre and the periphery. For large delta printers, add at least 3 more probe points halfway to the periphery.
If your Z probe has different trigger heights at different XY positions, you can add an H parameter to each G30 command. This gives the value that must be added to the G31 Z parameter to get the actual trigger height at that point. Set the G31 Z parameter so that it is accurate when probing the centre of the bed, and use the H parameter to correct for different trigger heights at the other bed probe points. The H parameter is supported in firmware version 1.09e-dc42 and later.
The S parameter on the final G30 command defines what calculation is actually done, as follows:
S=-1 Don't adjust anything, just print the height error at each probe point
S=0 Equivalent to S=<number_of_points_probed>
S=3 Adjust homing switch corrections only
S=4 Adjust homing switch corrections and delta radius
S=6 Adjust homing switch corrections, delta radius, and X and Y tower position offsets
S=7 Adjust homing switch corrections, delta radius, X and Y tower position offsets, and diagonal rod length
The adjustments are made so as to minimise the sum of the squares of the height errors.
If your printer is accurately built, then 4-factor calibration may be sufficient. For normal use I recommend 6-factor calibration. If you choose 7-factor calibration, then you need to include probe points that are opposite the towers and far enough away so that the rods to the farthest tower are nearly horizontal, otherwise the diagonal rod length is not very well defined by the probing errors. To achieve this, you will need an oversized bed, and you may need to temporarily allow movement outside the normal printing radius using the M574 command.
If you wish, you can define several variants of bed.g and run them using the M98 command, or just 'print' them like any other gcode file. In particular, it is useful to have a variant that uses S-1 on the final G30 command, so that you can check the height errors multiple times without adjusting anything, to get an idea of how reproducible the Z probe height readings are.
If the calibration errors are small, a single execution of bed.g will calibrate your printer accurately. Larger errors my require 2 or 3 runs to calibrate out. So I suggest the following procedure:
1. Run auto calibration, then use the M665 and M666 commands with no parameters to see the adjustments made.
2. Repeat (1) until the M665 and M666 results converge.
3. Edit those results into the M665 and M666 commands in config.g.
After this, a single auto calibration run will be sufficient. Note that the X and Y parameters of the M665 command are only supported in firmware version 1.09d-dc42 and later.
Testing the motors individually
You can test the three tower motors individually by putting the printer in relative mode (G91 command) and then using the G1 command with S2 parameter. For example, sending G1 S2 X10 should move the X carriage up 10mm, and sending G1 S2 X-10 should move the X carriage down 10mm. Similarly for Y and Z. If a motor moves the wrong way, you can reverse it by changing the corresponding M569 command in config.g. For example, if the X motor moves the wrong way, change M569 P0 S1 to M569 P0 S0.