Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

G33 minor change #6621

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 56 additions & 50 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5053,20 +5053,16 @@ void home_all_axes() { gcode_G28(); }
*
* Parameters:
*
* P Number of probe points:
* Pn Number of probe points:
*
* P1 Probe center and set height only.
* P2 Probe center and towers. Set height, endstops, and delta radius.
* P3 Probe all positions: center, towers and opposite towers. Set all.
* P4-P7 Probe all positions at different locations and average them.
*
* A Abort delta height calibration after 1 probe (only P1)
*
* O Use opposite tower points instead of tower points (only P2)
*
* T Don't calibrate tower angle corrections (P3-P7)
*
* V Verbose level:
* T0 Don't calibrate tower angle corrections
*
* Vn Verbose level:
*
* V0 Dry-run mode. Report settings and probe results. No calibration.
* V1 Report settings
Expand All @@ -5082,7 +5078,7 @@ void home_all_axes() { gcode_G28(); }

const int8_t verbose_level = code_seen('V') ? code_value_byte() : 1;
if (!WITHIN(verbose_level, 0, 2)) {
SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-2).");
SERIAL_PROTOCOLLNPGM("?(V)erbose Level is implausible (0-2).");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was changed in a previous merge, and it isn't important really, but it suggests a rebase may be needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the whole G33 routine from a non-Git local copy on my drive I use to develop and beta test. Hence not 100% up to date with the latest merges....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, no worries. Just better to not undo recent changes, if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return;
}

Expand All @@ -5094,22 +5090,29 @@ void home_all_axes() { gcode_G28(); }
do_circle_x4 = probe_points == 7,
probe_center_plus_3 = probe_points >= 3,
point_averaging = probe_points >= 4,
probe_center_plus_6 = probe_points >= 5;

const char negating_parameter = do_height_only ? 'A' : do_center_and_towers ? 'O' : 'T';
int8_t probe_mode = code_seen(negating_parameter) && code_value_bool() ? -probe_points : probe_points;
probe_center_plus_6 = probe_points >= 5,
towers_set = (code_seen('T') ? code_value_bool() : true);

SERIAL_PROTOCOLLNPGM("G33 Auto Calibrate");

stepper.synchronize();
#if HAS_LEVELING
set_bed_leveling_enabled(false);
reset_bed_level(); //after calibration bed-level will no longer be valid
#endif
#if HOTENDS > 1
const uint8_t old_tool_index = active_extruder;
tool_change(0, 0, true);
#endif
setup_for_endstop_or_probe_move();

home_all_axes();
endstops.enable(true);
home_delta();
endstops.not_homing();

const static char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
float test_precision,
zero_std_dev = (verbose_level ? 999.0 : 0.0), // 0.0 in dry-run mode : forced end
zero_std_dev_old = zero_std_dev,
e_old[XYZ] = {
endstop_adj[A_AXIS],
endstop_adj[B_AXIS],
Expand Down Expand Up @@ -5141,7 +5144,7 @@ void home_all_axes() { gcode_G28(); }
SERIAL_PROTOCOLPAIR(" Radius:", delta_radius);
}
SERIAL_EOL;
if (probe_mode > 2) { // negative disables tower angles
if (probe_center_plus_3 && towers_set) {
SERIAL_PROTOCOLPGM(".Tower angle : Tx:");
if (delta_tower_angle_trim[A_AXIS] >= 0) SERIAL_CHAR('+');
SERIAL_PROTOCOL_F(delta_tower_angle_trim[A_AXIS], 2);
Expand All @@ -5165,41 +5168,36 @@ void home_all_axes() { gcode_G28(); }
S2 = 0.0;
int16_t N = 0;

test_precision = zero_std_dev;
test_precision = (zero_std_dev_old != 999.0) ? (zero_std_dev + zero_std_dev_old)/2 : zero_std_dev;

iterations++;

// Probe the points

if (!do_all_positions && !do_circle_x3) { // probe the center
setup_for_endstop_or_probe_move();
z_at_pt[0] += probe_pt(0.0, 0.0 , true, 1);
clean_up_after_endstop_or_probe_move();
}
if (probe_center_plus_3) { // probe extra center points
for (int8_t axis = probe_center_plus_6 ? 11 : 9; axis > 0; axis -= probe_center_plus_6 ? 2 : 4) {
setup_for_endstop_or_probe_move();
z_at_pt[0] += probe_pt(
cos(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius),
sin(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius), true, 1);
clean_up_after_endstop_or_probe_move();
}
z_at_pt[0] /= float(do_circle_x2 ? 7 : probe_points);
}
if (!do_height_only) { // probe the radius
bool zig_zag = true;
for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13;
for (uint8_t axis = (do_center_and_towers && !towers_set ? 3 : 1); axis < 13;
axis += (do_center_and_towers ? 4 : do_all_positions ? 2 : 1)) {
float offset_circles = (do_circle_x4 ? (zig_zag ? 1.5 : 1.0) :
do_circle_x3 ? (zig_zag ? 1.0 : 0.5) :
do_circle_x2 ? (zig_zag ? 0.5 : 0.0) : 0);
for (float circles = -offset_circles ; circles <= offset_circles; circles++) {
setup_for_endstop_or_probe_move();
z_at_pt[axis] += probe_pt(
cos(RADIANS(180 + 30 * axis)) * delta_calibration_radius *
(1 + circles * 0.1 * (zig_zag ? 1 : -1)),
sin(RADIANS(180 + 30 * axis)) * delta_calibration_radius *
(1 + circles * 0.1 * (zig_zag ? 1 : -1)), true, 1);
clean_up_after_endstop_or_probe_move();
}
zig_zag = !zig_zag;
z_at_pt[axis] /= (2 * offset_circles + 1);
Expand All @@ -5213,11 +5211,12 @@ void home_all_axes() { gcode_G28(); }
S2 += sq(z_at_pt[0]);
N++;
if (!do_height_only) // std dev from zero plane
for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13; axis += (do_center_and_towers ? 4 : 2)) {
for (uint8_t axis = (do_center_and_towers && !towers_set ? 3 : 1); axis < 13; axis += (do_center_and_towers ? 4 : 2)) {
S1 += z_at_pt[axis];
S2 += sq(z_at_pt[axis]);
N++;
}
zero_std_dev_old = zero_std_dev;
zero_std_dev = round(sqrt(S2 / N) * 1000.0) / 1000.0 + 0.00001;

// Solve matrices
Expand Down Expand Up @@ -5248,25 +5247,25 @@ void home_all_axes() { gcode_G28(); }
#define Z0444(I) ZP(a_factor * 4.0 / 9.0, I)
#define Z0888(I) ZP(a_factor * 8.0 / 9.0, I)

switch (probe_mode) {
case -1:
test_precision = 0.00;
switch (probe_points) {
case 1:
test_precision = 0.00;
LOOP_XYZ(i) e_delta[i] = Z1000(0);
break;

case 2:
e_delta[X_AXIS] = Z1050(0) + Z0700(1) - Z0350(5) - Z0350(9);
e_delta[Y_AXIS] = Z1050(0) - Z0350(1) + Z0700(5) - Z0350(9);
e_delta[Z_AXIS] = Z1050(0) - Z0350(1) - Z0350(5) + Z0700(9);
r_delta = Z2250(0) - Z0750(1) - Z0750(5) - Z0750(9);
break;

case -2:
e_delta[X_AXIS] = Z1050(0) - Z0700(7) + Z0350(11) + Z0350(3);
e_delta[Y_AXIS] = Z1050(0) + Z0350(7) - Z0700(11) + Z0350(3);
e_delta[Z_AXIS] = Z1050(0) + Z0350(7) + Z0350(11) - Z0700(3);
r_delta = Z2250(0) - Z0750(7) - Z0750(11) - Z0750(3);
if (towers_set) {
e_delta[X_AXIS] = Z1050(0) + Z0700(1) - Z0350(5) - Z0350(9);
e_delta[Y_AXIS] = Z1050(0) - Z0350(1) + Z0700(5) - Z0350(9);
e_delta[Z_AXIS] = Z1050(0) - Z0350(1) - Z0350(5) + Z0700(9);
r_delta = Z2250(0) - Z0750(1) - Z0750(5) - Z0750(9);
}
else {
e_delta[X_AXIS] = Z1050(0) - Z0700(7) + Z0350(11) + Z0350(3);
e_delta[Y_AXIS] = Z1050(0) + Z0350(7) - Z0700(11) + Z0350(3);
e_delta[Z_AXIS] = Z1050(0) + Z0350(7) + Z0350(11) - Z0700(3);
r_delta = Z2250(0) - Z0750(7) - Z0750(11) - Z0750(3);
}
break;

default:
Expand All @@ -5275,17 +5274,17 @@ void home_all_axes() { gcode_G28(); }
e_delta[Z_AXIS] = Z1050(0) - Z0175(1) - Z0175(5) + Z0350(9) + Z0175(7) + Z0175(11) - Z0350(3);
r_delta = Z2250(0) - Z0375(1) - Z0375(5) - Z0375(9) - Z0375(7) - Z0375(11) - Z0375(3);

if (probe_mode > 0) { // negative disables tower angles
t_alpha = + Z0444(1) - Z0888(5) + Z0444(9) + Z0444(7) - Z0888(11) + Z0444(3);
t_beta = - Z0888(1) + Z0444(5) + Z0444(9) - Z0888(7) + Z0444(11) + Z0444(3);
if (towers_set) {
t_alpha = Z0444(1) - Z0888(5) + Z0444(9) + Z0444(7) - Z0888(11) + Z0444(3);
t_beta = Z0888(1) - Z0444(5) - Z0444(9) + Z0888(7) - Z0444(11) - Z0444(3);
}
break;
}

LOOP_XYZ(axis) endstop_adj[axis] += e_delta[axis];
delta_radius += r_delta;
delta_tower_angle_trim[A_AXIS] += t_alpha;
delta_tower_angle_trim[B_AXIS] -= t_beta;
delta_tower_angle_trim[B_AXIS] += t_beta;

// adjust delta_height and endstops by the max amount
const float z_temp = MAX3(endstop_adj[A_AXIS], endstop_adj[B_AXIS], endstop_adj[C_AXIS]);
Expand All @@ -5310,7 +5309,7 @@ void home_all_axes() { gcode_G28(); }
SERIAL_PROTOCOLPGM(". c:");
if (z_at_pt[0] > 0) SERIAL_CHAR('+');
SERIAL_PROTOCOL_F(z_at_pt[0], 2);
if (probe_mode == 2 || probe_center_plus_3) {
if ((do_center_and_towers && towers_set) || probe_center_plus_3) {
SERIAL_PROTOCOLPGM(" x:");
if (z_at_pt[1] >= 0) SERIAL_CHAR('+');
SERIAL_PROTOCOL_F(z_at_pt[1], 2);
Expand All @@ -5321,8 +5320,8 @@ void home_all_axes() { gcode_G28(); }
if (z_at_pt[9] >= 0) SERIAL_CHAR('+');
SERIAL_PROTOCOL_F(z_at_pt[9], 2);
}
if (probe_mode != -2) SERIAL_EOL;
if (probe_mode == -2 || probe_center_plus_3) {
if (!do_center_and_towers || towers_set) SERIAL_EOL;
if ((do_center_and_towers && !towers_set) || probe_center_plus_3) {
if (probe_center_plus_3) {
SERIAL_CHAR('.');
SERIAL_PROTOCOL_SP(13);
Expand Down Expand Up @@ -5372,7 +5371,7 @@ void home_all_axes() { gcode_G28(); }
SERIAL_PROTOCOLPAIR(" Radius:", delta_radius);
}
SERIAL_EOL;
if (probe_mode > 2) { // negative disables tower angles
if (probe_center_plus_3 && towers_set) {
SERIAL_PROTOCOLPGM(".Tower angle : Tx:");
if (delta_tower_angle_trim[A_AXIS] >= 0) SERIAL_CHAR('+');
SERIAL_PROTOCOL_F(delta_tower_angle_trim[A_AXIS], 2);
Expand Down Expand Up @@ -5404,12 +5403,19 @@ void home_all_axes() { gcode_G28(); }
}
}

stepper.synchronize();

home_all_axes();
endstops.enable(true);
home_delta();
endstops.not_homing();

} while (zero_std_dev < test_precision && iterations < 31);

#if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
do_blocking_move_to_z(delta_clip_start_height);
#endif
clean_up_after_endstop_or_probe_move();
#if HOTENDS > 1
tool_change(old_tool_index, 0, true);
#endif
#if ENABLED(Z_PROBE_SLED)
RETRACT_PROBE();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@
#define DELTA_RADIUS 100.00 //mm // get this value from auto calibrate

// height from z=0 to home position
#define DELTA_HEIGHT 295.00 // get this value from auto calibrate - use G33 P1 A at 1st time calibration
#define DELTA_HEIGHT 295.00 // get this value from auto calibrate - use G33 P1 at 1st time calibration

// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
#define DELTA_PRINTABLE_RADIUS 85.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@
#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET - DELTA_EFFECTOR_OFFSET - DELTA_CARRIAGE_OFFSET) //mm // get this value from auto calibrate

// height from z=0.00 to home position
#define DELTA_HEIGHT 280 // get this value from auto calibrate - use G33 C-1 at 1st time calibration
#define DELTA_HEIGHT 280 // get this value from auto calibrate - use G33 P1 at 1st time calibration

// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
#define DELTA_PRINTABLE_RADIUS 85.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@
#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET - DELTA_EFFECTOR_OFFSET - DELTA_CARRIAGE_OFFSET) //mm // get this value from auto calibrate // height from z=0.00 to home position

// height from z=0.00 to home position
#define DELTA_HEIGHT 250 // get this value from auto calibrate - use G33 C-1 at 1st time calibration
#define DELTA_HEIGHT 250 // get this value from auto calibrate - use G33 P1 at 1st time calibration

// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
#define DELTA_PRINTABLE_RADIUS 140.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@
#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET - DELTA_EFFECTOR_OFFSET - DELTA_CARRIAGE_OFFSET) //mm // get this value from auto calibrate

// height from z=0.00 to home position
#define DELTA_HEIGHT 250 // get this value from auto calibrate - use G33 C-1 at 1st time calibration
#define DELTA_HEIGHT 250 // get this value from auto calibrate - use G33 P1 at 1st time calibration

// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
#define DELTA_PRINTABLE_RADIUS 90.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET - DELTA_EFFECTOR_OFFSET - DELTA_CARRIAGE_OFFSET) //mm // get this value from auto calibrate

// height from z=0.00 to home position
#define DELTA_HEIGHT 277 // get this value from auto calibrate - use G33 C-1 at 1st time calibration
#define DELTA_HEIGHT 277 // get this value from auto calibrate - use G33 P1 at 1st time calibration

// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
#define DELTA_PRINTABLE_RADIUS 127.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET - DELTA_EFFECTOR_OFFSET - DELTA_CARRIAGE_OFFSET) //mm // get this value from auto calibrate

// height from z=0.00 to home position
#define DELTA_HEIGHT 380 // get this value from auto calibrate - use G33 C-1 at 1st time calibration
#define DELTA_HEIGHT 380 // get this value from auto calibrate - use G33 P1 at 1st time calibration

// Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers).
#define DELTA_PRINTABLE_RADIUS 140.0
Expand Down
2 changes: 1 addition & 1 deletion Marlin/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ void kill_screen(const char* lcd_msg) {
MENU_BACK(MSG_MAIN);
#if ENABLED(DELTA_AUTO_CALIBRATION)
MENU_ITEM(gcode, MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 P1 A"));
MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 P1"));
#endif
MENU_ITEM(submenu, MSG_AUTO_HOME, _lcd_delta_calibrate_home);
if (axis_homed[Z_AXIS]) {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ More features have been added by:
- [@Tannoo]
- [@teemuatlut]
- [@bgort]
- [@LVD-AC]
- Luc Van daele [@LVD-AC] - Dutch, French, English
- [@paulusjacobus]
- ...and many others

Expand Down