Polargraph / Makelangelo kinematics (#22790)

This commit is contained in:
Dan Royer
2021-09-20 13:42:33 -07:00
committed by Scott Lahteine
parent 71b8a22d96
commit b3fd03198a
24 changed files with 304 additions and 104 deletions

View File

@ -489,7 +489,7 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s
const feedRate_t z_feedrate = fr_mm_s ?: homing_feedrate(Z_AXIS);
#endif
#if EITHER(DELTA, IS_SCARA)
#if IS_KINEMATIC
if (!position_is_reachable(x, y)) return;
destination = current_position; // sync destination at the start
#endif

View File

@ -504,6 +504,14 @@ void home_if_needed(const bool keeplev=false);
return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS - inset + fslop);
#elif ENABLED(POLARGRAPH)
const float x1 = rx - (X_MIN_POS), x2 = (X_MAX_POS) - rx, y = ry - (Y_MAX_POS),
a = HYPOT(x1, y), b = HYPOT(x2, y);
return a < (POLARGRAPH_MAX_BELT_LEN) + 1
&& b < (POLARGRAPH_MAX_BELT_LEN) + 1
&& (a + b) > _MIN(X_BED_SIZE, Y_BED_SIZE);
#elif ENABLED(AXEL_TPARA)
const float R2 = HYPOT2(rx - TPARA_OFFSET_X, ry - TPARA_OFFSET_Y);

View File

@ -3021,7 +3021,7 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons
#else
const feedRate_t feedrate = fr_mm_s;
#endif
delta.e = machine.e;
TERN_(HAS_EXTRUDERS, delta.e = machine.e);
if (buffer_segment(delta OPTARG(HAS_DIST_MM_ARG, cart_dist_mm), feedrate, extruder, mm)) {
position_cart = cart;
return true;
@ -3126,7 +3126,7 @@ void Planner::set_position_mm(const xyze_pos_t &xyze) {
#if IS_KINEMATIC
position_cart = xyze;
inverse_kinematics(machine);
delta.e = machine.e;
TERN_(HAS_EXTRUDERS, delta.e = machine.e);
set_machine_position_mm(delta);
#else
set_machine_position_mm(machine);

View File

@ -48,6 +48,8 @@
#if ENABLED(DELTA)
#include "delta.h"
#elif ENABLED(POLARGRAPH)
#include "polargraph.h"
#endif
#if ABL_PLANAR

View File

@ -0,0 +1,47 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* polargraph.cpp
*/
#include "../inc/MarlinConfig.h"
#if ENABLED(POLARGRAPH)
#include "polargraph.h"
#include "motion.h"
// For homing:
#include "planner.h"
#include "endstops.h"
#include "../lcd/marlinui.h"
#include "../MarlinCore.h"
float segments_per_second; // Initialized by settings.load()
void inverse_kinematics(const xyz_pos_t &raw) {
const float x1 = raw.x - (X_MIN_POS), x2 = (X_MAX_POS) - raw.x, y = raw.y - (Y_MAX_POS);
delta.set(HYPOT(x1, y), HYPOT(x2, y), raw.z);
}
#endif // POLARGRAPH

View File

@ -0,0 +1,33 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* polargraph.h - Polargraph-specific functions
*/
#include "../core/types.h"
#include "../core/macros.h"
extern float segments_per_second;
void inverse_kinematics(const xyz_pos_t &raw);

View File

@ -36,7 +36,7 @@
*/
// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V84"
#define EEPROM_VERSION "V85"
#define EEPROM_OFFSET 100
// Check the integrity of data offsets.
@ -279,17 +279,24 @@ typedef struct SettingsDataStruct {
bool bltouch_last_written_mode;
//
// DELTA / [XYZ]_DUAL_ENDSTOPS
// Kinematic Settings
//
#if ENABLED(DELTA)
float delta_height; // M666 H
abc_float_t delta_endstop_adj; // M666 X Y Z
float delta_radius, // M665 R
delta_diagonal_rod, // M665 L
segments_per_second; // M665 S
abc_float_t delta_tower_angle_trim, // M665 X Y Z
delta_diagonal_rod_trim; // M665 A B C
#elif HAS_EXTRA_ENDSTOPS
#if IS_KINEMATIC
float segments_per_second; // M665 S
#if ENABLED(DELTA)
float delta_height; // M666 H
abc_float_t delta_endstop_adj; // M666 X Y Z
float delta_radius, // M665 R
delta_diagonal_rod; // M665 L
abc_float_t delta_tower_angle_trim, // M665 X Y Z
delta_diagonal_rod_trim; // M665 A B C
#endif
#endif
//
// Extra Endstops offsets
//
#if HAS_EXTRA_ENDSTOPS
float x2_endstop_adj, // M666 X
y2_endstop_adj, // M666 Y
z2_endstop_adj, // M666 (S2) Z
@ -857,45 +864,49 @@ void MarlinSettings::postprocess() {
}
//
// DELTA Geometry or Dual Endstops offsets
// Kinematic Settings
//
#if IS_KINEMATIC
{
EEPROM_WRITE(segments_per_second);
#if ENABLED(DELTA)
_FIELD_TEST(delta_height);
EEPROM_WRITE(delta_height); // 1 float
EEPROM_WRITE(delta_endstop_adj); // 3 floats
EEPROM_WRITE(delta_radius); // 1 float
EEPROM_WRITE(delta_diagonal_rod); // 1 float
EEPROM_WRITE(segments_per_second); // 1 float
EEPROM_WRITE(delta_tower_angle_trim); // 3 floats
EEPROM_WRITE(delta_diagonal_rod_trim); // 3 floats
#elif HAS_EXTRA_ENDSTOPS
_FIELD_TEST(x2_endstop_adj);
// Write dual endstops in X, Y, Z order. Unused = 0.0
dummyf = 0;
EEPROM_WRITE(TERN(X_DUAL_ENDSTOPS, endstops.x2_endstop_adj, dummyf)); // 1 float
EEPROM_WRITE(TERN(Y_DUAL_ENDSTOPS, endstops.y2_endstop_adj, dummyf)); // 1 float
EEPROM_WRITE(TERN(Z_MULTI_ENDSTOPS, endstops.z2_endstop_adj, dummyf)); // 1 float
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
EEPROM_WRITE(endstops.z3_endstop_adj); // 1 float
#else
EEPROM_WRITE(dummyf);
#endif
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4
EEPROM_WRITE(endstops.z4_endstop_adj); // 1 float
#else
EEPROM_WRITE(dummyf);
#endif
#endif
}
#endif
//
// Extra Endstops offsets
//
#if HAS_EXTRA_ENDSTOPS
{
_FIELD_TEST(x2_endstop_adj);
// Write dual endstops in X, Y, Z order. Unused = 0.0
dummyf = 0;
EEPROM_WRITE(TERN(X_DUAL_ENDSTOPS, endstops.x2_endstop_adj, dummyf)); // 1 float
EEPROM_WRITE(TERN(Y_DUAL_ENDSTOPS, endstops.y2_endstop_adj, dummyf)); // 1 float
EEPROM_WRITE(TERN(Z_MULTI_ENDSTOPS, endstops.z2_endstop_adj, dummyf)); // 1 float
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
EEPROM_WRITE(endstops.z3_endstop_adj); // 1 float
#else
EEPROM_WRITE(dummyf);
#endif
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4
EEPROM_WRITE(endstops.z4_endstop_adj); // 1 float
#else
EEPROM_WRITE(dummyf);
#endif
}
#endif
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
EEPROM_WRITE(z_stepper_align.xy);
@ -1724,42 +1735,46 @@ void MarlinSettings::postprocess() {
}
//
// DELTA Geometry or Dual Endstops offsets
// Kinematic Segments-per-second
//
#if IS_KINEMATIC
{
EEPROM_READ(segments_per_second);
#if ENABLED(DELTA)
_FIELD_TEST(delta_height);
EEPROM_READ(delta_height); // 1 float
EEPROM_READ(delta_endstop_adj); // 3 floats
EEPROM_READ(delta_radius); // 1 float
EEPROM_READ(delta_diagonal_rod); // 1 float
EEPROM_READ(segments_per_second); // 1 float
EEPROM_READ(delta_tower_angle_trim); // 3 floats
EEPROM_READ(delta_diagonal_rod_trim); // 3 floats
#elif HAS_EXTRA_ENDSTOPS
_FIELD_TEST(x2_endstop_adj);
EEPROM_READ(TERN(X_DUAL_ENDSTOPS, endstops.x2_endstop_adj, dummyf)); // 1 float
EEPROM_READ(TERN(Y_DUAL_ENDSTOPS, endstops.y2_endstop_adj, dummyf)); // 1 float
EEPROM_READ(TERN(Z_MULTI_ENDSTOPS, endstops.z2_endstop_adj, dummyf)); // 1 float
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
EEPROM_READ(endstops.z3_endstop_adj); // 1 float
#else
EEPROM_READ(dummyf);
#endif
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4
EEPROM_READ(endstops.z4_endstop_adj); // 1 float
#else
EEPROM_READ(dummyf);
#endif
#endif
}
#endif
//
// Extra Endstops offsets
//
#if HAS_EXTRA_ENDSTOPS
{
_FIELD_TEST(x2_endstop_adj);
EEPROM_READ(TERN(X_DUAL_ENDSTOPS, endstops.x2_endstop_adj, dummyf)); // 1 float
EEPROM_READ(TERN(Y_DUAL_ENDSTOPS, endstops.y2_endstop_adj, dummyf)); // 1 float
EEPROM_READ(TERN(Z_MULTI_ENDSTOPS, endstops.z2_endstop_adj, dummyf)); // 1 float
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
EEPROM_READ(endstops.z3_endstop_adj); // 1 float
#else
EEPROM_READ(dummyf);
#endif
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4
EEPROM_READ(endstops.z4_endstop_adj); // 1 float
#else
EEPROM_READ(dummyf);
#endif
}
#endif
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
EEPROM_READ(z_stepper_align.xy);
@ -2721,20 +2736,30 @@ void MarlinSettings::reset() {
//#endif
//
// Endstop Adjustments
// Kinematic settings
//
#if ENABLED(DELTA)
const abc_float_t adj = DELTA_ENDSTOP_ADJ, dta = DELTA_TOWER_ANGLE_TRIM, ddr = DELTA_DIAGONAL_ROD_TRIM_TOWER;
delta_height = DELTA_HEIGHT;
delta_endstop_adj = adj;
delta_radius = DELTA_RADIUS;
delta_diagonal_rod = DELTA_DIAGONAL_ROD;
segments_per_second = DELTA_SEGMENTS_PER_SECOND;
delta_tower_angle_trim = dta;
delta_diagonal_rod_trim = ddr;
#if IS_KINEMATIC
segments_per_second = (
TERN_(DELTA, DELTA_SEGMENTS_PER_SECOND)
TERN_(IS_SCARA, SCARA_SEGMENTS_PER_SECOND)
TERN_(POLARGRAPH, POLAR_SEGMENTS_PER_SECOND)
);
#if ENABLED(DELTA)
const abc_float_t adj = DELTA_ENDSTOP_ADJ, dta = DELTA_TOWER_ANGLE_TRIM, ddr = DELTA_DIAGONAL_ROD_TRIM_TOWER;
delta_height = DELTA_HEIGHT;
delta_endstop_adj = adj;
delta_radius = DELTA_RADIUS;
delta_diagonal_rod = DELTA_DIAGONAL_ROD;
delta_tower_angle_trim = dta;
delta_diagonal_rod_trim = ddr;
#endif
#endif
//
// Endstop Adjustments
//
#if ENABLED(X_DUAL_ENDSTOPS)
#ifndef X2_ENDSTOP_ADJUSTMENT
#define X2_ENDSTOP_ADJUSTMENT 0
@ -3137,7 +3162,7 @@ void MarlinSettings::reset() {
TERN_(EDITABLE_SERVO_ANGLES, gcode.M281_report(forReplay));
//
// Delta / SCARA Kinematics
// Kinematic Settings
//
TERN_(IS_KINEMATIC, gcode.M665_report(forReplay));