|
@@ -1,93 +1,96 @@
|
1
|
|
-/*
|
2
|
|
- planner.h - buffers movement commands and manages the acceleration profile plan
|
3
|
|
- Part of Grbl
|
4
|
|
-
|
5
|
|
- Copyright (c) 2009-2011 Simen Svale Skogsrud
|
6
|
|
-
|
7
|
|
- Grbl is free software: you can redistribute it and/or modify
|
8
|
|
- it under the terms of the GNU General Public License as published by
|
9
|
|
- the Free Software Foundation, either version 3 of the License, or
|
10
|
|
- (at your option) any later version.
|
11
|
|
-
|
12
|
|
- Grbl is distributed in the hope that it will be useful,
|
13
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
|
- GNU General Public License for more details.
|
16
|
|
-
|
17
|
|
- You should have received a copy of the GNU General Public License
|
18
|
|
- along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
19
|
|
-*/
|
20
|
|
-
|
21
|
|
-// This module is to be considered a sub-module of stepper.c. Please don't include
|
22
|
|
-// this file from any other module.
|
23
|
|
-
|
24
|
|
-#ifndef planner_h
|
25
|
|
-#define planner_h
|
26
|
|
-
|
27
|
|
-#include "Configuration.h"
|
28
|
|
-
|
29
|
|
-// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
|
30
|
|
-// the source g-code and may never actually be reached if acceleration management is active.
|
31
|
|
-typedef struct {
|
32
|
|
- // Fields used by the bresenham algorithm for tracing the line
|
33
|
|
- long steps_x, steps_y, steps_z, steps_e; // Step count along each axis
|
34
|
|
- long step_event_count; // The number of step events required to complete this block
|
35
|
|
- volatile long accelerate_until; // The index of the step event on which to stop acceleration
|
36
|
|
- volatile long decelerate_after; // The index of the step event on which to start decelerating
|
37
|
|
- volatile long acceleration_rate; // The acceleration rate used for acceleration calculation
|
38
|
|
- unsigned char direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
|
39
|
|
- #ifdef ADVANCE
|
40
|
|
- long advance_rate;
|
41
|
|
- volatile long initial_advance;
|
42
|
|
- volatile long final_advance;
|
43
|
|
- float advance;
|
44
|
|
- #endif
|
45
|
|
-
|
46
|
|
- // Fields used by the motion planner to manage acceleration
|
47
|
|
- float speed_x, speed_y, speed_z, speed_e; // Nominal mm/minute for each axis
|
48
|
|
- float nominal_speed; // The nominal speed for this block in mm/min
|
49
|
|
- float millimeters; // The total travel of this block in mm
|
50
|
|
- float entry_speed;
|
51
|
|
- float acceleration; // acceleration mm/sec^2
|
52
|
|
-
|
53
|
|
- // Settings for the trapezoid generator
|
54
|
|
- long nominal_rate; // The nominal step rate for this block in step_events/sec
|
55
|
|
- volatile long initial_rate; // The jerk-adjusted step rate at start of block
|
56
|
|
- volatile long final_rate; // The minimal rate at exit
|
57
|
|
- long acceleration_st; // acceleration steps/sec^2
|
58
|
|
- volatile char busy;
|
59
|
|
-} block_t;
|
60
|
|
-
|
61
|
|
-// Initialize the motion plan subsystem
|
62
|
|
-void plan_init();
|
63
|
|
-
|
64
|
|
-// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in
|
65
|
|
-// millimaters. Feed rate specifies the speed of the motion.
|
66
|
|
-void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate);
|
67
|
|
-
|
68
|
|
-// Set position. Used for G92 instructions.
|
69
|
|
-void plan_set_position(const float &x, const float &y, const float &z, const float &e);
|
70
|
|
-
|
71
|
|
-
|
72
|
|
-// Called when the current block is no longer needed. Discards the block and makes the memory
|
73
|
|
-// availible for new blocks.
|
74
|
|
-void plan_discard_current_block();
|
75
|
|
-
|
76
|
|
-// Gets the current block. Returns NULL if buffer empty
|
77
|
|
-block_t *plan_get_current_block();
|
78
|
|
-
|
79
|
|
-void check_axes_activity();
|
80
|
|
-
|
81
|
|
-extern unsigned long minsegmenttime;
|
82
|
|
-extern float max_feedrate[4]; // set the max speeds
|
83
|
|
-extern float axis_steps_per_unit[4];
|
84
|
|
-extern long max_acceleration_units_per_sq_second[4]; // Use M201 to override by software
|
85
|
|
-extern float minimumfeedrate;
|
86
|
|
-extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
|
87
|
|
-extern float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
|
88
|
|
-extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
|
89
|
|
-extern float max_z_jerk;
|
90
|
|
-extern float mintravelfeedrate;
|
91
|
|
-extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
92
|
|
-
|
|
1
|
+/*
|
|
2
|
+ planner.h - buffers movement commands and manages the acceleration profile plan
|
|
3
|
+ Part of Grbl
|
|
4
|
+
|
|
5
|
+ Copyright (c) 2009-2011 Simen Svale Skogsrud
|
|
6
|
+
|
|
7
|
+ Grbl is free software: you can redistribute it and/or modify
|
|
8
|
+ it under the terms of the GNU General Public License as published by
|
|
9
|
+ the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+ (at your option) any later version.
|
|
11
|
+
|
|
12
|
+ Grbl is distributed in the hope that it will be useful,
|
|
13
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+ GNU General Public License for more details.
|
|
16
|
+
|
|
17
|
+ You should have received a copy of the GNU General Public License
|
|
18
|
+ along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
+*/
|
|
20
|
+
|
|
21
|
+// This module is to be considered a sub-module of stepper.c. Please don't include
|
|
22
|
+// this file from any other module.
|
|
23
|
+
|
|
24
|
+#ifndef planner_h
|
|
25
|
+#define planner_h
|
|
26
|
+
|
|
27
|
+#include "Configuration.h"
|
|
28
|
+
|
|
29
|
+// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
|
|
30
|
+// the source g-code and may never actually be reached if acceleration management is active.
|
|
31
|
+typedef struct {
|
|
32
|
+ // Fields used by the bresenham algorithm for tracing the line
|
|
33
|
+ long steps_x, steps_y, steps_z, steps_e; // Step count along each axis
|
|
34
|
+ long step_event_count; // The number of step events required to complete this block
|
|
35
|
+ volatile long accelerate_until; // The index of the step event on which to stop acceleration
|
|
36
|
+ volatile long decelerate_after; // The index of the step event on which to start decelerating
|
|
37
|
+ volatile long acceleration_rate; // The acceleration rate used for acceleration calculation
|
|
38
|
+ unsigned char direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
|
|
39
|
+ #ifdef ADVANCE
|
|
40
|
+// long advance_rate;
|
|
41
|
+// volatile long initial_advance;
|
|
42
|
+// volatile long final_advance;
|
|
43
|
+// float advance;
|
|
44
|
+ #endif
|
|
45
|
+
|
|
46
|
+ // Fields used by the motion planner to manage acceleration
|
|
47
|
+// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/minute for each axis
|
|
48
|
+ float nominal_speed; // The nominal speed for this block in mm/min
|
|
49
|
+ float entry_speed; // Entry speed at previous-current junction in mm/min
|
|
50
|
+ float max_entry_speed; // Maximum allowable junction entry speed in mm/min
|
|
51
|
+ float millimeters; // The total travel of this block in mm
|
|
52
|
+ float acceleration; // acceleration mm/sec^2
|
|
53
|
+ unsigned char recalculate_flag; // Planner flag to recalculate trapezoids on entry junction
|
|
54
|
+ unsigned char nominal_length_flag; // Planner flag for nominal speed always reached
|
|
55
|
+
|
|
56
|
+ // Settings for the trapezoid generator
|
|
57
|
+ long nominal_rate; // The nominal step rate for this block in step_events/sec
|
|
58
|
+ volatile long initial_rate; // The jerk-adjusted step rate at start of block
|
|
59
|
+ volatile long final_rate; // The minimal rate at exit
|
|
60
|
+ long acceleration_st; // acceleration steps/sec^2
|
|
61
|
+ volatile char busy;
|
|
62
|
+} block_t;
|
|
63
|
+
|
|
64
|
+// Initialize the motion plan subsystem
|
|
65
|
+void plan_init();
|
|
66
|
+
|
|
67
|
+// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in
|
|
68
|
+// millimaters. Feed rate specifies the speed of the motion.
|
|
69
|
+void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate);
|
|
70
|
+
|
|
71
|
+// Set position. Used for G92 instructions.
|
|
72
|
+void plan_set_position(const float &x, const float &y, const float &z, const float &e);
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+// Called when the current block is no longer needed. Discards the block and makes the memory
|
|
76
|
+// availible for new blocks.
|
|
77
|
+void plan_discard_current_block();
|
|
78
|
+
|
|
79
|
+// Gets the current block. Returns NULL if buffer empty
|
|
80
|
+block_t *plan_get_current_block();
|
|
81
|
+
|
|
82
|
+void check_axes_activity();
|
|
83
|
+
|
|
84
|
+extern unsigned long minsegmenttime;
|
|
85
|
+extern float max_feedrate[4]; // set the max speeds
|
|
86
|
+extern float axis_steps_per_unit[4];
|
|
87
|
+extern long max_acceleration_units_per_sq_second[4]; // Use M201 to override by software
|
|
88
|
+extern float minimumfeedrate;
|
|
89
|
+extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
|
|
90
|
+extern float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
|
|
91
|
+extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
|
|
92
|
+extern float max_z_jerk;
|
|
93
|
+extern float mintravelfeedrate;
|
|
94
|
+extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
|
95
|
+
|
93
|
96
|
#endif
|