Fork of Smoothie to port to mbed non-LPC targets.
Fork of Smoothie by
Block.h
00001 /* 00002 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 00003 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. 00004 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. 00005 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. 00006 */ 00007 00008 #ifndef BLOCK_H 00009 #define BLOCK_H 00010 #include "libs/Module.h" 00011 #include "libs/Kernel.h" 00012 using namespace std; 00013 #include <string> 00014 #include <vector> 00015 00016 #include "../communication/utils/Gcode.h" 00017 #include "Planner.h" 00018 class Planner; 00019 class Conveyor; 00020 00021 float max_allowable_speed( float acceleration, float target_velocity, float distance); 00022 00023 class Block { 00024 public: 00025 Block(); 00026 void calculate_trapezoid( float entry_speed, float exit_speed ); 00027 float estimate_acceleration_distance( float initial_rate, float target_rate, float acceleration ); 00028 float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance); 00029 float get_duration_left(unsigned int already_taken_steps); 00030 00031 float reverse_pass(float exit_speed); 00032 float forward_pass(float next_entry_speed); 00033 00034 float max_exit_speed(); 00035 00036 void debug(); 00037 00038 void append_gcode(Gcode* gcode); 00039 00040 void take(); 00041 void release(); 00042 00043 void ready(); 00044 00045 void clear(); 00046 00047 void begin(); 00048 00049 //vector<std::string> commands; 00050 //vector<float> travel_distances; 00051 vector<Gcode> gcodes; 00052 00053 unsigned int steps[3]; // Number of steps for each axis for this block 00054 unsigned int steps_event_count; // Steps for the longest axis 00055 unsigned int nominal_rate; // Nominal rate in steps per second 00056 float nominal_speed; // Nominal speed in mm per second 00057 float millimeters; // Distance for this move 00058 float entry_speed; 00059 float exit_speed; 00060 float rate_delta; // Nomber of steps to add to the speed for each acceleration tick 00061 unsigned int initial_rate; // Initial speed in steps per second 00062 unsigned int final_rate; // Final speed in steps per second 00063 unsigned int accelerate_until; // Stop accelerating after this number of steps 00064 unsigned int decelerate_after; // Start decelerating after this number of steps 00065 unsigned int direction_bits; // Direction for each axis in bit form, relative to the direction port's mask 00066 00067 00068 bool recalculate_flag; // Planner flag to recalculate trapezoids on entry junction 00069 bool nominal_length_flag; // Planner flag for nominal speed always reached 00070 00071 float max_entry_speed; 00072 00073 bool is_ready; 00074 00075 short times_taken; // A block can be "taken" by any number of modules, and the next block is not moved to until all the modules have "released" it. This value serves as a tracker. 00076 00077 }; 00078 00079 00080 #endif
Generated on Tue Jul 12 2022 20:09:00 by 1.7.2