smoothie port to mbed online compiler (smoothieware.org)

Dependencies:   mbed

For documentation, license, ..., please check http://smoothieware.org/

This version has been tested with a 3 axis machine

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?

UserRevisionLine numberNew 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 ROBOT_H
scachat 0:31e91bb0ef3c 9 #define ROBOT_H
scachat 0:31e91bb0ef3c 10
scachat 0:31e91bb0ef3c 11 #include <string>
scachat 0:31e91bb0ef3c 12 using std::string;
scachat 0:31e91bb0ef3c 13 #include "libs/Module.h"
scachat 0:31e91bb0ef3c 14 #include "libs/Kernel.h"
scachat 0:31e91bb0ef3c 15 #include "../communication/utils/Gcode.h"
scachat 0:31e91bb0ef3c 16 #include "arm_solutions/BaseSolution.h"
scachat 0:31e91bb0ef3c 17 #include "Planner.h"
scachat 0:31e91bb0ef3c 18
scachat 0:31e91bb0ef3c 19 #define default_seek_rate_checksum 6633
scachat 0:31e91bb0ef3c 20 #define default_feed_rate_checksum 47357
scachat 0:31e91bb0ef3c 21 #define mm_per_line_segment_checksum 30176
scachat 0:31e91bb0ef3c 22 #define mm_per_arc_segment_checksum 15470
scachat 0:31e91bb0ef3c 23 #define arc_correction_checksum 5074
scachat 0:31e91bb0ef3c 24 #define x_axis_max_speed_checksum 64935
scachat 0:31e91bb0ef3c 25 #define y_axis_max_speed_checksum 3752
scachat 0:31e91bb0ef3c 26 #define z_axis_max_speed_checksum 7849
scachat 0:31e91bb0ef3c 27
scachat 0:31e91bb0ef3c 28 #define NEXT_ACTION_DEFAULT 0
scachat 0:31e91bb0ef3c 29 #define NEXT_ACTION_DWELL 1
scachat 0:31e91bb0ef3c 30 #define NEXT_ACTION_GO_HOME 2
scachat 0:31e91bb0ef3c 31
scachat 0:31e91bb0ef3c 32 #define MOTION_MODE_SEEK 0 // G0
scachat 0:31e91bb0ef3c 33 #define MOTION_MODE_LINEAR 1 // G1
scachat 0:31e91bb0ef3c 34 #define MOTION_MODE_CW_ARC 2 // G2
scachat 0:31e91bb0ef3c 35 #define MOTION_MODE_CCW_ARC 3 // G3
scachat 0:31e91bb0ef3c 36 #define MOTION_MODE_CANCEL 4 // G80
scachat 0:31e91bb0ef3c 37
scachat 0:31e91bb0ef3c 38 #define PATH_CONTROL_MODE_EXACT_PATH 0
scachat 0:31e91bb0ef3c 39 #define PATH_CONTROL_MODE_EXACT_STOP 1
scachat 0:31e91bb0ef3c 40 #define PATH_CONTROL_MODE_CONTINOUS 2
scachat 0:31e91bb0ef3c 41
scachat 0:31e91bb0ef3c 42 #define PROGRAM_FLOW_RUNNING 0
scachat 0:31e91bb0ef3c 43 #define PROGRAM_FLOW_PAUSED 1
scachat 0:31e91bb0ef3c 44 #define PROGRAM_FLOW_COMPLETED 2
scachat 0:31e91bb0ef3c 45
scachat 0:31e91bb0ef3c 46 #define SPINDLE_DIRECTION_CW 0
scachat 0:31e91bb0ef3c 47 #define SPINDLE_DIRECTION_CCW 1
scachat 0:31e91bb0ef3c 48
scachat 0:31e91bb0ef3c 49 #define M_PI 3.14159
scachat 0:31e91bb0ef3c 50
scachat 0:31e91bb0ef3c 51
scachat 0:31e91bb0ef3c 52 class Robot : public Module {
scachat 0:31e91bb0ef3c 53 public:
scachat 0:31e91bb0ef3c 54 Robot();
scachat 0:31e91bb0ef3c 55 virtual void on_module_loaded();
scachat 0:31e91bb0ef3c 56 virtual void on_config_reload(void* argument);
scachat 0:31e91bb0ef3c 57 virtual void on_gcode_received(void* argument);
scachat 0:31e91bb0ef3c 58 void execute_gcode(Gcode* gcode);
scachat 0:31e91bb0ef3c 59 void append_milestone( double target[], double feed_rate);
scachat 0:31e91bb0ef3c 60 void append_line( Gcode* gcode, double target[], double feed_rate);
scachat 0:31e91bb0ef3c 61 //void append_arc(double theta_start, double angular_travel, double radius, double depth, double rate);
scachat 0:31e91bb0ef3c 62 void append_arc( Gcode* gcode, double target[], double offset[], double radius, bool is_clockwise );
scachat 0:31e91bb0ef3c 63
scachat 0:31e91bb0ef3c 64
scachat 0:31e91bb0ef3c 65 void compute_arc(Gcode* gcode, double offset[], double target[]);
scachat 0:31e91bb0ef3c 66 double to_millimeters(double value);
scachat 0:31e91bb0ef3c 67 double theta(double x, double y);
scachat 0:31e91bb0ef3c 68 void select_plane(uint8_t axis_0, uint8_t axis_1, uint8_t axis_2);
scachat 0:31e91bb0ef3c 69
scachat 0:31e91bb0ef3c 70 double current_position[3]; // Current position, in millimeters
scachat 0:31e91bb0ef3c 71 double last_milestone[3]; // Last position, in millimeters
scachat 0:31e91bb0ef3c 72 bool inch_mode; // true for inch mode, false for millimeter mode ( default )
scachat 0:31e91bb0ef3c 73 bool absolute_mode; // true for absolute mode ( default ), false for relative mode
scachat 0:31e91bb0ef3c 74 int8_t motion_mode; // Motion mode for the current received Gcode
scachat 0:31e91bb0ef3c 75 double seek_rate; // Current rate for seeking moves ( mm/s )
scachat 0:31e91bb0ef3c 76 double feed_rate; // Current rate for feeding moves ( mm/s )
scachat 0:31e91bb0ef3c 77 uint8_t plane_axis_0, plane_axis_1, plane_axis_2; // Current plane ( XY, XZ, YZ )
scachat 0:31e91bb0ef3c 78 BaseSolution* arm_solution; // Selected Arm solution ( millimeters to step calculation )
scachat 0:31e91bb0ef3c 79 double mm_per_line_segment; // Setting : Used to split lines into segments
scachat 0:31e91bb0ef3c 80 double mm_per_arc_segment; // Setting : Used to split arcs into segmentrs
scachat 0:31e91bb0ef3c 81
scachat 0:31e91bb0ef3c 82 // Number of arc generation iterations by small angle approximation before exact arc trajectory
scachat 0:31e91bb0ef3c 83 // correction. This parameter maybe decreased if there are issues with the accuracy of the arc
scachat 0:31e91bb0ef3c 84 // generations. In general, the default value is more than enough for the intended CNC applications
scachat 0:31e91bb0ef3c 85 // of grbl, and should be on the order or greater than the size of the buffer to help with the
scachat 0:31e91bb0ef3c 86 // computational efficiency of generating arcs.
scachat 0:31e91bb0ef3c 87 int arc_correction; // Setting : how often to rectify arc computation
scachat 0:31e91bb0ef3c 88 double max_speeds[3]; // Setting : max allowable speed in mm/m for each axis
scachat 0:31e91bb0ef3c 89
scachat 0:31e91bb0ef3c 90 };
scachat 0:31e91bb0ef3c 91
scachat 0:31e91bb0ef3c 92 #endif