smoothie port to mbed online compiler (smoothieware.org)
For documentation, license, ..., please check http://smoothieware.org/
This version has been tested with a 3 axis machine
modules/robot/Block.h@0:31e91bb0ef3c, 2012-07-31 (annotated)
- Committer:
- scachat
- Date:
- Tue Jul 31 21:11:18 2012 +0000
- Revision:
- 0:31e91bb0ef3c
smoothie port to mbed online compiler
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scachat | 0:31e91bb0ef3c | 1 | /* |
scachat | 0:31e91bb0ef3c | 2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). |
scachat | 0:31e91bb0ef3c | 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. |
scachat | 0:31e91bb0ef3c | 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. |
scachat | 0:31e91bb0ef3c | 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
scachat | 0:31e91bb0ef3c | 6 | */ |
scachat | 0:31e91bb0ef3c | 7 | |
scachat | 0:31e91bb0ef3c | 8 | #ifndef BLOCK_H |
scachat | 0:31e91bb0ef3c | 9 | #define BLOCK_H |
scachat | 0:31e91bb0ef3c | 10 | #include "libs/Module.h" |
scachat | 0:31e91bb0ef3c | 11 | #include "libs/Kernel.h" |
scachat | 0:31e91bb0ef3c | 12 | using namespace std; |
scachat | 0:31e91bb0ef3c | 13 | #include <string> |
scachat | 0:31e91bb0ef3c | 14 | #include <vector> |
scachat | 0:31e91bb0ef3c | 15 | |
scachat | 0:31e91bb0ef3c | 16 | #include "../communication/utils/Gcode.h" |
scachat | 0:31e91bb0ef3c | 17 | #include "Planner.h" |
scachat | 0:31e91bb0ef3c | 18 | class Planner; |
scachat | 0:31e91bb0ef3c | 19 | class Player; |
scachat | 0:31e91bb0ef3c | 20 | |
scachat | 0:31e91bb0ef3c | 21 | double max_allowable_speed( double acceleration, double target_velocity, double distance); |
scachat | 0:31e91bb0ef3c | 22 | |
scachat | 0:31e91bb0ef3c | 23 | class Block { |
scachat | 0:31e91bb0ef3c | 24 | public: |
scachat | 0:31e91bb0ef3c | 25 | Block(); |
scachat | 0:31e91bb0ef3c | 26 | double compute_factor_for_safe_speed(); |
scachat | 0:31e91bb0ef3c | 27 | void calculate_trapezoid( double entry_factor, double exit_factor ); |
scachat | 0:31e91bb0ef3c | 28 | double estimate_acceleration_distance( double initial_rate, double target_rate, double acceleration ); |
scachat | 0:31e91bb0ef3c | 29 | double intersection_distance(double initial_rate, double final_rate, double acceleration, double distance); |
scachat | 0:31e91bb0ef3c | 30 | void reverse_pass(Block* previous, Block* next); |
scachat | 0:31e91bb0ef3c | 31 | void forward_pass(Block* previous, Block* next); |
scachat | 0:31e91bb0ef3c | 32 | void debug(Kernel* kernel); |
scachat | 0:31e91bb0ef3c | 33 | void append_gcode(Gcode* gcode); |
scachat | 0:31e91bb0ef3c | 34 | void pop_and_execute_gcode(Kernel* &kernel); |
scachat | 0:31e91bb0ef3c | 35 | double get_duration_left(unsigned int already_taken_steps); |
scachat | 0:31e91bb0ef3c | 36 | void take(); |
scachat | 0:31e91bb0ef3c | 37 | void release(); |
scachat | 0:31e91bb0ef3c | 38 | void ready(); |
scachat | 0:31e91bb0ef3c | 39 | |
scachat | 0:31e91bb0ef3c | 40 | vector<std::string> commands; |
scachat | 0:31e91bb0ef3c | 41 | vector<double> travel_distances; |
scachat | 0:31e91bb0ef3c | 42 | vector<Gcode> gcodes; |
scachat | 0:31e91bb0ef3c | 43 | |
scachat | 0:31e91bb0ef3c | 44 | unsigned int steps[3]; // Number of steps for each axis for this block |
scachat | 0:31e91bb0ef3c | 45 | unsigned int steps_event_count; // Steps for the longest axis |
scachat | 0:31e91bb0ef3c | 46 | unsigned int nominal_rate; // Nominal rate in steps per minute |
scachat | 0:31e91bb0ef3c | 47 | float nominal_speed; // Nominal speed in mm per minute |
scachat | 0:31e91bb0ef3c | 48 | float millimeters; // Distance for this move |
scachat | 0:31e91bb0ef3c | 49 | double entry_speed; |
scachat | 0:31e91bb0ef3c | 50 | unsigned int rate_delta; // Nomber of steps to add to the speed for each acceleration tick |
scachat | 0:31e91bb0ef3c | 51 | int initial_rate; // Initial speed in steps per minute |
scachat | 0:31e91bb0ef3c | 52 | int final_rate; // Final speed in steps per minute |
scachat | 0:31e91bb0ef3c | 53 | unsigned int accelerate_until; // Stop accelerating after this number of steps |
scachat | 0:31e91bb0ef3c | 54 | unsigned int decelerate_after; // Start decelerating after this number of steps |
scachat | 0:31e91bb0ef3c | 55 | unsigned int direction_bits; // Direction for each axis in bit form, relative to the direction port's mask |
scachat | 0:31e91bb0ef3c | 56 | |
scachat | 0:31e91bb0ef3c | 57 | |
scachat | 0:31e91bb0ef3c | 58 | uint8_t recalculate_flag; // Planner flag to recalculate trapezoids on entry junction |
scachat | 0:31e91bb0ef3c | 59 | uint8_t nominal_length_flag; // Planner flag for nominal speed always reached |
scachat | 0:31e91bb0ef3c | 60 | |
scachat | 0:31e91bb0ef3c | 61 | double max_entry_speed; |
scachat | 0:31e91bb0ef3c | 62 | Planner* planner; |
scachat | 0:31e91bb0ef3c | 63 | Player* player; |
scachat | 0:31e91bb0ef3c | 64 | |
scachat | 0:31e91bb0ef3c | 65 | bool is_ready; |
scachat | 0:31e91bb0ef3c | 66 | |
scachat | 0:31e91bb0ef3c | 67 | 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. |
scachat | 0:31e91bb0ef3c | 68 | |
scachat | 0:31e91bb0ef3c | 69 | }; |
scachat | 0:31e91bb0ef3c | 70 | |
scachat | 0:31e91bb0ef3c | 71 | |
scachat | 0:31e91bb0ef3c | 72 | |
scachat | 0:31e91bb0ef3c | 73 | |
scachat | 0:31e91bb0ef3c | 74 | |
scachat | 0:31e91bb0ef3c | 75 | |
scachat | 0:31e91bb0ef3c | 76 | |
scachat | 0:31e91bb0ef3c | 77 | |
scachat | 0:31e91bb0ef3c | 78 | |
scachat | 0:31e91bb0ef3c | 79 | |
scachat | 0:31e91bb0ef3c | 80 | |
scachat | 0:31e91bb0ef3c | 81 | #endif |