Commit | Line | Data |
---|---|---|
df27a6a3 | 1 | /* |
4cff3ded AW |
2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). |
3 | Smoothie 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. | |
4 | Smoothie 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. | |
df27a6a3 | 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
4cff3ded AW |
6 | */ |
7 | ||
8a9f9313 | 8 | #pragma once |
61134a65 | 9 | |
4cff3ded | 10 | #include <vector> |
558e170c | 11 | #include <bitset> |
807b9b57 | 12 | #include "ActuatorCoordinates.h" |
3a4fa0c1 | 13 | |
4cff3ded AW |
14 | class Block { |
15 | public: | |
16 | Block(); | |
a617ac35 | 17 | void calculate_trapezoid( float entry_speed, float exit_speed ); |
558e170c | 18 | float max_allowable_speed( float acceleration, float target_velocity, float distance); |
2134bcf2 | 19 | |
a617ac35 MM |
20 | float reverse_pass(float exit_speed); |
21 | float forward_pass(float next_entry_speed); | |
a617ac35 | 22 | float max_exit_speed(); |
433d636f | 23 | void debug() const; |
433d636f | 24 | void ready() { is_ready= true; } |
1cf31736 | 25 | void clear(); |
f6542ad9 | 26 | void prepare(); |
702023f3 | 27 | |
1b5776bf JM |
28 | std::array<uint32_t, k_max_actuators> steps; // Number of steps for each axis for this block |
29 | uint32_t steps_event_count; // Steps for the longest axis | |
1598a726 | 30 | float nominal_rate; // Nominal rate in steps per second |
1b5776bf JM |
31 | float nominal_speed; // Nominal speed in mm per second |
32 | float millimeters; // Distance for this move | |
33 | float entry_speed; | |
f6542ad9 | 34 | float exit_speed; |
1b5776bf | 35 | float acceleration; // the acceleratoin for this block |
1598a726 | 36 | float initial_rate; // Initial rate in steps per second |
8b260c2c JM |
37 | float maximum_rate; |
38 | ||
39 | float acceleration_per_tick{0}; | |
40 | float deceleration_per_tick {0}; | |
aab6cbba | 41 | |
4fdd2470 JM |
42 | float max_entry_speed; |
43 | ||
f6542ad9 JM |
44 | // this is tick info needed for this block. applies to all motors |
45 | uint32_t accelerate_until; | |
46 | uint32_t decelerate_after; | |
47 | uint32_t total_move_ticks; | |
807b9b57 | 48 | std::bitset<k_max_actuators> direction_bits; // Direction for each axis in bit form, relative to the direction port's mask |
f6542ad9 JM |
49 | |
50 | // this is the data needed to determine when each motor needs to be issued a step | |
51 | using tickinfo_t= struct { | |
52 | int32_t steps_per_tick; // 2.30 fixed point | |
53 | int32_t counter; // 2.30 fixed point | |
54 | int32_t acceleration_change; // 2.30 fixed point signed | |
55 | int32_t deceleration_change; // 2.30 fixed point | |
56 | int32_t plateau_rate; // 2.30 fixed point | |
57 | uint32_t steps_to_move; | |
58 | uint32_t step_count; | |
59 | uint32_t next_accel_event; | |
60 | }; | |
61 | ||
62 | // need info for each active motor | |
8a9f9313 JM |
63 | //std::array<tickinfo_t, k_max_actuators> tick_info; |
64 | std::vector<tickinfo_t> tick_info; | |
65 | static uint8_t n_actuators; | |
f6542ad9 | 66 | |
558e170c JM |
67 | struct { |
68 | bool recalculate_flag:1; // Planner flag to recalculate trapezoids on entry junction | |
69 | bool nominal_length_flag:1; // Planner flag for nominal speed always reached | |
70 | bool is_ready:1; | |
f6542ad9 JM |
71 | volatile bool is_ticking:1; // set when this block is being actively ticked by the stepticker |
72 | volatile bool locked:1; // set to true when the critical data is being updated, stepticker will have to skip if this is set | |
558e170c | 73 | }; |
4cff3ded | 74 | }; |