grblHAL core  20240704
motion_control.h
Go to the documentation of this file.
1 /*
2  motion_control.h - high level interface for issuing motion commands
3 
4  Part of grblHAL
5 
6  Copyright (c) 2017-2023 Terje Io
7  Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
8  Copyright (c) 2009-2011 Simen Svale Skogsrud
9 
10  Grbl is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  Grbl is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with Grbl. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef _MOTION_CONTROL_H_
25 #define _MOTION_CONTROL_H_
26 
27 // System motion commands must have a line number of zero.
28 #define DEFAULT_HOMING_CYCLE_LINE_NUMBER 0
29 #define PARKING_MOTION_LINE_NUMBER 0
30 
31 #define DEFAULT_HOMING_CYCLE_ALL 0 // Must be zero.
32 #define DEFAULT_HOMING_CYCLE_X bit(X_AXIS)
33 #define DEFAULT_HOMING_CYCLE_Y bit(Y_AXIS)
34 #define DEFAULT_HOMING_CYCLE_Z bit(Z_AXIS)
35 
36 // Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second
37 // unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in
38 // (1 minute)/feed_rate time.
39 bool mc_line(float *target, plan_line_data_t *pl_data);
40 
41 // Execute an arc in offset mode format. position == current xyz, target == target xyz,
42 // offset == offset from current xyz, axis_XXX defines circle plane in tool space, axis_linear is
43 // the direction of helical travel, radius == circle radius, is_clockwise_arc boolean. Used
44 // for vector transformation direction.
45 void mc_arc(float *target, plan_line_data_t *pl_data, float *position, float *offset, float radius,
46  plane_t plane, int32_t turns);
47 
48 // Execute canned cycle (drill)
49 void mc_canned_drill (motion_mode_t motion, float *target, plan_line_data_t *pl_data, float *position, plane_t plane, uint32_t repeats, gc_canned_t *canned);
50 
51 // Execute canned cycle (threading)
52 void mc_thread (plan_line_data_t *pl_data, float *position, gc_thread_data *thread, bool feed_hold_disabled);
53 
54 // Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog.
55 status_code_t mc_jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block, float *position);
56 
57 // Dwell for a specific number of seconds
58 void mc_dwell(float seconds);
59 
60 // Perform homing cycle to locate machine zero. Requires limit switches.
61 status_code_t mc_homing_cycle(axes_signals_t cycle);
62 
63 // Perform tool length probe cycle. Requires probe switch.
64 gc_probe_t mc_probe_cycle(float *target, plan_line_data_t *pl_data, gc_parser_flags_t parser_flags);
65 
66 // Handles updating the override control state.
67 void mc_override_ctrl_update(gc_override_flags_t override_state);
68 
69 // Plans and executes the single special motion case for parking. Independent of main planner buffer.
70 bool mc_parking_motion(float *parking_target, plan_line_data_t *pl_data);
71 
72 void mc_cubic_b_spline(float *target, plan_line_data_t *pl_data, float *position, float *offset1, float *offset2);
73 
74 // Performs system reset. If in motion state, kills all motion and sets system alarm.
75 void mc_reset (void);
76 
77 #if ENABLE_BACKLASH_COMPENSATION
78 void mc_backlash_init (axes_signals_t axes);
79 void mc_sync_backlash_position (void);
80 #endif
81 
82 #endif
motion_mode_t
Definition: gcode.h:78
gc_probe_t
Definition: gcode.h:299
status_code_t mc_homing_cycle(axes_signals_t cycle)
Definition: motion_control.c:821
void mc_reset(void)
Definition: motion_control.c:1114
bool mc_line(float *target, plan_line_data_t *pl_data)
Definition: motion_control.c:78
bool mc_parking_motion(float *parking_target, plan_line_data_t *pl_data)
Definition: motion_control.c:1083
void mc_override_ctrl_update(gc_override_flags_t override_state)
Definition: motion_control.c:1101
void mc_thread(plan_line_data_t *pl_data, float *position, gc_thread_data *thread, bool feed_hold_disabled)
Definition: motion_control.c:660
void mc_canned_drill(motion_mode_t motion, float *target, plan_line_data_t *pl_data, float *position, plane_t plane, uint32_t repeats, gc_canned_t *canned)
Definition: motion_control.c:562
status_code_t mc_jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block, float *position)
Definition: motion_control.c:778
void mc_arc(float *target, plan_line_data_t *pl_data, float *position, float *offset, float radius, plane_t plane, int32_t turns)
Definition: motion_control.c:209
void mc_cubic_b_spline(float *target, plan_line_data_t *pl_data, float *position, float *offset1, float *offset2)
Definition: motion_control.c:472
void mc_dwell(float seconds)
Definition: motion_control.c:810
gc_probe_t mc_probe_cycle(float *target, plan_line_data_t *pl_data, gc_parser_flags_t parser_flags)
Definition: motion_control.c:971
Data for canned cycles.
Definition: gcode.h:516
Definition: gcode.h:535
Parser block structure.
Definition: gcode.h:613
Definition: planner.h:87
Definition: nuts_bolts.h:130
Override flags.
Definition: gcode.h:330
Parser flags for special cases.
Definition: gcode.h:312
Axis index to plane assignment.
Definition: gcode.h:374