Ported over Johann Rocholl's improvements for delta printers:

- Nonlinear auto bed leveling code (includes G29, G30, Z_RAISE_AFTER_PROBING). Cleaned it up to be a delta-specific AUTO_BED_LEVELING_GRID code path.
- Allen key z-probe deployment and retraction code. Cleaned it up and added safety checks.
This commit is contained in:
maverikou 2015-03-07 20:36:21 +02:00
parent 9dccd3a94f
commit 7c24b97958
6 changed files with 425 additions and 30 deletions

View File

@ -189,12 +189,18 @@ void ClearToSend();
void get_coordinates();
#ifdef DELTA
void calculate_delta(float cartesian[3]);
#ifdef ENABLE_AUTO_BED_LEVELING
extern int delta_grid_spacing[2];
void adjust_delta(float cartesian[3]);
#endif
extern float delta[3];
void prepare_move_raw();
#endif
#ifdef SCARA
void calculate_delta(float cartesian[3]);
void calculate_SCARA_forward_Transform(float f_scara[3]);
#endif
void reset_bed_level();
void prepare_move();
void kill();
void Stop();

View File

@ -346,6 +346,9 @@ int fanSpeed = 0;
float delta_diagonal_rod = DELTA_DIAGONAL_ROD;
float delta_diagonal_rod_2 = sq(delta_diagonal_rod);
float delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
#ifdef ENABLE_AUTO_BED_LEVELING
float bed_level[AUTO_BED_LEVELING_GRID_POINTS][AUTO_BED_LEVELING_GRID_POINTS];
#endif
#endif
#ifdef SCARA
@ -1058,6 +1061,8 @@ static void axis_is_at_home(int axis) {
#ifdef ENABLE_AUTO_BED_LEVELING
#ifdef AUTO_BED_LEVELING_GRID
#ifndef DELTA
static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
{
vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
@ -1080,6 +1085,7 @@ static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
}
#endif
#else // not AUTO_BED_LEVELING_GRID
@ -1113,6 +1119,27 @@ static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float
#endif // AUTO_BED_LEVELING_GRID
static void run_z_probe() {
#ifdef DELTA
float start_z = current_position[Z_AXIS];
long start_steps = st_get_position(Z_AXIS);
// move down slowly until you find the bed
feedrate = homing_feedrate[Z_AXIS] / 4;
destination[Z_AXIS] = -10;
prepare_move_raw();
st_synchronize();
endstops_hit_on_purpose();
// we have to let the planner know where we are right now as it is not where we said to go.
long stop_steps = st_get_position(Z_AXIS);
float mm = start_z - float(start_steps - stop_steps) / axis_steps_per_unit[Z_AXIS];
current_position[Z_AXIS] = mm;
calculate_delta(current_position);
plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
#else
plan_bed_level_matrix.set_to_identity();
feedrate = homing_feedrate[Z_AXIS];
@ -1139,11 +1166,25 @@ static void run_z_probe() {
current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
// make sure the planner knows where we are as it may be a bit different than we last said to move to
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
#endif
}
static void do_blocking_move_to(float x, float y, float z) {
float oldFeedRate = feedrate;
#ifdef DELTA
feedrate = XY_TRAVEL_SPEED;
destination[X_AXIS] = x;
destination[Y_AXIS] = y;
destination[Z_AXIS] = z;
prepare_move_raw();
st_synchronize();
#else
feedrate = homing_feedrate[Z_AXIS];
current_position[Z_AXIS] = z;
@ -1157,6 +1198,8 @@ static void do_blocking_move_to(float x, float y, float z) {
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder);
st_synchronize();
#endif
feedrate = oldFeedRate;
}
@ -1196,7 +1239,40 @@ static void engage_z_probe() {
servos[servo_endstops[Z_AXIS]].detach();
#endif
}
#elif defined(Z_PROBE_ALLEN_KEY)
feedrate = homing_feedrate[X_AXIS];
// Move to the start position to initiate deployment
destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_X;
destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_Y;
destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_Z;
prepare_move_raw();
// Home X to touch the belt
feedrate = homing_feedrate[X_AXIS]/10;
destination[X_AXIS] = 0;
prepare_move_raw();
// Home Y for safety
feedrate = homing_feedrate[X_AXIS]/2;
destination[Y_AXIS] = 0;
prepare_move_raw();
st_synchronize();
bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
if (z_min_endstop)
{
if (!Stopped)
{
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Z-Probe failed to engage!");
LCD_ALERTMESSAGEPGM("Err: ZPROBE");
}
Stop();
}
#endif
}
static void retract_z_probe() {
@ -1212,7 +1288,49 @@ static void retract_z_probe() {
servos[servo_endstops[Z_AXIS]].detach();
#endif
}
#elif defined(Z_PROBE_ALLEN_KEY)
// Move up for safety
feedrate = homing_feedrate[X_AXIS];
destination[Z_AXIS] = current_position[Z_AXIS] + 20;
prepare_move_raw();
// Move to the start position to initiate retraction
destination[X_AXIS] = Z_PROBE_ALLEN_KEY_RETRACT_X;
destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_RETRACT_Y;
destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_RETRACT_Z;
prepare_move_raw();
// Move the nozzle down to push the probe into retracted position
feedrate = homing_feedrate[Z_AXIS]/10;
destination[Z_AXIS] = current_position[Z_AXIS] - Z_PROBE_ALLEN_KEY_RETRACT_DEPTH;
prepare_move_raw();
// Move up for safety
feedrate = homing_feedrate[Z_AXIS]/2;
destination[Z_AXIS] = current_position[Z_AXIS] + Z_PROBE_ALLEN_KEY_RETRACT_DEPTH * 2;
prepare_move_raw();
// Home XY for safety
feedrate = homing_feedrate[X_AXIS]/2;
destination[X_AXIS] = 0;
destination[Y_AXIS] = 0;
prepare_move_raw();
st_synchronize();
bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
if (!z_min_endstop)
{
if (!Stopped)
{
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Z-Probe failed to retract!");
LCD_ALERTMESSAGEPGM("Err: ZPROBE");
}
Stop();
}
#endif
}
enum ProbeAction { ProbeStay, ProbeEngage, ProbeRetract, ProbeEngageRetract };
@ -1223,14 +1341,14 @@ static float probe_pt(float x, float y, float z_before, ProbeAction retract_acti
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
#ifndef Z_PROBE_SLED
#if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY)
if (retract_action & ProbeEngage) engage_z_probe();
#endif
run_z_probe();
float measured_z = current_position[Z_AXIS];
#ifndef Z_PROBE_SLED
#if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY)
if (retract_action & ProbeRetract) retract_z_probe();
#endif
@ -1247,6 +1365,62 @@ static float probe_pt(float x, float y, float z_before, ProbeAction retract_acti
return measured_z;
}
#ifdef DELTA
static void extrapolate_one_point(int x, int y, int xdir, int ydir) {
if (bed_level[x][y] != 0.0) {
return; // Don't overwrite good values.
}
float a = 2*bed_level[x+xdir][y] - bed_level[x+xdir*2][y]; // Left to right.
float b = 2*bed_level[x][y+ydir] - bed_level[x][y+ydir*2]; // Front to back.
float c = 2*bed_level[x+xdir][y+ydir] - bed_level[x+xdir*2][y+ydir*2]; // Diagonal.
float median = c; // Median is robust (ignores outliers).
if (a < b) {
if (b < c) median = b;
if (c < a) median = a;
} else { // b <= a
if (c < b) median = b;
if (a < c) median = a;
}
bed_level[x][y] = median;
}
// Fill in the unprobed points (corners of circular print surface)
// using linear extrapolation, away from the center.
static void extrapolate_unprobed_bed_level() {
int half = (AUTO_BED_LEVELING_GRID_POINTS-1)/2;
for (int y = 0; y <= half; y++) {
for (int x = 0; x <= half; x++) {
if (x + y < 3) continue;
extrapolate_one_point(half-x, half-y, x>1?+1:0, y>1?+1:0);
extrapolate_one_point(half+x, half-y, x>1?-1:0, y>1?+1:0);
extrapolate_one_point(half-x, half+y, x>1?+1:0, y>1?-1:0);
extrapolate_one_point(half+x, half+y, x>1?-1:0, y>1?-1:0);
}
}
}
// Print calibration results for plotting or manual frame adjustment.
static void print_bed_level() {
for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
SERIAL_PROTOCOL_F(bed_level[x][y], 2);
SERIAL_PROTOCOLPGM(" ");
}
SERIAL_ECHOLN("");
}
}
// Reset calibration results to zero.
void reset_bed_level() {
for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
bed_level[x][y] = 0.0;
}
}
}
#endif // DELTA
#endif // ENABLE_AUTO_BED_LEVELING
static void homeaxis(int axis) {
@ -1523,8 +1697,12 @@ inline void gcode_G4() {
*/
inline void gcode_G28() {
#ifdef ENABLE_AUTO_BED_LEVELING
#ifdef DELTA
reset_bed_level();
#else
plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data)
#endif
#endif
saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply;
@ -1804,6 +1982,7 @@ inline void gcode_G28() {
* Parameters With AUTO_BED_LEVELING_GRID:
*
* P Set the size of the grid that will be probed (P x P points).
* Not supported by non-linear delta printer bed leveling.
* Example: "G29 P4"
*
* V Set the verbose level (0-4). Example: "G29 V3"
@ -1811,6 +1990,7 @@ inline void gcode_G28() {
* T Generate a Bed Topology Report. Example: "G29 P5 T" for a detailed report.
* This is useful for manual bed leveling and finding flaws in the bed (to
* assist with part placement).
* Not supported by non-linear delta printer bed leveling.
*
* F Set the Front limit of the probing grid
* B Set the Back limit of the probing grid
@ -1856,16 +2036,21 @@ inline void gcode_G28() {
#ifdef AUTO_BED_LEVELING_GRID
#ifndef DELTA
bool topo_flag = verbose_level > 2 || code_seen('T') || code_seen('t');
#endif
if (verbose_level > 0)
SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n");
int auto_bed_leveling_grid_points = code_seen('P') ? code_value_long() : AUTO_BED_LEVELING_GRID_POINTS;
int auto_bed_leveling_grid_points = AUTO_BED_LEVELING_GRID_POINTS;
#ifndef DELTA
if (code_seen('P')) auto_bed_leveling_grid_points = code_value_long();
if (auto_bed_leveling_grid_points < 2 || auto_bed_leveling_grid_points > AUTO_BED_LEVELING_GRID_POINTS) {
SERIAL_PROTOCOLPGM("?Number of probed (P)oints is implausible (2 minimum).\n");
return;
}
#endif
int left_probe_bed_position = code_seen('L') ? code_value_long() : LEFT_PROBE_BED_POSITION,
right_probe_bed_position = code_seen('R') ? code_value_long() : RIGHT_PROBE_BED_POSITION,
@ -1905,20 +2090,27 @@ inline void gcode_G28() {
#ifdef Z_PROBE_SLED
dock_sled(false); // engage (un-dock) the probe
#elif not defined(SERVO_ENDSTOPS)
engage_z_probe();
#endif
st_synchronize();
#ifdef DELTA
reset_bed_level();
#else
// make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
//vector_3 corrected_position = plan_get_position_mm();
//corrected_position.debug("position before G29");
plan_bed_level_matrix.set_to_identity();
vector_3 uncorrected_position = plan_get_position();
//uncorrected_position.debug("position durring G29");
//uncorrected_position.debug("position during G29");
current_position[X_AXIS] = uncorrected_position.x;
current_position[Y_AXIS] = uncorrected_position.y;
current_position[Z_AXIS] = uncorrected_position.z;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
#endif
setup_for_endstop_move();
feedrate = homing_feedrate[Z_AXIS];
@ -1926,9 +2118,10 @@ inline void gcode_G28() {
#ifdef AUTO_BED_LEVELING_GRID
// probe at the points of a lattice grid
int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points - 1);
int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points - 1);
const int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1);
const int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1);
#ifndef DELTA
// solve the plane equation ax + by + d = z
// A is the matrix with rows [x y 1] for all the probed points
// B is the vector of the Z positions
@ -1941,26 +2134,60 @@ inline void gcode_G28() {
eqnBVector[abl2], // "B" vector of Z points
mean = 0.0;
#else
delta_grid_spacing[0] = xGridSpacing;
delta_grid_spacing[1] = yGridSpacing;
float z_offset = Z_PROBE_OFFSET_FROM_EXTRUDER;
if (code_seen(axis_codes[Z_AXIS])) {
z_offset += code_value();
}
#endif
int probePointCounter = 0;
bool zig = true;
for (int yProbe = front_probe_bed_position; yProbe <= back_probe_bed_position; yProbe += yGridSpacing) {
int xProbe, xInc;
for (int yCount=0; yCount < auto_bed_leveling_grid_points; yCount++)
{
double yProbe = front_probe_bed_position + yGridSpacing * yCount;
int xStart, xStop, xInc;
if (zig)
xProbe = left_probe_bed_position, xInc = xGridSpacing;
{
xStart = 0;
xStop = auto_bed_leveling_grid_points;
xInc = 1;
zig = false;
}
else
xProbe = right_probe_bed_position, xInc = -xGridSpacing;
{
xStart = auto_bed_leveling_grid_points - 1;
xStop = -1;
xInc = -1;
zig = true;
}
#ifndef DELTA
// If topo_flag is set then don't zig-zag. Just scan in one direction.
// This gets the probe points in more readable order.
if (!topo_flag) zig = !zig;
#endif
for (int xCount=xStart; xCount != xStop; xCount += xInc)
{
double xProbe = left_probe_bed_position + xGridSpacing * xCount;
for (int xCount = 0; xCount < auto_bed_leveling_grid_points; xCount++) {
// raise extruder
float measured_z,
z_before = probePointCounter == 0 ? Z_RAISE_BEFORE_PROBING : current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS;
#ifdef DELTA
// Avoid probing the corners (outside the round or hexagon print surface) on a delta printer.
float distance_from_center = sqrt(xProbe*xProbe + yProbe*yProbe);
if (distance_from_center > DELTA_PROBABLE_RADIUS)
continue;
#endif //DELTA
// Enhanced G29 - Do not retract servo between probes
ProbeAction act;
if (enhanced_g29) {
@ -1976,22 +2203,24 @@ inline void gcode_G28() {
measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
#ifndef DELTA
mean += measured_z;
eqnBVector[probePointCounter] = measured_z;
eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
eqnAMatrix[probePointCounter + 2 * abl2] = 1;
#else
bed_level[xCount][yCount] = measured_z + z_offset;
#endif
probePointCounter++;
xProbe += xInc;
} //xProbe
} //yProbe
clean_up_after_endstop_move();
#ifndef DELTA
// solve lsq problem
double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector);
@ -2053,6 +2282,10 @@ inline void gcode_G28() {
set_bed_level_equation_lsq(plane_equation_coefficients);
free(plane_equation_coefficients);
#else
extrapolate_unprobed_bed_level();
print_bed_level();
#endif
#else // !AUTO_BED_LEVELING_GRID
@ -2075,11 +2308,13 @@ inline void gcode_G28() {
#endif // !AUTO_BED_LEVELING_GRID
do_blocking_move_to(MANUAL_X_HOME_POS, MANUAL_Y_HOME_POS, Z_RAISE_AFTER_PROBING);
st_synchronize();
if (verbose_level > 0)
plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
#ifndef DELTA
// Correct the Z height difference from z-probe position and hotend tip position.
// The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
// When the bed is uneven, this height must be corrected.
@ -2091,9 +2326,12 @@ inline void gcode_G28() {
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner.
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
#endif
#ifdef Z_PROBE_SLED
dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
#elif not defined(SERVO_ENDSTOPS)
retract_z_probe();
#endif
}
@ -4920,7 +5158,64 @@ void calculate_delta(float cartesian[3])
SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]);
*/
}
#endif
#ifdef ENABLE_AUTO_BED_LEVELING
// Adjust print surface height by linear interpolation over the bed_level array.
int delta_grid_spacing[2] = { 0, 0 };
void adjust_delta(float cartesian[3])
{
if (delta_grid_spacing[0] == 0 || delta_grid_spacing[1] == 0)
return; // G29 not done
int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
float grid_x = max(0.001-half, min(half-0.001, cartesian[X_AXIS] / delta_grid_spacing[0]));
float grid_y = max(0.001-half, min(half-0.001, cartesian[Y_AXIS] / delta_grid_spacing[1]));
int floor_x = floor(grid_x);
int floor_y = floor(grid_y);
float ratio_x = grid_x - floor_x;
float ratio_y = grid_y - floor_y;
float z1 = bed_level[floor_x+half][floor_y+half];
float z2 = bed_level[floor_x+half][floor_y+half+1];
float z3 = bed_level[floor_x+half+1][floor_y+half];
float z4 = bed_level[floor_x+half+1][floor_y+half+1];
float left = (1-ratio_y)*z1 + ratio_y*z2;
float right = (1-ratio_y)*z3 + ratio_y*z4;
float offset = (1-ratio_x)*left + ratio_x*right;
delta[X_AXIS] += offset;
delta[Y_AXIS] += offset;
delta[Z_AXIS] += offset;
/*
SERIAL_ECHOPGM("grid_x="); SERIAL_ECHO(grid_x);
SERIAL_ECHOPGM(" grid_y="); SERIAL_ECHO(grid_y);
SERIAL_ECHOPGM(" floor_x="); SERIAL_ECHO(floor_x);
SERIAL_ECHOPGM(" floor_y="); SERIAL_ECHO(floor_y);
SERIAL_ECHOPGM(" ratio_x="); SERIAL_ECHO(ratio_x);
SERIAL_ECHOPGM(" ratio_y="); SERIAL_ECHO(ratio_y);
SERIAL_ECHOPGM(" z1="); SERIAL_ECHO(z1);
SERIAL_ECHOPGM(" z2="); SERIAL_ECHO(z2);
SERIAL_ECHOPGM(" z3="); SERIAL_ECHO(z3);
SERIAL_ECHOPGM(" z4="); SERIAL_ECHO(z4);
SERIAL_ECHOPGM(" left="); SERIAL_ECHO(left);
SERIAL_ECHOPGM(" right="); SERIAL_ECHO(right);
SERIAL_ECHOPGM(" offset="); SERIAL_ECHOLN(offset);
*/
}
#endif //ENABLE_AUTO_BED_LEVELING
void prepare_move_raw()
{
previous_millis_cmd = millis();
calculate_delta(destination);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],
destination[E_AXIS], feedrate*feedmultiply/60/100.0,
active_extruder);
for(int8_t i=0; i < NUM_AXIS; i++) {
current_position[i] = destination[i];
}
}
#endif //DELTA
void prepare_move()
{

View File

@ -110,6 +110,9 @@ Here are some standard links for getting your machine calibrated:
// Effective horizontal distance bridged by diagonal push rods.
#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET)
// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
#define DELTA_PRINTABLE_RADIUS 90
//===========================================================================
//============================= Thermal Settings ============================
@ -361,8 +364,7 @@ const bool X_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
const bool Y_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
//#define DISABLE_MAX_ENDSTOPS
// Deltas never have min endstops
#define DISABLE_MIN_ENDSTOPS
#define DISABLE_MIN_ENDSTOPS // Deltas only use min endstops for probing
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
#define X_ENABLE_ON 0
@ -413,8 +415,80 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
//============================= Bed Auto Leveling ===========================
//===========================================================================
//Bed Auto Leveling is still not compatible with Delta Kinematics
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line)
// Z-Probe Repeatability test is not supported in Deltas yet.
#ifdef ENABLE_AUTO_BED_LEVELING
// Deltas only support grid mode
#define AUTO_BED_LEVELING_GRID
#define DELTA_PROBABLE_RADIUS (DELTA_PRINTABLE_RADIUS - 10)
#define LEFT_PROBE_BED_POSITION -DELTA_PROBABLE_RADIUS
#define RIGHT_PROBE_BED_POSITION DELTA_PROBABLE_RADIUS
#define BACK_PROBE_BED_POSITION DELTA_PROBABLE_RADIUS
#define FRONT_PROBE_BED_POSITION -DELTA_PROBABLE_RADIUS
// Non-linear bed leveling will be used.
// Compensate by interpolating between the nearest four Z probe values for each point.
// Useful for deltas where the print surface may appear like a bowl or dome shape.
// Works best with ACCURATE_BED_LEVELING_POINTS 5 or higher.
#define AUTO_BED_LEVELING_GRID_POINTS 9
// Offsets to the probe relative to the extruder tip (Hotend - Probe)
// X and Y offsets must be integers
#define X_PROBE_OFFSET_FROM_EXTRUDER 0 // -left +right
#define Y_PROBE_OFFSET_FROM_EXTRUDER -10 // -front +behind
#define Z_PROBE_OFFSET_FROM_EXTRUDER -3.5 // -below (always!)
#define Z_RAISE_BEFORE_HOMING 4 // (in mm) Raise Z before homing (G28) for Probe Clearance.
// Be sure you have this distance over your Z_MAX_POS in case
#define XY_TRAVEL_SPEED 4000 // X and Y axis travel speed between probes, in mm/min
#define Z_RAISE_BEFORE_PROBING 15 //How much the extruder will be raised before traveling to the first probing point.
#define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when traveling from between next probing points
#define Z_RAISE_AFTER_PROBING 50 //How much the extruder will be raised after the last probing point.
// Allen key retractable z-probe as seen on many Kossel delta printers - http://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe
// Deploys by touching z-axis belt. Retracts by pushing the probe down. Uses Z_MIN_PIN.
//#define Z_PROBE_ALLEN_KEY
#ifdef Z_PROBE_ALLEN_KEY
#define Z_PROBE_ALLEN_KEY_DEPLOY_X 30
#define Z_PROBE_ALLEN_KEY_DEPLOY_Y DELTA_PRINTABLE_RADIUS
#define Z_PROBE_ALLEN_KEY_DEPLOY_Z 100
#define Z_PROBE_ALLEN_KEY_RETRACT_X -64
#define Z_PROBE_ALLEN_KEY_RETRACT_Y 56
#define Z_PROBE_ALLEN_KEY_RETRACT_Z 23
#define Z_PROBE_ALLEN_KEY_RETRACT_DEPTH 20
#endif
//If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk
//The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.
// You MUST HAVE the SERVO_ENDSTOPS defined to use here a value higher than zero otherwise your code will not compile.
// #define PROBE_SERVO_DEACTIVATION_DELAY 300
//If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!!!
#define Z_SAFE_HOMING // This feature is meant to avoid Z homing with probe outside the bed area.
// When defined, it will:
// - Allow Z homing only after X and Y homing AND stepper drivers still enabled
// - If stepper drivers timeout, it will need X and Y homing again before Z homing
// - Position the probe in a defined XY point before Z Homing when homing all axis (G28)
// - Block Z homing only when the probe is outside bed area.
#ifdef Z_SAFE_HOMING
#define Z_SAFE_HOMING_X_POINT (X_MAX_LENGTH/2) // X point for Z homing when homing all axis (G28)
#define Z_SAFE_HOMING_Y_POINT (Y_MAX_LENGTH/2) // Y point for Z homing when homing all axis (G28)
#endif
#endif // ENABLE_AUTO_BED_LEVELING

View File

@ -455,7 +455,25 @@ const unsigned int dropsegments=5; //everything with less than this number of st
//===========================================================================
#if defined (ENABLE_AUTO_BED_LEVELING) && defined (DELTA)
#error "Bed Auto Leveling is still not compatible with Delta Kinematics."
#if not defined(AUTO_BED_LEVELING_GRID)
#error "Only Grid Bed Auto Leveling is supported on Deltas."
#endif
#if defined(Z_PROBE_SLED)
#error "You cannot use Z_PROBE_SLED together with DELTA."
#endif
#if defined(Z_PROBE_REPEATABILITY_TEST)
#error "Z-probe repeatability test is not supported on Deltas yet."
#endif
#endif
#if defined(Z_PROBE_ALLEN_KEY)
#if !defined(AUTO_BED_LEVELING_GRID) || !defined(DELTA)
#error "Invalid use of Z_PROBE_ALLEN_KEY."
#endif
#endif
#if EXTRUDERS > 1 && defined TEMP_SENSOR_1_AS_REDUNDANT

View File

@ -1057,7 +1057,7 @@ Having the real displacement of the head, we can calculate the total movement le
st_wake_up();
}
#ifdef ENABLE_AUTO_BED_LEVELING
#if defined(ENABLE_AUTO_BED_LEVELING) && not defined(DELTA)
vector_3 plan_get_position() {
vector_3 position = vector_3(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS));

View File

@ -85,8 +85,10 @@ void plan_init();
#ifdef ENABLE_AUTO_BED_LEVELING
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder);
// Get the position applying the bed level matrix if enabled
vector_3 plan_get_position();
#ifndef DELTA
// Get the position applying the bed level matrix if enabled
vector_3 plan_get_position();
#endif
#else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder);
#endif // ENABLE_AUTO_BED_LEVELING