Prusa MINI Firmware overview
delta.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 /**
25  * delta.h - Delta-specific functions
26  */
27 
28 #include "../core/types.h"
29 
30 extern float delta_height;
32 extern float delta_radius,
37 extern xy_float_t delta_tower[ABC];
39 extern float delta_clip_start_height;
40 
41 /**
42  * Recalculate factors used for delta kinematics whenever
43  * settings have been changed (e.g., by M665).
44  */
46 
47 /**
48  * Delta Inverse Kinematics
49  *
50  * Calculate the tower positions for a given machine
51  * position, storing the result in the delta[] array.
52  *
53  * This is an expensive calculation, requiring 3 square
54  * roots per segmented linear move, and strains the limits
55  * of a Mega2560 with a Graphical Display.
56  *
57  * Suggested optimizations include:
58  *
59  * - Disable the home_offset (M206) and/or position_shift (G92)
60  * features to remove up to 12 float additions.
61  *
62  * - Use a fast-inverse-sqrt function and add the reciprocal.
63  * (see above)
64  */
65 
66 // Macro to obtain the Z position of an individual tower
67 #define DELTA_Z(V,T) V.z + SQRT( \
68  delta_diagonal_rod_2_tower[T] - HYPOT2( \
69  delta_tower[T].x - V.x, \
70  delta_tower[T].y - V.y \
71  ) \
72  )
73 
74 #define DELTA_IK(V) delta.set(DELTA_Z(V, A_AXIS), DELTA_Z(V, B_AXIS), DELTA_Z(V, C_AXIS))
75 
76 void inverse_kinematics(const xyz_pos_t &raw);
77 
78 /**
79  * Calculate the highest Z position where the
80  * effector has the full range of XY motion.
81  */
83 
84 /**
85  * Delta Forward Kinematics
86  *
87  * See the Wikipedia article "Trilateration"
88  * https://en.wikipedia.org/wiki/Trilateration
89  *
90  * Establish a new coordinate system in the plane of the
91  * three carriage points. This system has its origin at
92  * tower1, with tower2 on the X axis. Tower3 is in the X-Y
93  * plane with a Z component of zero.
94  * We will define unit vectors in this coordinate system
95  * in our original coordinate system. Then when we calculate
96  * the Xnew, Ynew and Znew values, we can translate back into
97  * the original system by moving along those unit vectors
98  * by the corresponding values.
99  *
100  * Variable names matched to Marlin, c-version, and avoid the
101  * use of any vector library.
102  *
103  * by Andreas Hardtung 2016-06-07
104  * based on a Java function from "Delta Robot Kinematics V3"
105  * by Steve Graves
106  *
107  * The result is stored in the cartes[] array.
108  */
109 void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3);
110 
112  forward_kinematics_DELTA(point.a, point.b, point.c);
113 }
114 
115 void home_delta();
delta_clip_start_height
float delta_clip_start_height
planner.h
XYZval::z
T z
Definition: types.h:286
endstops.h
delta_segments_per_second
float delta_segments_per_second
XYZval::a
T a
Definition: types.h:287
RSQRT
#define RSQRT(x)
Definition: macros.h:282
sq
#define sq(x)
Definition: wiring_constants.h:83
XYZEval::z
T z
Definition: types.h:383
Planner::synchronize
static void synchronize()
Definition: planner.cpp:1556
XYZval::x
T x
Definition: types.h:286
delta_diagonal_rod_2_tower
abc_float_t delta_diagonal_rod_2_tower
probe_offset
constexpr xyz_pos_t probe_offset
Definition: probe.h:58
indirection.h
X_AXIS
Definition: types.h:37
DELTA_IK
#define DELTA_IK(V)
Definition: delta.h:74
C_AXIS
Definition: types.h:39
Endstops::validate_homing_move
static FORCE_INLINE void validate_homing_move()
Definition: endstops.h:144
set_axis_is_at_home
void set_axis_is_at_home(const AxisEnum axis)
Definition: motion.cpp:1361
HYPOT2
#define HYPOT2(x, y)
Definition: macros.h:100
i
uint8_t i
Definition: screen_test_graph.c:72
AxisEnum
AxisEnum
Definition: types.h:36
destination
xyze_pos_t destination
Definition: motion.cpp:110
motion.h
delta_height
float delta_height
XYZval::set
FI void set(const T px)
Definition: types.h:290
delta_tower
xy_float_t delta_tower[ABC]
delta_endstop_adj
abc_float_t delta_endstop_adj
Z_MAX_POS
#define Z_MAX_POS
Definition: Configuration_A3ides_2209_MINI.h:989
ABS
#define ABS(a)
Definition: macros.h:266
delta.h
delta_diagonal_rod
float delta_diagonal_rod
FORCE_INLINE
#define FORCE_INLINE
Definition: macros.h:40
XYZval::b
T b
Definition: types.h:287
RADIANS
#define RADIANS(d)
Definition: macros.h:98
current_position
xyze_pos_t current_position
Definition: motion.cpp:102
recalc_delta_settings
void recalc_delta_settings()
XYval::set
FI void set(const T px)
Definition: types.h:189
line_to_current_position
void line_to_current_position(const feedRate_t &fr_mm_s)
Definition: motion.cpp:285
cartes
xyz_pos_t cartes
Definition: motion.cpp:152
sync_plan_position
void sync_plan_position()
Definition: motion.cpp:216
LOOP_XYZ
#define LOOP_XYZ(VAR)
Definition: types.h:60
delta_safe_distance_from_top
float delta_safe_distance_from_top()
XYval
Definition: types.h:99
SQRT
#define SQRT(x)
Definition: macros.h:281
XYval::x
T x
Definition: types.h:185
DEBUG_POS
#define DEBUG_POS(...)
Definition: debug_out.h:87
delta_tower_angle_trim
abc_float_t delta_tower_angle_trim
update_software_endstops
void update_software_endstops(const AxisEnum axis)
Definition: motion.cpp:503
XYZval::y
T y
Definition: types.h:286
inverse_kinematics
void inverse_kinematics(const xyz_pos_t &raw)
homing_feedrate
FORCE_INLINE feedRate_t homing_feedrate(const AxisEnum a)
Definition: motion.h:93
hotend_offset
constexpr xyz_pos_t hotend_offset[1]
Definition: motion.h:136
Z_AXIS
Definition: types.h:39
DEBUGGING
#define DEBUGGING(F)
Definition: serial.h:47
A_AXIS
Definition: types.h:37
delta_radius
float delta_radius
XYval::y
T y
Definition: types.h:185
forward_kinematics_DELTA
void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3)
XYZval< float >
homeaxis
void homeaxis(const AxisEnum axis)
Definition: motion.cpp:1449
delta_calibration_radius
float delta_calibration_radius
B_AXIS
Definition: types.h:38
XYZval::c
T c
Definition: types.h:287
probe.h
endstops
Endstops endstops
Definition: endstops.cpp:51
XYZEval::reset
FI void reset()
Definition: types.h:387
active_extruder
constexpr uint8_t active_extruder
Definition: motion.h:107
planner
Planner planner
Definition: planner.cpp:111
home_delta
void home_delta()
ABC
#define ABC
Definition: macros.h:26
set_all_unhomed
FORCE_INLINE void set_all_unhomed()
Definition: motion.h:46