Skip to content

Commit

Permalink
Update tower position adjust code
Browse files Browse the repository at this point in the history
update to allow towers to be adjusted independantly
disabled r and dr multiplier
  • Loading branch information
RichCattell committed Feb 12, 2014
1 parent dbc811a commit 86ce8ad
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
#define AUTOCALIBRATION_PRECISION 0.03 // mm

// Diameter of print bed (printable area)
#define BED_DIAMETER 170 // mm
#define BED_DIAMETER 160 // 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 Down
66 changes: 43 additions & 23 deletions Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,12 +888,12 @@ void set_delta_constants()
DELTA_DIAGONAL_ROD_2 = pow(delta_diagonal_rod,2);

// Effective X/Y positions of the three vertical towers.
delta_tower1_x = (-SIN_60 * delta_radius) + tower_adj[0]; // front left tower
delta_tower1_y = (-COS_60 * delta_radius) + tower_adj[1];
delta_tower2_x = -delta_tower1_x; // front right tower
delta_tower2_y = delta_tower1_y;
delta_tower3_x = tower_adj[2] ; // back middle tower
delta_tower3_y = -2 * delta_tower1_y;
delta_tower1_x = (-SIN_60 * delta_radius) + tower_adj[0]; // front left tower + xa
delta_tower1_y = (-COS_60 * delta_radius) - tower_adj[0] ;
delta_tower2_x = -(-SIN_60 * delta_radius) + tower_adj[1]; // front right tower + xb
delta_tower2_y = (-COS_60 * delta_radius) + tower_adj[1]; //
delta_tower3_x = tower_adj[2] ; // back middle tower + xc
delta_tower3_y = -2 * (-COS_60 * delta_radius);
}

void deploy_z_probe() {
Expand Down Expand Up @@ -1441,7 +1441,16 @@ void process_commands()
saved_feedmultiply = feedmultiply;
feedmultiply = 100;

if (code_seen('A')) SERIAL_ECHOLN("Starting Auto Calibration..");
if (code_seen('A'))
{
SERIAL_ECHOLN("Starting Auto Calibration..");
if (code_seen('D'))
{
SERIAL_ECHOPAIR("Using diagional rod length: ", delta_diagonal_rod);
SERIAL_ECHOLN("mm");
SERIAL_ECHOLN("(will not be adjusted)");
}
}

home_delta_axis();
deploy_z_probe();
Expand All @@ -1465,7 +1474,7 @@ void process_commands()
float adj_r_target_delta = 0, adj_dr_target_delta = 0;
float saved_bed_level_c, saved_adj_r_target, saved_adj_dr_target;
float saved_delta_diagonal_rod = delta_diagonal_rod;
float adj_xa =0 , adj_ya = 0, adj_xc = 0;
float adj_xa, adj_ya, adj_xc;
float adj_r = 0, adj_dr = 0;
float adj_r_mul = 1, adj_dr_mul = 1;
boolean adj_r_done, adj_dr_done;
Expand All @@ -1476,8 +1485,6 @@ void process_commands()
//If delta rod length is specified in G30A G-Code command.. fix at this value and do not allow adjustment
delta_diagonal_rod = code_value();
adj_dr_allowed = false;
SERIAL_ECHOPAIR("Using diagional rod length: ", delta_diagonal_rod);
SERIAL_ECHOLN("mm (will not be adjusted)");
}

do {
Expand Down Expand Up @@ -1509,9 +1516,12 @@ void process_commands()

adj_r_target = (bed_level_x + bed_level_y + bed_level_z) / 3;
adj_dr_target = (bed_level_ox + bed_level_oy + bed_level_oz) / 3;
adj_xa = ((bed_level_oy + bed_level_x)/2) - ((bed_level_ox + bed_level_y)/2);
adj_ya = bed_level_oz - ((bed_level_ox + bed_level_oy)/2);
adj_xc = bed_level_oy - bed_level_ox;
//tower A position adjust
adj_xa = bed_level_oz - bed_level_oy;
//tower y position adjust
adj_ya = bed_level_ox - bed_level_oz;
//tower z position adjust
adj_xc = bed_level_ox - bed_level_oy;

//Determine which parameters require adjustment
if ((bed_level_c >= adj_r_target - ac_prec/4) and (bed_level_c <= adj_r_target + ac_prec/4)) adj_r_done = true; else adj_r_done = false;
Expand Down Expand Up @@ -1544,9 +1554,9 @@ void process_commands()
//Apply adjustments
delta_radius += adj_r * adj_r_mul;
if (adj_dr_allowed == true) delta_diagonal_rod += adj_dr * adj_dr_mul;
tower_adj[0] -= adj_xa;
tower_adj[1] -= adj_ya;
tower_adj[2] -= adj_xc;
tower_adj[0] += adj_xa;
tower_adj[1] += adj_ya;
tower_adj[2] += adj_xc;
set_delta_constants();

bed_level_c = probe_bed(0.0,0.0);
Expand All @@ -1559,34 +1569,44 @@ void process_commands()

adj_r_target = (bed_level_x + bed_level_y + bed_level_z) / 3;
adj_dr_target = (bed_level_ox + bed_level_oy + bed_level_oz) / 3;
adj_ya = bed_level_oz - ((bed_level_ox + bed_level_oy)/2);
adj_xc = bed_level_oy - bed_level_ox;

//tower x position adjust
adj_xa = bed_level_oz - bed_level_oy;
//tower y position adjust
adj_ya = bed_level_ox - bed_level_oz;
//tower z position adjust
adj_xc = bed_level_ox - bed_level_oy;

//Modify multipliers based on previous adjustments
if (saved_adj_r_target != 0)
{
adj_r_target_delta = abs(abs(bed_level_c - adj_r_target) - abs(saved_bed_level_c - saved_adj_r_target));
adj_r_mul = abs(adj_r / adj_r_target_delta);
adj_r_mul = 1; //abs(adj_r / adj_r_target_delta);
//SERIAL_ECHOPAIR("adj_r = ", adj_r);
//SERIAL_ECHOPAIR("adj_r_target_delta = ", adj_r_target_delta);
//SERIAL_ECHOPAIR("adj_r_mul = ", adj_r_mul);
}
if (saved_adj_dr_target != 0)
{
adj_dr_target_delta = abs(abs(adj_r_target - adj_dr_target) - abs(saved_adj_r_target - saved_adj_dr_target));
adj_dr_mul = abs(adj_dr / adj_dr_target_delta);
adj_dr_mul = 1; //abs(adj_dr / adj_dr_target_delta);
//SERIAL_ECHOPAIR("adj_dr = ", adj_dr);
//SERIAL_ECHOPAIR("adj_dr_target_delta = ", adj_dr_target_delta);
//SERIAL_ECHOPAIR("adj_dr_mul = ", adj_dr_mul);
}


if (((adj_r > 0) and (bed_level_c > adj_r_target)) or ((adj_r < 0) and (bed_level_c < adj_r_target)))
{
//overshot target .. reverse and scale down adj var
if (abs(adj_r) > 0.0001) adj_r = adj_r /10;
if (abs(adj_r) > 0.0001) adj_r = adj_r / 10;
adj_r = -adj_r;
//adj_r_mul = 1;
}

if (((adj_dr > 0) and (adj_dr_target > adj_r_target)) or ((adj_dr < 0) and (adj_dr_target < adj_r_target)))
{
//overshot target .. reverse and scale down adj var
if (abs(adj_dr) > 0.0001) adj_dr = adj_dr /10;
if (abs(adj_dr) > 0.0001) adj_dr = adj_dr / 10;
adj_dr = -adj_dr;
//adj_dr_mul = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
#define Z_STEP_PIN 46
#define Z_DIR_PIN 48
#define Z_ENABLE_PIN 62
#define Z_MIN_PIN 18 // autolevel probe for deltabot
#define Z_MIN_PIN 14 // autolevel probe for deltabot
#define Z_MAX_PIN 19

#define Z2_STEP_PIN 36
Expand Down

0 comments on commit 86ce8ad

Please sign in to comment.