implement parsing of A B C parameters for multi axis, NOTE mutually exclusive with...
authorJim Morris <morris@wolfman.com>
Thu, 28 Jul 2016 07:32:57 +0000 (00:32 -0700)
committerJim Morris <morris@wolfman.com>
Thu, 28 Jul 2016 07:32:57 +0000 (00:32 -0700)
src/libs/nuts_bolts.h
src/main.cpp
src/makefile
src/modules/robot/Robot.cpp
src/modules/utils/simpleshell/SimpleShell.cpp
src/modules/utils/simpleshell/SimpleShell.h

index f490abf..932f208 100644 (file)
@@ -25,6 +25,9 @@ along with Grbl. If not, see <http://www.gnu.org/licenses/>.
 #define Y_AXIS 1
 #define Z_AXIS 2
 #define E_AXIS 3
+#define A_AXIS 3
+#define B_AXIS 4
+#define C_AXIS 5
 
 #define ALPHA_STEPPER 0
 #define BETA_STEPPER 1
index 41b98f9..87886c2 100644 (file)
@@ -101,11 +101,7 @@ void init() {
     Kernel* kernel = new Kernel();
 
     kernel->streams->printf("Smoothie Running @%ldMHz\r\n", SystemCoreClock / 1000000);
-    Version version;
-    kernel->streams->printf("  Build version %s, Build date %s\r\n", version.get_build(), version.get_build_date());
-#ifdef CNC
-    kernel->streams->printf("  CNC Build\r\n");
-#endif
+    SimpleShell::version_command("", kernel->streams);
 
     bool sdok= (sd.disk_initialize() == 0);
     if(!sdok) kernel->streams->printf("SDCard failed to initialize\r\n");
index 3c880e7..a1023d8 100644 (file)
@@ -70,6 +70,9 @@ else
 export EXCLUDED_MODULES = $(EXCLUDE_MODULES)
 endif
 
+ifneq "$(AXIS)" ""
+DEFINES += -DMAX_ROBOT_ACTUATORS=$(AXIS)
+endif
 
 # set to not compile in any network support
 #export NONETWORK = 1
index 4098435..2ae87fa 100644 (file)
@@ -179,22 +179,36 @@ void Robot::load_config()
     this->segment_z_moves     = THEKERNEL->config->value(segment_z_moves_checksum     )->by_default(true)->as_bool();
     this->save_g92            = THEKERNEL->config->value(save_g92_checksum            )->by_default(false)->as_bool();
 
-    // Make our Primary XYZ StepperMotors
+    // Make our Primary XYZ StepperMotors, and potentially A B C
     uint16_t const checksums[][6] = {
         ACTUATOR_CHECKSUMS("alpha"), // X
         ACTUATOR_CHECKSUMS("beta"),  // Y
         ACTUATOR_CHECKSUMS("gamma"), // Z
+        #if MAX_ROBOT_ACTUATORS > 3
+        ACTUATOR_CHECKSUMS("delta"),   // A
+        #if MAX_ROBOT_ACTUATORS > 4
+        ACTUATOR_CHECKSUMS("epsilon"), // B
+        #if MAX_ROBOT_ACTUATORS > 5
+        ACTUATOR_CHECKSUMS("zeta")     // C
+        #endif
+        #endif
+        #endif
     };
 
     // default acceleration setting, can be overriden with newer per axis settings
     this->default_acceleration= THEKERNEL->config->value(acceleration_checksum)->by_default(100.0F )->as_number(); // Acceleration is in mm/s^2
 
     // make each motor
-    for (size_t a = X_AXIS; a <= Z_AXIS; a++) {
+    for (size_t a = 0; a < MAX_ROBOT_ACTUATORS; a++) {
         Pin pins[3]; //step, dir, enable
         for (size_t i = 0; i < 3; i++) {
             pins[i].from_string(THEKERNEL->config->value(checksums[a][i])->by_default("nc")->as_string())->as_output();
+            if(!pins[i].connected()) {
+                if(i <= Z_AXIS) THEKERNEL->streams->printf("FATAL: motor %d is not defined in config\n", 'X'+a);
+                break; // if all pins are not defined then the axis is not defined (and axis need to be defined in contiguous order)
+            }
         }
+
         StepperMotor *sm = new StepperMotor(pins[0], pins[1], pins[2]);
         // register this motor (NB This must be 0,1,2) of the actuators array
         uint8_t n= register_motor(sm);
@@ -780,6 +794,9 @@ void Robot::process_move(Gcode *gcode, enum MOTION_MODE_T motion_mode)
         }
     }
 
+    float delta_e= NAN;
+
+    #if MAX_ROBOT_ACTUATORS > 3
     // process extruder parameters, for active extruder only (only one active extruder at a time)
     selected_extruder= 0;
     if(gcode->has_letter('E')) {
@@ -794,7 +811,6 @@ void Robot::process_move(Gcode *gcode, enum MOTION_MODE_T motion_mode)
     }
 
     // do E for the selected extruder
-    float delta_e= NAN;
     if(selected_extruder > 0 && !isnan(param[E_AXIS])) {
         if(this->e_absolute_mode) {
             target[selected_extruder]= param[E_AXIS];
@@ -805,6 +821,20 @@ void Robot::process_move(Gcode *gcode, enum MOTION_MODE_T motion_mode)
         }
     }
 
+    // process ABC axis, this is mutually exclusive to using E for an extruder, so if E is used and A then the results are undefined
+    for (int i = A_AXIS; i < n_motors; ++i) {
+        char letter= 'A'+i-A_AXIS;
+        if(gcode->has_letter(letter)) {
+            float p= gcode->get_value(letter);
+            if(this->absolute_mode) {
+                target[i]= p;
+            }else{
+                target[i]= p + last_milestone[i];
+            }
+        }
+    }
+    #endif
+
     if( gcode->has_letter('F') ) {
         if( motion_mode == SEEK )
             this->seek_rate = this->to_millimeters( gcode->get_value('F') );
index e7afa9f..4f325df 100644 (file)
@@ -620,8 +620,10 @@ void SimpleShell::version_command( string parameters, StreamOutput *stream)
     const char *mcu = (dev & 0x00100000) ? "LPC1769" : "LPC1768";
     stream->printf("Build version: %s, Build date: %s, MCU: %s, System Clock: %ldMHz\r\n", vers.get_build(), vers.get_build_date(), mcu, SystemCoreClock / 1000000);
     #ifdef CNC
-    stream->printf("  CNC Build\r\n");
+    stream->printf("  CNC Build ");
     #endif
+
+    stream->printf("%d axis\n", MAX_ROBOT_ACTUATORS);
 }
 
 // Reset the system
index 3b55e88..e275370 100644 (file)
@@ -26,6 +26,7 @@ public:
     void on_second_tick(void *);
     static bool parse_command(const char *cmd, string args, StreamOutput *stream);
     static void print_mem(StreamOutput *stream) { mem_command("", stream); }
+    static void version_command(string parameters, StreamOutput *stream );
 
 private:
     static void ls_command(string parameters, StreamOutput *stream );
@@ -40,7 +41,6 @@ private:
     static void reset_command(string parameters, StreamOutput *stream );
     static void dfu_command(string parameters, StreamOutput *stream );
     static void help_command(string parameters, StreamOutput *stream );
-    static void version_command(string parameters, StreamOutput *stream );
     static void get_command(string parameters, StreamOutput *stream );
     static void set_temp_command(string parameters, StreamOutput *stream );
     static void calc_thermistor_command( string parameters, StreamOutput *stream);