Skip to content

Commit

Permalink
Final autocalibration updates for release version
Browse files Browse the repository at this point in the history
  • Loading branch information
RichCattell committed Mar 4, 2014
1 parent 7db2a0f commit 1c59870
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 114 deletions.
8 changes: 6 additions & 2 deletions Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@
// Effective horizontal distance bridged by diagonal push rods.
#define DEFAULT_DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET)

//Uncomment to enable autocalibration debug messages
//#define DEBUG_MESSAGES

// Precision for G30 delta autocalibration function
#define AUTOCALIBRATION_PRECISION 0.03 // mm

// Diameter of print bed (printable area)
#define BED_DIAMETER 160 // mm
// Diameter of print bed - this is used to set the distance that autocalibration probes the bed at.
#define BED_DIAMETER 170 // mm

// Z-Probe variables
// Start and end location values are used to deploy/retract the probe (will move from start to end and back again)
Expand All @@ -112,6 +115,7 @@
#define Z_PROBE_RETRACT_END_LOCATION {49, 84, 1, 0} // X, Y, Z, E end location for z-probe retract sequence

#define AUTOLEVEL_GRID 24 // Distance between autolevel Z probing points, should be less than print surface radius/3.

//===========================================================================
//=============================Thermal Settings ============================
//===========================================================================
Expand Down
95 changes: 41 additions & 54 deletions Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,39 +993,45 @@ float z_probe() {

void calibrate_print_surface(float z_offset)
{
//Zero the array
for (int y = 0; y < 7; y++)
{
for (int x = 0; x < 7; x++)
{
bed_level[x][y] = 0.0;
}
}

float probe_bed_z, probe_z, probe_h, probe_l;
int probe_count;

for (int y = 3; y >= -3; y--) {
int dir = y % 2 ? -1 : 1;
for (int x = -3*dir; x != 4*dir; x += dir) {
if (x*x + y*y < 11) {
destination[X_AXIS] = AUTOLEVEL_GRID * x - z_probe_offset[X_AXIS];
destination[Y_AXIS] = AUTOLEVEL_GRID * y - z_probe_offset[Y_AXIS];
//prepare_move();
bed_level[x+3][y+3] = z_probe() + z_offset;

probe_count = 0;
probe_z = -100;
probe_h = -100;
probe_l = 100;
do {
probe_bed_z = probe_z;
probe_z = z_probe() + z_offset;
if (probe_z > probe_h) probe_h = probe_z;
if (probe_z < probe_l) probe_l = probe_z;
probe_count ++;
} while ((probe_z != probe_bed_z) and (probe_count < 21));

bed_level[x+3][3-y] = probe_bed_z;
} else {
bed_level[x+3][y+3] = 0.0;
bed_level[x+3][3-y] = 0.0;
}
}
// For unprobed positions just copy nearest neighbor.
if (abs(y) >= 3) {
bed_level[1][y+3] = bed_level[2][y+3];
bed_level[5][y+3] = bed_level[4][y+3];
bed_level[1][3-y] = bed_level[2][3-y];
bed_level[5][3-y] = bed_level[4][3-y];
}
if (abs(y) >=2) {
bed_level[0][y+3] = bed_level[1][y+3];
bed_level[6][y+3] = bed_level[5][y+3];
bed_level[0][3-y] = bed_level[1][3-y];
bed_level[6][3-y] = bed_level[5][3-y];
}
// Print calibration results for manual frame adjustment.
for (int x = -3; x <= 3; x++) {
SERIAL_PROTOCOL_F(bed_level[x+3][y+3], 3);
SERIAL_PROTOCOL_F(bed_level[x+3][3-y], 3);
SERIAL_PROTOCOLPGM(" ");
}
SERIAL_ECHOLN("");
Expand Down Expand Up @@ -1631,31 +1637,6 @@ void process_commands()
feedmultiply = saved_feedmultiply;
break;
}

/*
//Probe all bed locations and check probe accuracy
probe_error = z_probe_accuracy();
SERIAL_ECHO("Z-Probe error: ");
SERIAL_PROTOCOL_F(probe_error, 3);
SERIAL_ECHO(" mm ");
if (probe_error < 0.03)
{
SERIAL_ECHOLN("(OK)");
}
else
{
SERIAL_ECHOLN("(FAILED)");
SERIAL_ECHOLN("Z-Probe is not accurate enough to perform auto-calibration");
retract_z_probe();
//Restore saved variables
feedrate = saved_feedrate;
feedmultiply = saved_feedmultiply;
break;
}
*/

if (code_seen('D'))
{
Expand Down Expand Up @@ -1748,7 +1729,9 @@ void process_commands()
delta_radius += adj_r;
}

if ((adj_dr_allowed == true) and (adj_dr_done == false)) // and (adj_r_done == true))
if (adj_dr_allowed == false) adj_dr_done = true;

if (adj_dr_done == false)
{
SERIAL_ECHOPAIR("Adjusting Diag Rod Length (",delta_diagonal_rod);
SERIAL_ECHOPAIR(" -> ", delta_diagonal_rod + adj_dr);
Expand Down Expand Up @@ -1804,7 +1787,8 @@ void process_commands()
if ((radiusErrorA >= (radiusErrorB - 0.02)) and (radiusErrorA <= (radiusErrorB + 0.02))) equalAB = true; else equalAB = false;
if ((radiusErrorB >= (radiusErrorC - 0.02)) and (radiusErrorB <= (radiusErrorC + 0.02))) equalBC = true; else equalBC = false;
if ((radiusErrorC >= (radiusErrorA - 0.02)) and (radiusErrorC <= (radiusErrorA + 0.02))) equalCA = true; else equalCA = false;


#ifdef DEBUG_MESSAGES
if (equalAB == true)
{
SERIAL_ECHOPAIR("Tower AB Equal (A=",radiusErrorA);
Expand All @@ -1825,13 +1809,14 @@ void process_commands()
SERIAL_ECHOPAIR(" A=",radiusErrorA);
SERIAL_ECHOLN(")");
} else SERIAL_ECHOLN("equalCA=false");


#endif

if ((equalAB == true) and (equalBC == true) and (equalCA == true))
{
// all tower radius out by the same amount (within 0.02) - allow adjustment with delta rod length
#ifdef DEBUG_MESSAGES
SERIAL_ECHOLN("All tower radius errors equal");
#endif
adj_RadiusA = adj_RadiusB = adj_RadiusC = 0;
}

Expand All @@ -1843,8 +1828,10 @@ void process_commands()
{
if (bed_level_z < bed_level_oz) adj_RadiusC = 0.5;
if (bed_level_z > bed_level_oz) adj_RadiusC = -0.5;
#ifdef DEBUG_MESSAGES
SERIAL_ECHOPAIR("adj_RadiusC set to ",adj_RadiusC);
SERIAL_ECHOLN("");
#endif
}
}
if ((equalBC == true) and (equalAB == false) and (equalCA == false))
Expand All @@ -1854,9 +1841,11 @@ void process_commands()
if (adj_RadiusA == 0)
{
if (bed_level_x < bed_level_ox) adj_RadiusA = 0.5;
if (bed_level_x > bed_level_ox) adj_RadiusA = -0.5;
if (bed_level_x > bed_level_ox) adj_RadiusA = -0.5;
#ifdef DEBUG_MESSAGES
SERIAL_ECHOPAIR("adj_RadiusA set to ",adj_RadiusA);
SERIAL_ECHOLN("");
#endif
}
}
if ((equalCA == true) and (equalAB == false) and (equalBC == false))
Expand All @@ -1867,8 +1856,10 @@ void process_commands()
{
if (bed_level_y < bed_level_oy) adj_RadiusB = 0.5;
if (bed_level_y > bed_level_oy) adj_RadiusB = -0.5;
#ifdef DEBUG_MESSAGES
SERIAL_ECHOPAIR("adj_RadiusB set to ",adj_RadiusB);
SERIAL_ECHOLN("");
#endif
}
}

Expand All @@ -1884,12 +1875,6 @@ void process_commands()
//overshot target .. reverse & scale down
adj_dr = -(adj_dr / 2);
}
/*
//Tower radus adjustment complete
if (bed_level_x == bed_level_ox) adj_RadiusA = 0;
if (bed_level_y == bed_level_oy) adj_RadiusB = 0;
if (bed_level_z == bed_level_oz) adj_RadiusC = 0;
*/

//Tower radius overshot targets?
if (((adj_RadiusA > 0) and (bed_level_x > bed_level_ox)) or ((adj_RadiusA < 0) and (bed_level_x < bed_level_ox))) adj_RadiusA = -(adj_RadiusA / 2);
Expand All @@ -1902,6 +1887,7 @@ void process_commands()
//Diag Rod adjustment complete?
if ((adj_dr_target >= (adj_r_target - ac_prec)) and (adj_dr_target <= (adj_r_target + ac_prec))) adj_dr_done = true; else adj_dr_done = false;

#ifdef DEBUG_MESSAGES
SERIAL_ECHOPAIR("c: ", bed_level_c);
SERIAL_ECHOPAIR(" x: ", bed_level_x);
SERIAL_ECHOPAIR(" y: ", bed_level_y);
Expand Down Expand Up @@ -1935,7 +1921,8 @@ void process_commands()
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("DeltaAlphaC: ",adj_AlphaC);
SERIAL_ECHOLN("");

#endif

} while(((adj_r_done == false) or (adj_dr_done = false)) and (loopcount < iterations));

}
Expand Down
122 changes: 68 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,72 @@ Marlin

Marlin Firmware with Delta autocalibration and various other updates/fixes


includes the following updates:


- Add/Update M666 Command to support the following parameters:

L - List all current parameters.
X/Y/Z - Endstop offset adjustment (unchanged from previous implementation).
A/B/C - Delta tower position adjustment. These values equate to xa/ya/xc parameters from Peter
Hercek's Maxima calibration worksheet (deltabot google group).
R - Delta radius (in mm).
D - Diagonal rod length (in mm).
H - Max Z-Height (in mm).
P - Set Z-Probe Z Offset.

All of these parameters can now be saved/loaded to EEPROM using M500 / M501 commands.
M502 will load default values for these parameters from configuration.h

- Add G30 Bed Report / Autocalibration command, supports the following syntax:

G30 - Home all carrages the probe bed at 7 points and produce calibration report:

Z-Tower Endstop Offsets
-2.0125 X: 0.00 Y: 0.00 Z: 0.00
-2.3250 -2.3750 Tower Position Adjust:
-2.0625 A: 0.00 B: 0.00 C: 0.00
-2.3000 -2.4375 Delta Radius: 108.85
-2.8000 Diagonal Rod: 217.50
X-Tower Y-Tower Build Height: 280.00

This can be used to perform manual calibration by changing parameters with M666 command and
then re-doing G30 to see the result.

G30 A - Perform delta autocalibration - will produce a G30 report for each stage of the calibration.
G30 X Y - Probe bed at specified X,Y point and report bed height and carrage positions
G30 C - Show carriage positions for last G30 report
This version has a much improved auto-calibration function which will hopefully be able to cope with many more printer configuration errors than previous versions were capable of resolving.
The auto-calibration can now automatically adjust the following printer configuration variables:

· Delta Radius
· Diagonal Rod Length
· Software Endstop Offsets
· Z-Height Correction
· Tower Position Error Correction (independent Radius and Radial position adjustment for each tower)
All of these values can also be changed manually if desired using the M666 command .

The following G-Code commands are have been added to the standard marlin firmware:
G30 This command is used to perform reporting and auto-calibration of a delta printer and has several options, as follows:
G30 Probe bed and produce a report of the current state of the printer, e.g.:
Z-Tower Endstop Offsets
-0.0125 X:-3.05 Y:-1.83 Z:-2.69
-0.0000 -0.0000 Tower Position Adjust
-0.0625 A:-0.04 B:0.05 C:-0.01
-0.0375 -0.0250 I:0.25 J:-1.25 K:-0.37
-0.0250 Delta Radius: 109.5965
X-Tower Y-Tower Diag Rod: 224.5935
This option does not change any settings, but is useful when manually calibrating a printer, using the M666 command to change values.
G30 Xnn Ynn Probe bed at specified X,Y point and show z-height and delta carriage positions, e.g.:
Bed Z-Height at X:30.00 Y:30.00 = 0.0000
Carriage Positions: [176.40, 207.77, 209.52]
G30 A Start auto-calibration. This will attempt to calibrate the printer, adjusting all
parameters automatically, and will repeat the bed probing sequence show above
several times adjusting each time until calibration is complete.
It is recommended that you use M502 to load default values and then M500 to save
them prior to starting the auto-calibration.

To save the settings after the auto-calibration is complete, use the M500 command.
M666 L List all current configuration values , e.g.:
Current Delta geometry values:
X (Endstop Adj): -3.05
Y (Endstop Adj): -1.83
Z (Endstop Adj): -2.69
P (Z-Probe Offset): X0.00 Y10.00 Z-5.60
A (Tower A Position Correction): -0.04
B (Tower B Position Correction): 0.05
C (Tower C Position Correction): -0.02
I (Tower A Radius Correction): 0.25
J (Tower B Radius Correction): -1.25
K (Tower C Radius Correction): -0.37
R (Delta Radius): 109.60
D (Diagonal Rod Length): 224.59
H (Z-Height): 255.73
All of these values can also be adjusted using the M666 command, e.g. to set the delta radius to 200mm, use:
M666 R200
Or to change the Z-Height to 350.5 mm:
M666 H350.5
Commands can also be combined, e.g. to set endstop values:
M666 X-2.04 Y-1.02 Z-1.52
All of these values can be saved/loaded to/from EEPROM using standard M500/M501 G-Code commands (to save the settings at any time just type M500). This makes manual configuration of a printer much easier as there is no longer a requirement to edit the configuration.h file and re-upload firmware for each time a change needs to be made.

Configuration.h now includes the following additional parameters:
Set start and end locations used to deploy the Z-Probe:

#define Z_PROBE_DEPLOY_START_LOCATION {20, 96, 30, 0}
#define Z_PROBE_DEPLOY_END_LOCATION {5, 96, 30, 0}
#define Z_PROBE_RETRACT_START_LOCATION {49, 84, 20, 0}
#define Z_PROBE_RETRACT_END_LOCATION {49, 84, 1, 0}
Set precision for autocalibration G30 function – calibration will complete when this value is reached – all probed point have to be at 0 +/- 0.015mm (for 0.03 setting below)

#define AUTOCALIBRATION_PRECISION 0.03 // mm

Set distance to probe bed at for G30 function

#define BED_DIAMETER 170 // mm

- Add Z-Probe deploy / retract location variables to configuration.h:

#define Z_PROBE_DEPLOY_START_LOCATION {20, 96, 30, 0}
#define Z_PROBE_DEPLOY_END_LOCATION {5, 96, 30, 0}
#define Z_PROBE_RETRACT_START_LOCATION {49, 84, 20, 0}
#define Z_PROBE_RETRACT_END_LOCATION {49, 84, 1, 0}

- Changes to configuration.h to support autocalibration function. Added variables:

#define AUTOCALIBRATION_PRECISION 0.03 // mm
#define BED_DIAMETER 170 // mm - used to calculate raidus to probe bed at for G30


- Prevent moves to invalid delta coordinates
This fix prevents delta carrages from crashing into motor mounts when attempting to move to an
invalid location that is outside of the delta printable area. Will display an error to console if
this is attempted.
11 changes: 7 additions & 4 deletions example_configurations/delta/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,25 @@
// Effective horizontal distance bridged by diagonal push rods.
#define DEFAULT_DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET)

//Uncomment to enable autocalibration debug messages
//#define DEBUG_MESSAGES

// Precision for G30 delta autocalibration function
#define AUTOCALIBRATION_PRECISION 0.03 // mm

// Diameter of print bed (printable area)
// Diameter of print bed - this is used to set the distance that autocalibration probes the bed at.
#define BED_DIAMETER 170 // mm

// Z-Probe variables
// Start and end location values are used to deploy/retract the probe (will move from start to end and back again)
#define Z_PROBE_OFFSET {0, 10, -5.5, 0} // X, Y, Z, E distance between hotend nozzle and deployed bed leveling probe.
#define Z_PROBE_OFFSET {0, 10, -5.6, 0} // X, Y, Z, E distance between hotend nozzle and deployed bed leveling probe.
#define Z_PROBE_DEPLOY_START_LOCATION {20, 96, 30, 0} // X, Y, Z, E start location for z-probe deployment sequence
#define Z_PROBE_DEPLOY_END_LOCATION {5, 96, 30, 0} // X, Y, Z, E end location for z-probe deployment sequence
#define Z_PROBE_RETRACT_START_LOCATION {49, 84, 20, 0} // X, Y, Z, E start location for z-probe retract sequence
#define Z_PROBE_RETRACT_END_LOCATION {49, 84, 1, 0} // X, Y, Z, E end location for z-probe retract sequence

#define AUTOLEVEL_GRID 24 // Distance between autolevel Z probing points, should be less than print surface radius/3.

//===========================================================================
//=============================Thermal Settings ============================
//===========================================================================
Expand Down Expand Up @@ -346,8 +351,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define MANUAL_Y_HOME_POS 0
#define MANUAL_Z_HOME_POS 258 // For delta: Distance between nozzle and print surface after homing.

#define AUTOLEVEL_GRID 25 // Distance between autolevel Z probing points, should be less than print surface radius/3.

//// MOVEMENT SETTINGS
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
#define HOMING_FEEDRATE {200*60, 200*60, 200*60, 0} // set the homing speeds (mm/min)
Expand Down

0 comments on commit 1c59870

Please sign in to comment.