chiark / gitweb /
Add option to only check endstop when homing
authorErik van der Zalm <erik@vdzalm.eu>
Sun, 4 Dec 2011 19:17:21 +0000 (20:17 +0100)
committerErik van der Zalm <erik@vdzalm.eu>
Sun, 4 Dec 2011 19:17:21 +0000 (20:17 +0100)
Marlin/Configuration.h
Marlin/Marlin.pde
Marlin/stepper.cpp
Marlin/stepper.h

index f288aba970832d7cb42a49ca0f65cef3c963f5a4..e8b960f788843264afdb34289bfd4e7178d6fa24 100644 (file)
@@ -170,6 +170,7 @@ const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
 const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
 // For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
 
+//#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
 
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
 #define X_ENABLE_ON 0
index 016702ee3636869e6d32960fc7aad686bf85ac27..0a51b1edb8f678c4a452b7f086d541dbc9c7529e 100644 (file)
@@ -528,6 +528,8 @@ FORCE_INLINE void process_commands()
       saved_feedmultiply = feedmultiply;
       feedmultiply = 100;
       
+      enable_endstops(true);
+      
       for(int8_t i=0; i < NUM_AXIS; i++) {
         destination[i] = current_position[i];
       }
@@ -563,6 +565,9 @@ FORCE_INLINE void process_commands()
         HOMEAXIS(Z);
        current_position[2]=code_value()+add_homeing[2];
       }       
+      #ifdef ENDSTOPS_ONLY_FOR_HOMING
+        enable_endstops(false);
+      #endif
       
       feedrate = saved_feedrate;
       feedmultiply = saved_feedmultiply;
index e25d179df803ba28aa75792d9be76ad61a7fabc5..1f688ff90cf6649ccbf60bd215e2559919b27b56 100644 (file)
@@ -79,6 +79,8 @@ static bool old_y_max_endstop=false;
 static bool old_z_min_endstop=false;
 static bool old_z_max_endstop=false;
 
+static bool check_endstops = true;
+
 volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
 volatile char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
 
@@ -191,6 +193,11 @@ void endstops_hit_on_purpose()
   endstop_z_hit=false;
 }
 
+void enable_endstops(bool check)
+{
+  check_endstops = check;
+}
+
 //         __________________________
 //        /|                        |\     _________________         ^
 //       / |                        | \   /|               |\        |
@@ -309,82 +316,94 @@ ISR(TIMER1_COMPA_vect)
     if ((out_bits & (1<<X_AXIS)) != 0) {   // -direction
       WRITE(X_DIR_PIN, INVERT_X_DIR);
       count_direction[X_AXIS]=-1;
-      #if X_MIN_PIN > -1
-        bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
-        if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
-          endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
-          endstop_x_hit=true;
-          step_events_completed = current_block->step_event_count;
-        }
-        old_x_min_endstop = x_min_endstop;
-      #endif
+      if(check_endstops) {
+        #if X_MIN_PIN > -1
+          bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
+          if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
+            endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
+            endstop_x_hit=true;
+            step_events_completed = current_block->step_event_count;
+          }
+          old_x_min_endstop = x_min_endstop;
+        #endif
+      }
     }
     else { // +direction 
       WRITE(X_DIR_PIN,!INVERT_X_DIR);
       count_direction[X_AXIS]=1;
-      #if X_MAX_PIN > -1
-        bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
-        if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
-          endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
-          endstop_x_hit=true;
-          step_events_completed = current_block->step_event_count;
-        }
-        old_x_max_endstop = x_max_endstop;
-      #endif
+      if(check_endstops) {
+        #if X_MAX_PIN > -1
+          bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
+          if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
+            endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
+            endstop_x_hit=true;
+            step_events_completed = current_block->step_event_count;
+          }
+          old_x_max_endstop = x_max_endstop;
+        #endif
+      }
     }
 
     if ((out_bits & (1<<Y_AXIS)) != 0) {   // -direction
       WRITE(Y_DIR_PIN,INVERT_Y_DIR);
       count_direction[Y_AXIS]=-1;
-      #if Y_MIN_PIN > -1
-        bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
-        if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
-          endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
-          endstop_y_hit=true;
-          step_events_completed = current_block->step_event_count;
-        }
-        old_y_min_endstop = y_min_endstop;
-      #endif
+      if(check_endstops) {
+        #if Y_MIN_PIN > -1
+          bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
+          if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
+            endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
+            endstop_y_hit=true;
+            step_events_completed = current_block->step_event_count;
+          }
+          old_y_min_endstop = y_min_endstop;
+        #endif
+      }
     }
     else { // +direction
     WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
       count_direction[Y_AXIS]=1;
-      #if Y_MAX_PIN > -1
-        bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
-        if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
-          endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
-          endstop_y_hit=true;
-          step_events_completed = current_block->step_event_count;
-        }
-        old_y_max_endstop = y_max_endstop;
-      #endif
+      if(check_endstops) {
+        #if Y_MAX_PIN > -1
+          bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
+          if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
+            endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
+            endstop_y_hit=true;
+            step_events_completed = current_block->step_event_count;
+          }
+          old_y_max_endstop = y_max_endstop;
+        #endif
+      }
     }
 
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction
       WRITE(Z_DIR_PIN,INVERT_Z_DIR);
       count_direction[Z_AXIS]=-1;
-      #if Z_MIN_PIN > -1
-        bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
-        if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
-          endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
-          endstop_z_hit=true;
-          step_events_completed = current_block->step_event_count;
-        }
-        old_z_min_endstop = z_min_endstop;
-      #endif
+      if(check_endstops) {
+        #if Z_MIN_PIN > -1
+          bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
+          if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
+            endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
+            endstop_z_hit=true;
+            step_events_completed = current_block->step_event_count;
+          }
+          old_z_min_endstop = z_min_endstop;
+        #endif
+      }
     }
     else { // +direction
       WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
-        count_direction[Z_AXIS]=1;
-      #if Z_MAX_PIN > -1
-        bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
-        if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
-          endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
-          endstop_z_hit=true;
-          step_events_completed = current_block->step_event_count;
-        }
-        old_z_max_endstop = z_max_endstop;
-      #endif
+      count_direction[Z_AXIS]=1;
+      if(check_endstops) {
+        #if Z_MAX_PIN > -1
+          bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
+          if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
+            endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
+            endstop_z_hit=true;
+            step_events_completed = current_block->step_event_count;
+          }
+          old_z_max_endstop = z_max_endstop;
+        #endif
+      }
     }
 
     #ifndef ADVANCE
@@ -666,6 +685,13 @@ void st_init()
     e_steps = 0;
     TIMSK0 |= (1<<OCIE0A);
   #endif //ADVANCE
+  
+  #ifdef ENDSTOPS_ONLY_FOR_HOMING
+    enable_endstops(false);
+  #else
+    enable_endstops(true);
+  #endif
+  
   sei();
 }
 
index e11f5e5a92a38ca9732fba9add70f5e62baede81..fd388ca68bd5b338a9928cb2682dfd482ae7e8fe 100644 (file)
@@ -44,6 +44,8 @@ void st_wake_up();
 void checkHitEndstops(); //call from somwhere to create an serial error message with the locations the endstops where hit, in case they were triggered
 void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homeing and before a routine call of checkHitEndstops();
 
+void enable_endstops(bool check); // Enable/disable endstop checking
+
 void checkStepperErrors(); //Print errors detected by the stepper
 
 void finishAndDisableSteppers();