2017-09-06 06:28:31 -05:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 08:00:57 -06:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 06:28:31 -05:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-27 23:57:50 -05:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 06:28:31 -05:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-07-22 22:20:14 -05:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-09-06 06:28:31 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-08 15:35:25 -05:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2017-09-08 15:35:25 -05:00
|
|
|
#if ENABLED(DELTA_AUTO_CALIBRATION)
|
|
|
|
|
|
|
|
#include "../gcode.h"
|
|
|
|
#include "../../module/delta.h"
|
|
|
|
#include "../../module/motion.h"
|
|
|
|
#include "../../module/stepper.h"
|
|
|
|
#include "../../module/endstops.h"
|
|
|
|
#include "../../lcd/ultralcd.h"
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
#if HAS_BED_PROBE
|
|
|
|
#include "../../module/probe.h"
|
|
|
|
#endif
|
|
|
|
|
2020-04-19 23:56:55 -05:00
|
|
|
#if HAS_MULTI_HOTEND
|
2017-11-04 21:01:41 -05:00
|
|
|
#include "../../module/tool_change.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 15:35:25 -05:00
|
|
|
#if HAS_LEVELING
|
|
|
|
#include "../../feature/bedlevel/bedlevel.h"
|
2017-09-06 06:28:31 -05:00
|
|
|
#endif
|
|
|
|
|
2017-11-03 03:36:16 -05:00
|
|
|
constexpr uint8_t _7P_STEP = 1, // 7-point step - to change number of calibration points
|
|
|
|
_4P_STEP = _7P_STEP * 2, // 4-point step
|
|
|
|
NPP = _7P_STEP * 6; // number of calibration points on the radius
|
2018-04-11 21:14:48 -05:00
|
|
|
enum CalEnum : char { // the 7 main calibration points - add definitions if needed
|
2017-11-03 03:36:16 -05:00
|
|
|
CEN = 0,
|
|
|
|
__A = 1,
|
|
|
|
_AB = __A + _7P_STEP,
|
|
|
|
__B = _AB + _7P_STEP,
|
|
|
|
_BC = __B + _7P_STEP,
|
|
|
|
__C = _BC + _7P_STEP,
|
|
|
|
_CA = __C + _7P_STEP,
|
|
|
|
};
|
|
|
|
|
2017-11-03 04:07:45 -05:00
|
|
|
#define LOOP_CAL_PT(VAR, S, N) for (uint8_t VAR=S; VAR<=NPP; VAR+=N)
|
|
|
|
#define F_LOOP_CAL_PT(VAR, S, N) for (float VAR=S; VAR<NPP+0.9999; VAR+=N)
|
2017-11-03 03:36:16 -05:00
|
|
|
#define I_LOOP_CAL_PT(VAR, S, N) for (float VAR=S; VAR>CEN+0.9999; VAR-=N)
|
|
|
|
#define LOOP_CAL_ALL(VAR) LOOP_CAL_PT(VAR, CEN, 1)
|
|
|
|
#define LOOP_CAL_RAD(VAR) LOOP_CAL_PT(VAR, __A, _7P_STEP)
|
|
|
|
#define LOOP_CAL_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP)
|
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder);
|
2018-04-11 21:14:48 -05:00
|
|
|
|
2019-09-29 04:25:39 -05:00
|
|
|
float lcd_probe_pt(const xy_pos_t &xy);
|
2018-04-11 21:14:48 -05:00
|
|
|
|
2018-06-30 21:54:07 -05:00
|
|
|
void ac_home() {
|
2018-04-11 21:14:48 -05:00
|
|
|
endstops.enable(true);
|
2018-06-30 21:54:07 -05:00
|
|
|
home_delta();
|
2018-04-11 21:14:48 -05:00
|
|
|
endstops.not_homing();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ac_setup(const bool reset_bed) {
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(HAS_MULTI_HOTEND, tool_change(0, true));
|
2018-04-11 21:14:48 -05:00
|
|
|
|
2018-05-12 01:38:02 -05:00
|
|
|
planner.synchronize();
|
2019-09-23 20:58:01 -05:00
|
|
|
remember_feedrate_scaling_off();
|
2018-04-11 21:14:48 -05:00
|
|
|
|
|
|
|
#if HAS_LEVELING
|
|
|
|
if (reset_bed) reset_bed_level(); // After full calibration bed-level data is no longer valid
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) {
|
|
|
|
TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));
|
|
|
|
TERN_(HAS_BED_PROBE, probe.stow());
|
2019-09-23 20:58:01 -05:00
|
|
|
restore_feedrate_and_scaling();
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index, true));
|
2018-04-11 21:14:48 -05:00
|
|
|
}
|
|
|
|
|
2018-09-30 23:44:33 -05:00
|
|
|
void print_signed_float(PGM_P const prefix, const float &f) {
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOPGM(" ");
|
2017-09-06 06:28:31 -05:00
|
|
|
serialprintPGM(prefix);
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_CHAR(':');
|
2017-09-06 06:28:31 -05:00
|
|
|
if (f >= 0) SERIAL_CHAR('+');
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHO_F(f, 2);
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
/**
|
|
|
|
* - Print the delta settings
|
|
|
|
*/
|
|
|
|
static void print_calibration_settings(const bool end_stops, const bool tower_angles) {
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOPAIR(".Height:", delta_height);
|
2017-09-06 06:28:31 -05:00
|
|
|
if (end_stops) {
|
2019-09-29 04:25:39 -05:00
|
|
|
print_signed_float(PSTR("Ex"), delta_endstop_adj.a);
|
|
|
|
print_signed_float(PSTR("Ey"), delta_endstop_adj.b);
|
|
|
|
print_signed_float(PSTR("Ez"), delta_endstop_adj.c);
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
if (end_stops && tower_angles) {
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOPAIR(" Radius:", delta_radius);
|
2017-10-20 01:08:21 -05:00
|
|
|
SERIAL_EOL();
|
|
|
|
SERIAL_CHAR('.');
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHO_SP(13);
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
2017-09-06 06:28:31 -05:00
|
|
|
if (tower_angles) {
|
2019-09-29 04:25:39 -05:00
|
|
|
print_signed_float(PSTR("Tx"), delta_tower_angle_trim.a);
|
|
|
|
print_signed_float(PSTR("Ty"), delta_tower_angle_trim.b);
|
|
|
|
print_signed_float(PSTR("Tz"), delta_tower_angle_trim.c);
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
|
|
|
if ((!end_stops && tower_angles) || (end_stops && !tower_angles)) { // XOR
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOPAIR(" Radius:", delta_radius);
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
|
|
|
SERIAL_EOL();
|
|
|
|
}
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
/**
|
|
|
|
* - Print the probe results
|
|
|
|
*/
|
|
|
|
static void print_calibration_results(const float z_pt[NPP + 1], const bool tower_points, const bool opposite_points) {
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOPGM(". ");
|
2018-04-11 21:14:48 -05:00
|
|
|
print_signed_float(PSTR("c"), z_pt[CEN]);
|
2017-10-20 01:08:21 -05:00
|
|
|
if (tower_points) {
|
2018-04-11 21:14:48 -05:00
|
|
|
print_signed_float(PSTR(" x"), z_pt[__A]);
|
|
|
|
print_signed_float(PSTR(" y"), z_pt[__B]);
|
|
|
|
print_signed_float(PSTR(" z"), z_pt[__C]);
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
|
|
|
if (tower_points && opposite_points) {
|
2017-09-24 02:18:15 -05:00
|
|
|
SERIAL_EOL();
|
2017-10-20 01:08:21 -05:00
|
|
|
SERIAL_CHAR('.');
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHO_SP(13);
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
if (opposite_points) {
|
2018-04-11 21:14:48 -05:00
|
|
|
print_signed_float(PSTR("yz"), z_pt[_BC]);
|
|
|
|
print_signed_float(PSTR("zx"), z_pt[_CA]);
|
|
|
|
print_signed_float(PSTR("xy"), z_pt[_AB]);
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
|
|
|
SERIAL_EOL();
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
|
2017-10-20 01:08:21 -05:00
|
|
|
/**
|
2018-04-11 21:14:48 -05:00
|
|
|
* - Calculate the standard deviation from the zero plane
|
2017-10-20 01:08:21 -05:00
|
|
|
*/
|
2018-04-11 21:14:48 -05:00
|
|
|
static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool _1p_cal, const bool _4p_cal, const bool _4p_opp) {
|
|
|
|
if (!_0p_cal) {
|
|
|
|
float S2 = sq(z_pt[CEN]);
|
|
|
|
int16_t N = 1;
|
|
|
|
if (!_1p_cal) { // std dev from zero plane
|
|
|
|
LOOP_CAL_ACT(rad, _4p_cal, _4p_opp) {
|
|
|
|
S2 += sq(z_pt[rad]);
|
|
|
|
N++;
|
|
|
|
}
|
2019-09-17 23:10:19 -05:00
|
|
|
return LROUND(SQRT(S2 / N) * 1000.0f) / 1000.0f + 0.00001f;
|
2018-04-11 21:14:48 -05:00
|
|
|
}
|
|
|
|
}
|
2019-09-17 23:10:19 -05:00
|
|
|
return 0.00001f;
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
/**
|
|
|
|
* - Probe a point
|
|
|
|
*/
|
2019-09-29 04:25:39 -05:00
|
|
|
static float calibration_probe(const xy_pos_t &xy, const bool stow) {
|
2017-11-25 03:59:46 -06:00
|
|
|
#if HAS_BED_PROBE
|
2020-02-26 05:33:48 -06:00
|
|
|
return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true, false);
|
2017-11-25 03:59:46 -06:00
|
|
|
#else
|
|
|
|
UNUSED(stow);
|
2019-09-29 04:25:39 -05:00
|
|
|
return lcd_probe_pt(xy);
|
2017-11-25 03:59:46 -06:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
/**
|
|
|
|
* - Probe a grid
|
|
|
|
*/
|
2018-12-18 12:43:38 -06:00
|
|
|
static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_points, const bool towers_set, const bool stow_after_each) {
|
2017-10-20 01:08:21 -05:00
|
|
|
const bool _0p_calibration = probe_points == 0,
|
2018-04-11 21:14:48 -05:00
|
|
|
_1p_calibration = probe_points == 1 || probe_points == -1,
|
2017-10-20 01:08:21 -05:00
|
|
|
_4p_calibration = probe_points == 2,
|
|
|
|
_4p_opposite_points = _4p_calibration && !towers_set,
|
2018-04-11 21:14:48 -05:00
|
|
|
_7p_calibration = probe_points >= 3,
|
2017-11-03 03:36:16 -05:00
|
|
|
_7p_no_intermediates = probe_points == 3,
|
|
|
|
_7p_1_intermediates = probe_points == 4,
|
|
|
|
_7p_2_intermediates = probe_points == 5,
|
|
|
|
_7p_4_intermediates = probe_points == 6,
|
|
|
|
_7p_6_intermediates = probe_points == 7,
|
|
|
|
_7p_8_intermediates = probe_points == 8,
|
|
|
|
_7p_11_intermediates = probe_points == 9,
|
|
|
|
_7p_14_intermediates = probe_points == 10,
|
2017-10-20 01:08:21 -05:00
|
|
|
_7p_intermed_points = probe_points >= 4,
|
2018-04-11 21:14:48 -05:00
|
|
|
_7p_6_center = probe_points >= 5 && probe_points <= 7,
|
|
|
|
_7p_9_center = probe_points >= 8;
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2019-09-17 23:10:19 -05:00
|
|
|
LOOP_CAL_ALL(rad) z_pt[rad] = 0.0f;
|
2017-10-20 01:08:21 -05:00
|
|
|
|
|
|
|
if (!_0p_calibration) {
|
|
|
|
|
2019-11-21 03:26:00 -06:00
|
|
|
const float dcr = delta_calibration_radius();
|
|
|
|
|
2017-11-03 03:36:16 -05:00
|
|
|
if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
|
2019-09-29 04:25:39 -05:00
|
|
|
const xy_pos_t center{0};
|
|
|
|
z_pt[CEN] += calibration_probe(center, stow_after_each);
|
2018-04-11 21:14:48 -05:00
|
|
|
if (isnan(z_pt[CEN])) return false;
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_7p_calibration) { // probe extra center points
|
2019-09-17 23:10:19 -05:00
|
|
|
const float start = _7p_9_center ? float(_CA) + _7P_STEP / 3.0f : _7p_6_center ? float(_CA) : float(__C),
|
|
|
|
steps = _7p_9_center ? _4P_STEP / 3.0f : _7p_6_center ? _7P_STEP : _4P_STEP;
|
2018-04-11 21:14:48 -05:00
|
|
|
I_LOOP_CAL_PT(rad, start, steps) {
|
|
|
|
const float a = RADIANS(210 + (360 / NPP) * (rad - 1)),
|
2019-11-21 03:26:00 -06:00
|
|
|
r = dcr * 0.1;
|
2019-09-29 04:25:39 -05:00
|
|
|
const xy_pos_t vec = { cos(a), sin(a) };
|
|
|
|
z_pt[CEN] += calibration_probe(vec * r, stow_after_each);
|
2018-04-11 21:14:48 -05:00
|
|
|
if (isnan(z_pt[CEN])) return false;
|
2017-11-25 03:59:46 -06:00
|
|
|
}
|
2018-04-11 21:14:48 -05:00
|
|
|
z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!_1p_calibration) { // probe the radius
|
2017-11-03 03:36:16 -05:00
|
|
|
const CalEnum start = _4p_opposite_points ? _AB : __A;
|
2019-09-17 23:10:19 -05:00
|
|
|
const float steps = _7p_14_intermediates ? _7P_STEP / 15.0f : // 15r * 6 + 10c = 100
|
|
|
|
_7p_11_intermediates ? _7P_STEP / 12.0f : // 12r * 6 + 9c = 81
|
|
|
|
_7p_8_intermediates ? _7P_STEP / 9.0f : // 9r * 6 + 10c = 64
|
|
|
|
_7p_6_intermediates ? _7P_STEP / 7.0f : // 7r * 6 + 7c = 49
|
|
|
|
_7p_4_intermediates ? _7P_STEP / 5.0f : // 5r * 6 + 6c = 36
|
|
|
|
_7p_2_intermediates ? _7P_STEP / 3.0f : // 3r * 6 + 7c = 25
|
|
|
|
_7p_1_intermediates ? _7P_STEP / 2.0f : // 2r * 6 + 4c = 16
|
2017-11-03 03:36:16 -05:00
|
|
|
_7p_no_intermediates ? _7P_STEP : // 1r * 6 + 3c = 9
|
|
|
|
_4P_STEP; // .5r * 6 + 1c = 4
|
2017-10-20 01:08:21 -05:00
|
|
|
bool zig_zag = true;
|
2018-04-11 21:14:48 -05:00
|
|
|
F_LOOP_CAL_PT(rad, start, _7p_9_center ? steps * 3 : steps) {
|
|
|
|
const int8_t offset = _7p_9_center ? 2 : 0;
|
|
|
|
for (int8_t circle = 0; circle <= offset; circle++) {
|
|
|
|
const float a = RADIANS(210 + (360 / NPP) * (rad - 1)),
|
2019-11-21 03:26:00 -06:00
|
|
|
r = dcr * (1 - 0.1 * (zig_zag ? offset - circle : circle)),
|
2018-09-17 17:30:04 -05:00
|
|
|
interpol = FMOD(rad, 1);
|
2019-09-29 04:25:39 -05:00
|
|
|
const xy_pos_t vec = { cos(a), sin(a) };
|
|
|
|
const float z_temp = calibration_probe(vec * r, stow_after_each);
|
2018-04-11 21:14:48 -05:00
|
|
|
if (isnan(z_temp)) return false;
|
2017-11-03 03:36:16 -05:00
|
|
|
// split probe point to neighbouring calibration points
|
2018-07-04 18:38:05 -05:00
|
|
|
z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
|
|
|
|
z_pt[uint8_t(LROUND(rad - interpol)) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
|
|
|
zig_zag = !zig_zag;
|
|
|
|
}
|
2017-11-03 03:36:16 -05:00
|
|
|
if (_7p_intermed_points)
|
2018-04-11 21:14:48 -05:00
|
|
|
LOOP_CAL_RAD(rad)
|
|
|
|
z_pt[rad] /= _7P_STEP / steps;
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2019-09-17 23:10:19 -05:00
|
|
|
do_blocking_move_to_xy(0.0f, 0.0f);
|
2017-11-03 03:36:16 -05:00
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
2018-04-11 21:14:48 -05:00
|
|
|
return true;
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
/**
|
|
|
|
* kinematics routines and auto tune matrix scaling parameters:
|
|
|
|
* see https://github.com/LVD-AC/Marlin-AC/tree/1.1.x-AC/documentation for
|
|
|
|
* - formulae for approximative forward kinematics in the end-stop displacement matrix
|
|
|
|
* - definition of the matrix scaling parameters
|
|
|
|
*/
|
2019-09-29 04:25:39 -05:00
|
|
|
static void reverse_kinematics_probe_points(float z_pt[NPP + 1], abc_float_t mm_at_pt_axis[NPP + 1]) {
|
|
|
|
xyz_pos_t pos{0};
|
2018-04-11 21:14:48 -05:00
|
|
|
|
2019-11-21 03:26:00 -06:00
|
|
|
const float dcr = delta_calibration_radius();
|
2018-04-11 21:14:48 -05:00
|
|
|
LOOP_CAL_ALL(rad) {
|
|
|
|
const float a = RADIANS(210 + (360 / NPP) * (rad - 1)),
|
2019-11-21 03:26:00 -06:00
|
|
|
r = (rad == CEN ? 0.0f : dcr);
|
2019-09-29 04:25:39 -05:00
|
|
|
pos.set(cos(a) * r, sin(a) * r, z_pt[rad]);
|
2018-04-11 21:14:48 -05:00
|
|
|
inverse_kinematics(pos);
|
2019-09-29 04:25:39 -05:00
|
|
|
mm_at_pt_axis[rad] = delta;
|
2018-04-11 21:14:48 -05:00
|
|
|
}
|
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2019-09-29 04:25:39 -05:00
|
|
|
static void forward_kinematics_probe_points(abc_float_t mm_at_pt_axis[NPP + 1], float z_pt[NPP + 1]) {
|
2019-11-21 03:26:00 -06:00
|
|
|
const float r_quot = delta_calibration_radius() / delta_radius;
|
2018-04-11 21:14:48 -05:00
|
|
|
|
2019-09-29 04:25:39 -05:00
|
|
|
#define ZPP(N,I,A) (((1.0f + r_quot * (N)) / 3.0f) * mm_at_pt_axis[I].A)
|
2018-04-11 21:14:48 -05:00
|
|
|
#define Z00(I, A) ZPP( 0, I, A)
|
|
|
|
#define Zp1(I, A) ZPP(+1, I, A)
|
|
|
|
#define Zm1(I, A) ZPP(-1, I, A)
|
|
|
|
#define Zp2(I, A) ZPP(+2, I, A)
|
|
|
|
#define Zm2(I, A) ZPP(-2, I, A)
|
|
|
|
|
2019-09-29 04:25:39 -05:00
|
|
|
z_pt[CEN] = Z00(CEN, a) + Z00(CEN, b) + Z00(CEN, c);
|
|
|
|
z_pt[__A] = Zp2(__A, a) + Zm1(__A, b) + Zm1(__A, c);
|
|
|
|
z_pt[__B] = Zm1(__B, a) + Zp2(__B, b) + Zm1(__B, c);
|
|
|
|
z_pt[__C] = Zm1(__C, a) + Zm1(__C, b) + Zp2(__C, c);
|
|
|
|
z_pt[_BC] = Zm2(_BC, a) + Zp1(_BC, b) + Zp1(_BC, c);
|
|
|
|
z_pt[_CA] = Zp1(_CA, a) + Zm2(_CA, b) + Zp1(_CA, c);
|
|
|
|
z_pt[_AB] = Zp1(_AB, a) + Zp1(_AB, b) + Zm2(_AB, c);
|
2018-04-11 21:14:48 -05:00
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2019-09-29 04:25:39 -05:00
|
|
|
static void calc_kinematics_diff_probe_points(float z_pt[NPP + 1], abc_float_t delta_e, const float delta_r, abc_float_t delta_t) {
|
2018-04-11 21:14:48 -05:00
|
|
|
const float z_center = z_pt[CEN];
|
2019-09-29 04:25:39 -05:00
|
|
|
abc_float_t diff_mm_at_pt_axis[NPP + 1], new_mm_at_pt_axis[NPP + 1];
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
reverse_kinematics_probe_points(z_pt, diff_mm_at_pt_axis);
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
delta_radius += delta_r;
|
2019-09-29 04:25:39 -05:00
|
|
|
delta_tower_angle_trim += delta_t;
|
2018-04-11 21:14:48 -05:00
|
|
|
recalc_delta_settings();
|
|
|
|
reverse_kinematics_probe_points(z_pt, new_mm_at_pt_axis);
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2019-09-29 04:25:39 -05:00
|
|
|
LOOP_CAL_ALL(rad) diff_mm_at_pt_axis[rad] -= new_mm_at_pt_axis[rad] + delta_e;
|
2018-04-11 21:14:48 -05:00
|
|
|
forward_kinematics_probe_points(diff_mm_at_pt_axis, z_pt);
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
LOOP_CAL_RAD(rad) z_pt[rad] -= z_pt[CEN] - z_center;
|
|
|
|
z_pt[CEN] = z_center;
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
delta_radius -= delta_r;
|
2019-09-29 04:25:39 -05:00
|
|
|
delta_tower_angle_trim -= delta_t;
|
2018-04-11 21:14:48 -05:00
|
|
|
recalc_delta_settings();
|
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
static float auto_tune_h() {
|
2019-11-21 03:26:00 -06:00
|
|
|
const float r_quot = delta_calibration_radius() / delta_radius;
|
2019-09-29 04:25:39 -05:00
|
|
|
return RECIPROCAL(r_quot / (2.0f / 3.0f)); // (2/3)/CR
|
2018-04-11 21:14:48 -05:00
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
static float auto_tune_r() {
|
2019-09-29 04:25:39 -05:00
|
|
|
constexpr float diff = 0.01f, delta_r = diff;
|
|
|
|
float r_fac = 0.0f, z_pt[NPP + 1] = { 0.0f };
|
|
|
|
abc_float_t delta_e = { 0.0f }, delta_t = { 0.0f };
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
calc_kinematics_diff_probe_points(z_pt, delta_e, delta_r, delta_t);
|
2019-09-17 23:10:19 -05:00
|
|
|
r_fac = -(z_pt[__A] + z_pt[__B] + z_pt[__C] + z_pt[_BC] + z_pt[_CA] + z_pt[_AB]) / 6.0f;
|
|
|
|
r_fac = diff / r_fac / 3.0f; // 1/(3*delta_Z)
|
2018-04-11 21:14:48 -05:00
|
|
|
return r_fac;
|
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
static float auto_tune_a() {
|
2019-09-29 04:25:39 -05:00
|
|
|
constexpr float diff = 0.01f, delta_r = 0.0f;
|
|
|
|
float a_fac = 0.0f, z_pt[NPP + 1] = { 0.0f };
|
|
|
|
abc_float_t delta_e = { 0.0f }, delta_t = { 0.0f };
|
|
|
|
|
|
|
|
delta_t.reset();
|
2018-04-11 21:14:48 -05:00
|
|
|
LOOP_XYZ(axis) {
|
|
|
|
delta_t[axis] = diff;
|
|
|
|
calc_kinematics_diff_probe_points(z_pt, delta_e, delta_r, delta_t);
|
2019-09-14 03:05:10 -05:00
|
|
|
delta_t[axis] = 0;
|
2019-09-17 23:10:19 -05:00
|
|
|
a_fac += z_pt[uint8_t((axis * _4P_STEP) - _7P_STEP + NPP) % NPP + 1] / 6.0f;
|
|
|
|
a_fac -= z_pt[uint8_t((axis * _4P_STEP) + 1 + _7P_STEP)] / 6.0f;
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
2019-09-17 23:10:19 -05:00
|
|
|
a_fac = diff / a_fac / 3.0f; // 1/(3*delta_Z)
|
2018-04-11 21:14:48 -05:00
|
|
|
return a_fac;
|
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2017-10-06 15:47:51 -05:00
|
|
|
/**
|
|
|
|
* G33 - Delta '1-4-7-point' Auto-Calibration
|
2018-04-11 21:14:48 -05:00
|
|
|
* Calibrate height, z_offset, endstops, delta radius, and tower angles.
|
2017-10-06 15:47:51 -05:00
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
*
|
|
|
|
* Pn Number of probe points:
|
2018-04-11 21:14:48 -05:00
|
|
|
* P0 Normalizes calibration.
|
|
|
|
* P1 Calibrates height only with center probe.
|
|
|
|
* P2 Probe center and towers. Calibrate height, endstops and delta radius.
|
|
|
|
* P3 Probe all positions: center, towers and opposite towers. Calibrate all.
|
|
|
|
* P4-P10 Probe all positions at different intermediate locations and average them.
|
2017-10-06 15:47:51 -05:00
|
|
|
*
|
2017-10-20 01:08:21 -05:00
|
|
|
* T Don't calibrate tower angle corrections
|
2017-10-06 15:47:51 -05:00
|
|
|
*
|
2017-10-20 01:08:21 -05:00
|
|
|
* Cn.nn Calibration precision; when omitted calibrates to maximum precision
|
2017-10-06 15:47:51 -05:00
|
|
|
*
|
2018-03-16 01:25:32 -05:00
|
|
|
* Fn Force to run at least n iterations and take the best result
|
2017-10-06 15:47:51 -05:00
|
|
|
*
|
2017-10-20 01:08:21 -05:00
|
|
|
* Vn Verbose level:
|
2017-10-06 15:47:51 -05:00
|
|
|
* V0 Dry-run mode. Report settings and probe results. No calibration.
|
2017-11-25 03:59:46 -06:00
|
|
|
* V1 Report start and end settings only
|
|
|
|
* V2 Report settings at each iteration
|
|
|
|
* V3 Report settings and probe results
|
2017-10-06 15:47:51 -05:00
|
|
|
*
|
|
|
|
* E Engage the probe for each point
|
|
|
|
*/
|
2017-09-08 15:35:25 -05:00
|
|
|
void GcodeSuite::G33() {
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2018-12-18 12:43:38 -06:00
|
|
|
const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
|
|
|
|
if (!WITHIN(probe_points, 0, 10)) {
|
2019-09-11 02:46:52 -05:00
|
|
|
SERIAL_ECHOLNPGM("?(P)oints implausible (0-10).");
|
2017-09-06 06:28:31 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
const bool towers_set = !parser.seen('T');
|
|
|
|
|
2019-09-17 23:10:19 -05:00
|
|
|
const float calibration_precision = parser.floatval('C', 0.0f);
|
2017-09-06 06:28:31 -05:00
|
|
|
if (calibration_precision < 0) {
|
2019-09-11 02:46:52 -05:00
|
|
|
SERIAL_ECHOLNPGM("?(C)alibration precision implausible (>=0).");
|
2017-09-06 06:28:31 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int8_t force_iterations = parser.intval('F', 0);
|
|
|
|
if (!WITHIN(force_iterations, 0, 30)) {
|
2019-09-11 02:46:52 -05:00
|
|
|
SERIAL_ECHOLNPGM("?(F)orce iteration implausible (0-30).");
|
2018-04-11 21:14:48 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int8_t verbose_level = parser.byteval('V', 1);
|
|
|
|
if (!WITHIN(verbose_level, 0, 3)) {
|
2019-09-11 02:46:52 -05:00
|
|
|
SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-3).");
|
2017-09-06 06:28:31 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
const bool stow_after_each = parser.seen('E');
|
|
|
|
|
|
|
|
const bool _0p_calibration = probe_points == 0,
|
|
|
|
_1p_calibration = probe_points == 1 || probe_points == -1,
|
2017-09-06 06:28:31 -05:00
|
|
|
_4p_calibration = probe_points == 2,
|
2018-04-11 21:14:48 -05:00
|
|
|
_4p_opposite_points = _4p_calibration && !towers_set,
|
|
|
|
_7p_9_center = probe_points >= 8,
|
|
|
|
_tower_results = (_4p_calibration && towers_set) || probe_points >= 3,
|
|
|
|
_opposite_results = (_4p_calibration && !towers_set) || probe_points >= 3,
|
|
|
|
_endstop_results = probe_points != 1 && probe_points != -1 && probe_points != 0,
|
2019-08-16 18:34:13 -05:00
|
|
|
_angle_results = probe_points >= 3 && towers_set;
|
2017-09-06 06:28:31 -05:00
|
|
|
int8_t iterations = 0;
|
|
|
|
float test_precision,
|
2019-09-17 23:10:19 -05:00
|
|
|
zero_std_dev = (verbose_level ? 999.0f : 0.0f), // 0.0 in dry-run mode : forced end
|
2017-09-06 06:28:31 -05:00
|
|
|
zero_std_dev_min = zero_std_dev,
|
2018-04-11 21:14:48 -05:00
|
|
|
zero_std_dev_old = zero_std_dev,
|
2019-09-29 04:25:39 -05:00
|
|
|
h_factor, r_factor, a_factor,
|
2018-04-11 21:14:48 -05:00
|
|
|
r_old = delta_radius,
|
2019-09-29 04:25:39 -05:00
|
|
|
h_old = delta_height;
|
|
|
|
|
|
|
|
abc_pos_t e_old = delta_endstop_adj, a_old = delta_tower_angle_trim;
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOLNPGM("G33 Auto Calibrate");
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2019-11-21 03:26:00 -06:00
|
|
|
const float dcr = delta_calibration_radius();
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
if (!_1p_calibration && !_0p_calibration) { // test if the outer radius is reachable
|
2017-11-03 03:36:16 -05:00
|
|
|
LOOP_CAL_RAD(axis) {
|
2019-11-21 03:26:00 -06:00
|
|
|
const float a = RADIANS(210 + (360 / NPP) * (axis - 1));
|
|
|
|
if (!position_is_reachable(cos(a) * dcr, sin(a) * dcr)) {
|
|
|
|
SERIAL_ECHOLNPGM("?Bed calibration radius implausible.");
|
2017-09-06 06:28:31 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-20 01:08:21 -05:00
|
|
|
// Report settings
|
2020-05-05 23:34:04 -05:00
|
|
|
PGM_P const checkingac = PSTR("Checking... AC");
|
2017-09-06 06:28:31 -05:00
|
|
|
serialprintPGM(checkingac);
|
2018-11-29 16:58:58 -06:00
|
|
|
if (verbose_level == 0) SERIAL_ECHOPGM(" (DRY-RUN)");
|
2017-09-06 06:28:31 -05:00
|
|
|
SERIAL_EOL();
|
2018-11-17 22:21:44 -06:00
|
|
|
ui.set_status_P(checkingac);
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
print_calibration_settings(_endstop_results, _angle_results);
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
ac_setup(!_0p_calibration && !_1p_calibration);
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2018-06-30 21:54:07 -05:00
|
|
|
if (!_0p_calibration) ac_home();
|
2018-04-11 21:14:48 -05:00
|
|
|
|
|
|
|
do { // start iterations
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2019-09-17 23:10:19 -05:00
|
|
|
float z_at_pt[NPP + 1] = { 0.0f };
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2019-09-17 23:10:19 -05:00
|
|
|
test_precision = zero_std_dev_old != 999.0f ? (zero_std_dev + zero_std_dev_old) / 2.0f : zero_std_dev;
|
2017-09-06 06:28:31 -05:00
|
|
|
iterations++;
|
|
|
|
|
|
|
|
// Probe the points
|
2018-04-11 21:14:48 -05:00
|
|
|
zero_std_dev_old = zero_std_dev;
|
2018-12-18 12:43:38 -06:00
|
|
|
if (!probe_calibration_points(z_at_pt, probe_points, towers_set, stow_after_each)) {
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOLNPGM("Correct delta settings with M665 and M666");
|
2020-04-22 16:35:03 -05:00
|
|
|
return ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index));
|
2017-11-25 03:59:46 -06:00
|
|
|
}
|
2018-04-11 21:14:48 -05:00
|
|
|
zero_std_dev = std_dev_points(z_at_pt, _0p_calibration, _1p_calibration, _4p_calibration, _4p_opposite_points);
|
2017-09-06 06:28:31 -05:00
|
|
|
|
|
|
|
// Solve matrices
|
|
|
|
|
2017-10-06 15:47:51 -05:00
|
|
|
if ((zero_std_dev < test_precision || iterations <= force_iterations) && zero_std_dev > calibration_precision) {
|
2018-04-11 21:14:48 -05:00
|
|
|
|
|
|
|
#if !HAS_BED_PROBE
|
2019-09-17 23:10:19 -05:00
|
|
|
test_precision = 0.0f; // forced end
|
2018-04-11 21:14:48 -05:00
|
|
|
#endif
|
|
|
|
|
2017-09-06 06:28:31 -05:00
|
|
|
if (zero_std_dev < zero_std_dev_min) {
|
2018-04-11 21:14:48 -05:00
|
|
|
// set roll-back point
|
2019-09-29 04:25:39 -05:00
|
|
|
e_old = delta_endstop_adj;
|
2018-04-11 21:14:48 -05:00
|
|
|
r_old = delta_radius;
|
|
|
|
h_old = delta_height;
|
2019-09-29 04:25:39 -05:00
|
|
|
a_old = delta_tower_angle_trim;
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
|
2019-09-29 04:25:39 -05:00
|
|
|
abc_float_t e_delta = { 0.0f }, t_delta = { 0.0f };
|
|
|
|
float r_delta = 0.0f;
|
2018-04-11 21:14:48 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* convergence matrices:
|
|
|
|
* see https://github.com/LVD-AC/Marlin-AC/tree/1.1.x-AC/documentation for
|
|
|
|
* - definition of the matrix scaling parameters
|
|
|
|
* - matrices for 4 and 7 point calibration
|
|
|
|
*/
|
2019-09-17 23:10:19 -05:00
|
|
|
#define ZP(N,I) ((N) * z_at_pt[I] / 4.0f) // 4.0 = divider to normalize to integers
|
2018-04-11 21:14:48 -05:00
|
|
|
#define Z12(I) ZP(12, I)
|
2017-09-24 02:18:15 -05:00
|
|
|
#define Z4(I) ZP(4, I)
|
|
|
|
#define Z2(I) ZP(2, I)
|
|
|
|
#define Z1(I) ZP(1, I)
|
2018-04-11 21:14:48 -05:00
|
|
|
#define Z0(I) ZP(0, I)
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
// calculate factors
|
2019-11-21 03:26:00 -06:00
|
|
|
if (_7p_9_center) calibration_radius_factor = 0.9f;
|
2018-04-11 21:14:48 -05:00
|
|
|
h_factor = auto_tune_h();
|
|
|
|
r_factor = auto_tune_r();
|
|
|
|
a_factor = auto_tune_a();
|
2019-11-21 03:26:00 -06:00
|
|
|
calibration_radius_factor = 1.0f;
|
2017-09-06 06:28:31 -05:00
|
|
|
|
|
|
|
switch (probe_points) {
|
2017-10-06 15:47:51 -05:00
|
|
|
case 0:
|
2019-09-17 23:10:19 -05:00
|
|
|
test_precision = 0.0f; // forced end
|
2017-10-06 15:47:51 -05:00
|
|
|
break;
|
|
|
|
|
2017-09-06 06:28:31 -05:00
|
|
|
case 1:
|
2019-09-17 23:10:19 -05:00
|
|
|
test_precision = 0.0f; // forced end
|
2018-04-11 21:14:48 -05:00
|
|
|
LOOP_XYZ(axis) e_delta[axis] = +Z4(CEN);
|
2017-09-06 06:28:31 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2018-04-11 21:14:48 -05:00
|
|
|
if (towers_set) { // see 4 point calibration (towers) matrix
|
2019-09-29 04:25:39 -05:00
|
|
|
e_delta.set((+Z4(__A) -Z2(__B) -Z2(__C)) * h_factor +Z4(CEN),
|
|
|
|
(-Z2(__A) +Z4(__B) -Z2(__C)) * h_factor +Z4(CEN),
|
|
|
|
(-Z2(__A) -Z2(__B) +Z4(__C)) * h_factor +Z4(CEN));
|
|
|
|
r_delta = (+Z4(__A) +Z4(__B) +Z4(__C) -Z12(CEN)) * r_factor;
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2018-04-11 21:14:48 -05:00
|
|
|
else { // see 4 point calibration (opposites) matrix
|
2019-09-29 04:25:39 -05:00
|
|
|
e_delta.set((-Z4(_BC) +Z2(_CA) +Z2(_AB)) * h_factor +Z4(CEN),
|
|
|
|
(+Z2(_BC) -Z4(_CA) +Z2(_AB)) * h_factor +Z4(CEN),
|
|
|
|
(+Z2(_BC) +Z2(_CA) -Z4(_AB)) * h_factor +Z4(CEN));
|
|
|
|
r_delta = (+Z4(_BC) +Z4(_CA) +Z4(_AB) -Z12(CEN)) * r_factor;
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
default: // see 7 point calibration (towers & opposites) matrix
|
2019-09-29 04:25:39 -05:00
|
|
|
e_delta.set((+Z2(__A) -Z1(__B) -Z1(__C) -Z2(_BC) +Z1(_CA) +Z1(_AB)) * h_factor +Z4(CEN),
|
|
|
|
(-Z1(__A) +Z2(__B) -Z1(__C) +Z1(_BC) -Z2(_CA) +Z1(_AB)) * h_factor +Z4(CEN),
|
|
|
|
(-Z1(__A) -Z1(__B) +Z2(__C) +Z1(_BC) +Z1(_CA) -Z2(_AB)) * h_factor +Z4(CEN));
|
|
|
|
r_delta = (+Z2(__A) +Z2(__B) +Z2(__C) +Z2(_BC) +Z2(_CA) +Z2(_AB) -Z12(CEN)) * r_factor;
|
2018-04-11 21:14:48 -05:00
|
|
|
|
|
|
|
if (towers_set) { // see 7 point tower angle calibration (towers & opposites) matrix
|
2019-09-29 04:25:39 -05:00
|
|
|
t_delta.set((+Z0(__A) -Z4(__B) +Z4(__C) +Z0(_BC) -Z4(_CA) +Z4(_AB) +Z0(CEN)) * a_factor,
|
|
|
|
(+Z4(__A) +Z0(__B) -Z4(__C) +Z4(_BC) +Z0(_CA) -Z4(_AB) +Z0(CEN)) * a_factor,
|
|
|
|
(-Z4(__A) +Z4(__B) +Z0(__C) -Z4(_BC) +Z4(_CA) +Z0(_AB) +Z0(CEN)) * a_factor);
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2019-09-29 04:25:39 -05:00
|
|
|
delta_endstop_adj += e_delta;
|
2017-09-06 06:28:31 -05:00
|
|
|
delta_radius += r_delta;
|
2019-09-29 04:25:39 -05:00
|
|
|
delta_tower_angle_trim += t_delta;
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2018-04-11 21:14:48 -05:00
|
|
|
else if (zero_std_dev >= test_precision) {
|
|
|
|
// roll back
|
2019-09-29 04:25:39 -05:00
|
|
|
delta_endstop_adj = e_old;
|
2018-04-11 21:14:48 -05:00
|
|
|
delta_radius = r_old;
|
|
|
|
delta_height = h_old;
|
2019-09-29 04:25:39 -05:00
|
|
|
delta_tower_angle_trim = a_old;
|
2017-09-24 02:18:15 -05:00
|
|
|
}
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2017-09-24 02:18:15 -05:00
|
|
|
if (verbose_level != 0) { // !dry run
|
2018-04-11 21:14:48 -05:00
|
|
|
|
2018-10-16 03:38:57 -05:00
|
|
|
// Normalize angles to least-squares
|
2017-10-20 01:08:21 -05:00
|
|
|
if (_angle_results) {
|
2019-09-17 23:10:19 -05:00
|
|
|
float a_sum = 0.0f;
|
2017-10-20 01:08:21 -05:00
|
|
|
LOOP_XYZ(axis) a_sum += delta_tower_angle_trim[axis];
|
2019-09-17 23:10:19 -05:00
|
|
|
LOOP_XYZ(axis) delta_tower_angle_trim[axis] -= a_sum / 3.0f;
|
2017-10-20 01:08:21 -05:00
|
|
|
}
|
2017-09-27 04:57:14 -05:00
|
|
|
|
2017-09-24 02:18:15 -05:00
|
|
|
// adjust delta_height and endstops by the max amount
|
2019-09-29 04:25:39 -05:00
|
|
|
const float z_temp = _MAX(delta_endstop_adj.a, delta_endstop_adj.b, delta_endstop_adj.c);
|
2017-11-08 22:10:08 -06:00
|
|
|
delta_height -= z_temp;
|
2017-09-24 02:18:15 -05:00
|
|
|
LOOP_XYZ(axis) delta_endstop_adj[axis] -= z_temp;
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2017-11-08 03:07:17 -06:00
|
|
|
recalc_delta_settings();
|
2017-09-06 06:28:31 -05:00
|
|
|
NOMORE(zero_std_dev_min, zero_std_dev);
|
|
|
|
|
|
|
|
// print report
|
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
if (verbose_level == 3)
|
|
|
|
print_calibration_results(z_at_pt, _tower_results, _opposite_results);
|
2017-10-20 01:08:21 -05:00
|
|
|
|
2018-04-11 21:14:48 -05:00
|
|
|
if (verbose_level != 0) { // !dry run
|
|
|
|
if ((zero_std_dev >= test_precision && iterations > force_iterations) || zero_std_dev <= calibration_precision) { // end iterations
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOPGM("Calibration OK");
|
|
|
|
SERIAL_ECHO_SP(32);
|
2017-11-07 19:34:34 -06:00
|
|
|
#if HAS_BED_PROBE
|
2018-04-11 21:14:48 -05:00
|
|
|
if (zero_std_dev >= test_precision && !_1p_calibration && !_0p_calibration)
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOPGM("rolling back.");
|
2017-09-06 06:28:31 -05:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHOPAIR_F("std dev:", zero_std_dev_min, 3);
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
SERIAL_EOL();
|
|
|
|
char mess[21];
|
2017-11-07 17:33:33 -06:00
|
|
|
strcpy_P(mess, PSTR("Calibration sd:"));
|
2017-09-06 06:28:31 -05:00
|
|
|
if (zero_std_dev_min < 1)
|
2019-09-17 23:10:19 -05:00
|
|
|
sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev_min * 1000.0f));
|
2017-09-06 06:28:31 -05:00
|
|
|
else
|
2018-07-04 18:38:05 -05:00
|
|
|
sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev_min));
|
2018-11-17 22:21:44 -06:00
|
|
|
ui.set_status(mess);
|
2018-04-11 21:14:48 -05:00
|
|
|
print_calibration_settings(_endstop_results, _angle_results);
|
2020-01-30 03:24:23 -06:00
|
|
|
SERIAL_ECHOLNPGM("Save with M500 and/or copy to Configuration.h");
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2018-04-11 21:14:48 -05:00
|
|
|
else { // !end iterations
|
2017-09-06 06:28:31 -05:00
|
|
|
char mess[15];
|
|
|
|
if (iterations < 31)
|
2018-12-27 18:05:42 -06:00
|
|
|
sprintf_P(mess, PSTR("Iteration : %02i"), (unsigned int)iterations);
|
2017-09-06 06:28:31 -05:00
|
|
|
else
|
2017-11-07 17:33:33 -06:00
|
|
|
strcpy_P(mess, PSTR("No convergence"));
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHO(mess);
|
|
|
|
SERIAL_ECHO_SP(32);
|
|
|
|
SERIAL_ECHOLNPAIR_F("std dev:", zero_std_dev, 3);
|
2018-11-17 22:21:44 -06:00
|
|
|
ui.set_status(mess);
|
2017-11-25 03:59:46 -06:00
|
|
|
if (verbose_level > 1)
|
2018-04-11 21:14:48 -05:00
|
|
|
print_calibration_settings(_endstop_results, _angle_results);
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
|
|
|
}
|
2018-04-11 21:14:48 -05:00
|
|
|
else { // dry run
|
2020-05-05 23:34:04 -05:00
|
|
|
PGM_P const enddryrun = PSTR("End DRY-RUN");
|
2017-09-06 06:28:31 -05:00
|
|
|
serialprintPGM(enddryrun);
|
2018-11-29 16:58:58 -06:00
|
|
|
SERIAL_ECHO_SP(35);
|
|
|
|
SERIAL_ECHOLNPAIR_F("std dev:", zero_std_dev, 3);
|
2017-09-06 06:28:31 -05:00
|
|
|
|
|
|
|
char mess[21];
|
2017-11-07 17:33:33 -06:00
|
|
|
strcpy_P(mess, enddryrun);
|
|
|
|
strcpy_P(&mess[11], PSTR(" sd:"));
|
2017-09-06 06:28:31 -05:00
|
|
|
if (zero_std_dev < 1)
|
2019-09-17 23:10:19 -05:00
|
|
|
sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev * 1000.0f));
|
2017-09-06 06:28:31 -05:00
|
|
|
else
|
2018-07-04 18:38:05 -05:00
|
|
|
sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev));
|
2018-11-17 22:21:44 -06:00
|
|
|
ui.set_status(mess);
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2018-06-30 21:54:07 -05:00
|
|
|
ac_home();
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2017-10-06 15:47:51 -05:00
|
|
|
while (((zero_std_dev < test_precision && iterations < 31) || iterations <= force_iterations) && zero_std_dev > calibration_precision);
|
2017-09-06 06:28:31 -05:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index));
|
2017-09-06 06:28:31 -05:00
|
|
|
}
|
2017-09-08 15:35:25 -05:00
|
|
|
|
|
|
|
#endif // DELTA_AUTO_CALIBRATION
|