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.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
11 #include "ActuatorCoordinates.h"
17 static void init(uint8_t);
19 void calculate_trapezoid( float entry_speed
, float exit_speed
);
21 float reverse_pass(float exit_speed
);
22 float forward_pass(float next_entry_speed
);
23 float max_exit_speed();
25 void ready() { is_ready
= true; }
27 float get_trapezoid_rate(int i
) const;
30 float max_allowable_speed( float acceleration
, float target_velocity
, float distance
);
31 void prepare(float acceleration_in_steps
, float deceleration_in_steps
);
33 static double fp_scale
; // optimize to store this as it does not change
36 std::array
<uint32_t, k_max_actuators
> steps
; // Number of steps for each axis for this block
37 uint32_t steps_event_count
; // Steps for the longest axis
38 float nominal_rate
; // Nominal rate in steps per second
39 float nominal_speed
; // Nominal speed in mm per second
40 float millimeters
; // Distance for this move
43 float acceleration
; // the acceleration for this block
44 float initial_rate
; // Initial rate in steps per second
47 float max_entry_speed
;
49 // this is tick info needed for this block. applies to all motors
50 uint32_t accelerate_until
;
51 uint32_t decelerate_after
;
52 uint32_t total_move_ticks
;
53 std::bitset
<k_max_actuators
> direction_bits
; // Direction for each axis in bit form, relative to the direction port's mask
55 // this is the data needed to determine when each motor needs to be issued a step
56 using tickinfo_t
= struct {
57 int64_t steps_per_tick
; // 2.62 fixed point
58 int64_t counter
; // 2.62 fixed point
59 int64_t acceleration_change
; // 2.62 fixed point signed
60 int64_t deceleration_change
; // 2.62 fixed point
61 int64_t plateau_rate
; // 2.62 fixed point
62 uint32_t steps_to_move
;
64 uint32_t next_accel_event
;
67 // need info for each active motor
68 tickinfo_t
*tick_info
;
70 static uint8_t n_actuators
;
73 bool recalculate_flag
:1; // Planner flag to recalculate trapezoids on entry junction
74 bool nominal_length_flag
:1; // Planner flag for nominal speed always reached
76 bool primary_axis
:1; // set if this move is a primary axis
77 bool is_g123
:1; // set if this is a G1, G2 or G3
78 volatile bool is_ticking
:1; // set when this block is being actively ticked by the stepticker
79 volatile bool locked
:1; // set to true when the critical data is being updated, stepticker will have to skip if this is set
80 uint16_t s_value
:12; // for laser 1.11 Fixed point