Implement Johanns method of specifying segments for delta bots in segments per second.
[clinton/Smoothieware.git] / src / modules / robot / Robot.h
index 9478524..e3d5087 100644 (file)
@@ -1,8 +1,8 @@
-/*  
+/*
       This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
       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.
       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.
-      You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. 
+      You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
 */
 
 #ifndef ROBOT_H
@@ -15,15 +15,24 @@ using std::string;
 #include "../communication/utils/Gcode.h"
 #include "arm_solutions/BaseSolution.h"
 #include "Planner.h"
-
-#define default_seek_rate_checksum             6633
-#define default_feed_rate_checksum             47357
-#define mm_per_line_segment_checksum           30176
-#define mm_per_arc_segment_checksum            15470
-#define arc_correction_checksum                5074
-#define x_axis_max_speed_checksum              64935
-#define y_axis_max_speed_checksum              3752
-#define z_axis_max_speed_checksum              7849
+#include "libs/Pin.h"
+#include "libs/StepperMotor.h"
+
+
+#define default_seek_rate_checksum             CHECKSUM("default_seek_rate")
+#define default_feed_rate_checksum             CHECKSUM("default_feed_rate")
+#define mm_per_line_segment_checksum           CHECKSUM("mm_per_line_segment")
+#define delta_segments_per_second_checksum     CHECKSUM("delta_segments_per_second")
+#define mm_per_arc_segment_checksum            CHECKSUM("mm_per_arc_segment")
+#define arc_correction_checksum                CHECKSUM("arc_correction")
+#define x_axis_max_speed_checksum              CHECKSUM("x_axis_max_speed")
+#define y_axis_max_speed_checksum              CHECKSUM("y_axis_max_speed")
+#define z_axis_max_speed_checksum              CHECKSUM("z_axis_max_speed")
+#define arm_solution_checksum                  CHECKSUM("arm_solution")
+#define cartesian_checksum                     CHECKSUM("cartesian")
+#define rotatable_cartesian_checksum           CHECKSUM("rotatable_cartesian")
+#define rostock_checksum                       CHECKSUM("rostock")
+#define delta_checksum                         CHECKSUM("delta")
 
 #define NEXT_ACTION_DEFAULT 0
 #define NEXT_ACTION_DWELL 1
@@ -54,6 +63,9 @@ class Robot : public Module {
         void on_module_loaded();
         void on_config_reload(void* argument);
         void on_gcode_received(void* argument);
+        void reset_axis_position(double position, int axis);
+
+    private:
         void execute_gcode(Gcode* gcode);
         void append_milestone( double target[], double feed_rate);
         void append_line( Gcode* gcode, double target[], double feed_rate);
@@ -70,14 +82,15 @@ class Robot : public Module {
         double last_milestone[3];                             // Last position, in millimeters
         bool inch_mode;                                       // true for inch mode, false for millimeter mode ( default )
         bool absolute_mode;                                   // true for absolute mode ( default ), false for relative mode
-        uint8_t motion_mode;                                  // Motion mode for the current received Gcode
+        int8_t motion_mode;                                   // Motion mode for the current received Gcode
         double seek_rate;                                     // Current rate for seeking moves ( mm/s )
         double feed_rate;                                     // Current rate for feeding moves ( mm/s )
         uint8_t plane_axis_0, plane_axis_1, plane_axis_2;     // Current plane ( XY, XZ, YZ )
         BaseSolution* arm_solution;                           // Selected Arm solution ( millimeters to step calculation )
-        double mm_per_line_segment;                           // Setting : Used to split lines into segments
-        double mm_per_arc_segment;                            // Setting : Used to split arcs into segmentrs
-        
+        double mm_per_line_segment;                           // Setting : Used to split lines into segments
+        double mm_per_arc_segment;                            // Setting : Used to split arcs into segmentrs
+        double delta_segments_per_second;                     // Setting : Used to split lines into segments for delta based on speed
+
         // Number of arc generation iterations by small angle approximation before exact arc trajectory
         // correction. This parameter maybe decreased if there are issues with the accuracy of the arc
         // generations. In general, the default value is more than enough for the intended CNC applications
@@ -86,6 +99,23 @@ class Robot : public Module {
         int arc_correction;                                   // Setting : how often to rectify arc computation
         double max_speeds[3];                                 // Setting : max allowable speed in mm/m for each axis
 
+    // Used by Stepper
+    public:
+        Pin alpha_step_pin;
+        Pin alpha_dir_pin;
+        Pin alpha_en_pin;
+        Pin beta_step_pin;
+        Pin beta_dir_pin;
+        Pin beta_en_pin;
+        Pin gamma_step_pin;
+        Pin gamma_dir_pin;
+        Pin gamma_en_pin;
+
+        StepperMotor* alpha_stepper_motor;
+        StepperMotor* beta_stepper_motor;
+        StepperMotor* gamma_stepper_motor;
+
+        double seconds_per_minute;                            // for realtime speed change
 };
 
 #endif