Michael Spencer / Smoothie

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Committer:
Michael J. Spencer
Date:
Fri Feb 28 18:52:52 2014 -0800
Revision:
2:1df0b61d3b5a
Parent:
0:31e91bb0ef3c
Update to latest Smoothie.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Michael J. Spencer 2:1df0b61d3b5a 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.
Michael J. Spencer 2:1df0b61d3b5a 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;
Michael J. Spencer 2:1df0b61d3b5a 19 class Conveyor;
scachat 0:31e91bb0ef3c 20
Michael J. Spencer 2:1df0b61d3b5a 21 float max_allowable_speed( float acceleration, float target_velocity, float distance);
scachat 0:31e91bb0ef3c 22
scachat 0:31e91bb0ef3c 23 class Block {
scachat 0:31e91bb0ef3c 24 public:
scachat 0:31e91bb0ef3c 25 Block();
Michael J. Spencer 2:1df0b61d3b5a 26 void calculate_trapezoid( float entry_speed, float exit_speed );
Michael J. Spencer 2:1df0b61d3b5a 27 float estimate_acceleration_distance( float initial_rate, float target_rate, float acceleration );
Michael J. Spencer 2:1df0b61d3b5a 28 float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance);
Michael J. Spencer 2:1df0b61d3b5a 29 float get_duration_left(unsigned int already_taken_steps);
Michael J. Spencer 2:1df0b61d3b5a 30
Michael J. Spencer 2:1df0b61d3b5a 31 float reverse_pass(float exit_speed);
Michael J. Spencer 2:1df0b61d3b5a 32 float forward_pass(float next_entry_speed);
Michael J. Spencer 2:1df0b61d3b5a 33
Michael J. Spencer 2:1df0b61d3b5a 34 float max_exit_speed();
Michael J. Spencer 2:1df0b61d3b5a 35
Michael J. Spencer 2:1df0b61d3b5a 36 void debug();
Michael J. Spencer 2:1df0b61d3b5a 37
scachat 0:31e91bb0ef3c 38 void append_gcode(Gcode* gcode);
Michael J. Spencer 2:1df0b61d3b5a 39
scachat 0:31e91bb0ef3c 40 void take();
scachat 0:31e91bb0ef3c 41 void release();
Michael J. Spencer 2:1df0b61d3b5a 42
scachat 0:31e91bb0ef3c 43 void ready();
scachat 0:31e91bb0ef3c 44
Michael J. Spencer 2:1df0b61d3b5a 45 void clear();
Michael J. Spencer 2:1df0b61d3b5a 46
Michael J. Spencer 2:1df0b61d3b5a 47 void begin();
Michael J. Spencer 2:1df0b61d3b5a 48
Michael J. Spencer 2:1df0b61d3b5a 49 //vector<std::string> commands;
Michael J. Spencer 2:1df0b61d3b5a 50 //vector<float> travel_distances;
scachat 0:31e91bb0ef3c 51 vector<Gcode> gcodes;
Michael J. Spencer 2:1df0b61d3b5a 52
scachat 0:31e91bb0ef3c 53 unsigned int steps[3]; // Number of steps for each axis for this block
scachat 0:31e91bb0ef3c 54 unsigned int steps_event_count; // Steps for the longest axis
Michael J. Spencer 2:1df0b61d3b5a 55 unsigned int nominal_rate; // Nominal rate in steps per second
Michael J. Spencer 2:1df0b61d3b5a 56 float nominal_speed; // Nominal speed in mm per second
scachat 0:31e91bb0ef3c 57 float millimeters; // Distance for this move
Michael J. Spencer 2:1df0b61d3b5a 58 float entry_speed;
Michael J. Spencer 2:1df0b61d3b5a 59 float exit_speed;
Michael J. Spencer 2:1df0b61d3b5a 60 float rate_delta; // Nomber of steps to add to the speed for each acceleration tick
Michael J. Spencer 2:1df0b61d3b5a 61 unsigned int initial_rate; // Initial speed in steps per second
Michael J. Spencer 2:1df0b61d3b5a 62 unsigned int final_rate; // Final speed in steps per second
scachat 0:31e91bb0ef3c 63 unsigned int accelerate_until; // Stop accelerating after this number of steps
scachat 0:31e91bb0ef3c 64 unsigned int decelerate_after; // Start decelerating after this number of steps
scachat 0:31e91bb0ef3c 65 unsigned int direction_bits; // Direction for each axis in bit form, relative to the direction port's mask
scachat 0:31e91bb0ef3c 66
scachat 0:31e91bb0ef3c 67
Michael J. Spencer 2:1df0b61d3b5a 68 bool recalculate_flag; // Planner flag to recalculate trapezoids on entry junction
Michael J. Spencer 2:1df0b61d3b5a 69 bool nominal_length_flag; // Planner flag for nominal speed always reached
scachat 0:31e91bb0ef3c 70
Michael J. Spencer 2:1df0b61d3b5a 71 float max_entry_speed;
Michael J. Spencer 2:1df0b61d3b5a 72
scachat 0:31e91bb0ef3c 73 bool is_ready;
scachat 0:31e91bb0ef3c 74
Michael J. Spencer 2:1df0b61d3b5a 75 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 76
scachat 0:31e91bb0ef3c 77 };
scachat 0:31e91bb0ef3c 78
scachat 0:31e91bb0ef3c 79
scachat 0:31e91bb0ef3c 80 #endif