These are some tools to compute calibration adjustments for a delta-style 3D printer using the Marlin firmware.

Adjustments are computed only for the DELTA_RADIUS firmware setting, and the endstop offsets, as are set by the M666 command. It is assumed that all towers are equally spaced around the center, and that the length of the delta rods was carefully measured, and set properly in the DELTA_DIAGONAL_ROD macro of Configuration.h.

Most people will want to use the auto bed-leveling probe function to take levels of the bed height. If you use pronterface to command the auto-level probe, it will print information like this back to the console:

   ...
   Bed x: 40.00 y: -60.00 z: 5.24
   Bed x: 20.00 y: -60.00 z: 5.07
   ...
   Bed x: -20.00 y: 60.00 z: 5.33
   Bed x: -40.00 y: 60.00 z: 5.25
   -0.51 0.07 -0.00 -0.10 -0.13 0.04 0.21
   ...
In a terminal window, run the follwing command:
   perl extractProbeData.pl > myBed.dat
It will wait for input.
Copy all of the Bed... lines from pronterface, and paste them into the window running the extractProbeData.pl script, then press <CR>ctrl-D, and the script should terminate.

When complete, the script should have produced a myBed.dat file that has contents like:

     40.00 -60.00 4.53
     20.00 -60.00 4.48
     0.00 -60.00 4.63
     -20.00 -60.00 4.84
     -40.00 -60.00 5.05
     -60.00 -40.00 5.08
     -40.00 -40.00 4.69
     -20.00 -40.00 4.63
     0.00 -40.00 4.59
     20.00 -40.00 4.53
     40.00 -40.00 4.52
     60.00 -40.00 4.48
     60.00 -20.00 4.43
     40.00 -20.00 4.46
     20.00 -20.00 4.63
     0.00 -20.00 4.84
     -20.00 -20.00 5.06
     -40.00 -20.00 5.20
     -60.00 -20.00 5.45
     -60.00 0.00 5.14
     -40.00 0.00 4.98
     -20.00 0.00 4.92
     0.00 0.00 4.87
     20.00 0.00 4.81
     40.00 0.00 4.74
     60.00 0.00 4.69
     60.00 20.00 4.63
     40.00 20.00 4.58
     20.00 20.00 4.76
     0.00 20.00 4.97
     -20.00 20.00 5.19
     -40.00 20.00 5.36
     -60.00 20.00 5.51
     -60.00 40.00 5.25
     -40.00 40.00 5.19
     -20.00 40.00 5.13
     0.00 40.00 5.05
     20.00 40.00 4.98
     40.00 40.00 4.87
     60.00 40.00 4.78
     40.00 60.00 4.66
     20.00 60.00 4.83
     0.00 60.00 4.99
     -20.00 60.00 5.28
     -40.00 60.00 5.44

If you do not have a bed leveling probe, you can manually check the nozzle height over the bed, and note the position with the M114 command. I have a similar script to create a data file like the one above from M114 output called extractM114.pl. I have used this by sliding a microscope slide under the nozzle to find how low I can go before I touch the slide.

Data Analysis in Octave (or MATLAB)

In a folder containing this code, and the myBed.dat file start up an octave session.

   octave
Load the data with a command like:
   bed = load('myBed.dat');
You may wish to remove the Z axis bias. I measured this by hand on my printer using the microscope slide technique, and placed the setting in the Z_PROBE_OFFSET_FROM_EXTRUDER macro. In my case, this distance is 5.2mm, so I correct my bed probe data with a command like:
   bed(:,3) = bed(:,3) - 5.2;
If I were correcting manually taken data, with the microscope slide, the number would be 1.17;

I do not know weather or not I should adjust the X and Y ordinates according to their probe offsets. I still need to check the code and see if this is necessary.
It seems that the Z-offset is critical, to sub-100micron, in order to get the first layer spacing correct, and get prints to stick properly. The XY errors are less sensitive.

There are two parameters needed besides the bed probe data to guess at calibration errors. They are the length of the diagonal rods, pivot-center to pivot-center, and the DELTA_RADIUS setting. Place these values in a structure with commands like:

  DP.RodLen=217.5;
  DP.RADIUS=108.2;
Where the RodLen field is the value of your DELTA_DIAGONAL_ROD setting, and the RADIUS field is the value of your DELTA_RADIUS macro setting from Configuration.h.

The calibration error estimate takes some time, and you will not be able to see the progress messages unless you disable the Octave output pager:

   more off

Now you are ready to guess the calibration errors for the DELTA_RADIUS setting, and the endstop offsets:

   [deltaErr,towerErr]=guessDeltaErr(DP,bed)
This will produce a plot of the bed probe values, with a quadratic fit surface, a plot of the best-fit distorted surface that fits your bed probes, with a quadratic fit to these points, and finally a simple plot showing all of your measurements, along with the distorted bed best-fit to those measurements.

To update your calibration, subtract the towerErr value from your endstop offsets (M666 setting), and subtract the deltaErr value from your DELTA_RADIUS setting.

I prefer to get the surface fairly flat before I really trust the deltaErr value and apply it.
As your calibration gets better, I often update by only 1/2 of the towerErr and deltaErr numbers to avoid overshooting the best possible answer, at the cost of a few more calibration iterations.