Просмотр исходного кода

Add option to only check endstop when homing

Erik van der Zalm 13 лет назад
Родитель
Сommit
b99c49ec3b
4 измененных файлов: 89 добавлений и 55 удалений
  1. 1
    0
      Marlin/Configuration.h
  2. 5
    0
      Marlin/Marlin.pde
  3. 81
    55
      Marlin/stepper.cpp
  4. 2
    0
      Marlin/stepper.h

+ 1
- 0
Marlin/Configuration.h Просмотреть файл

@@ -170,6 +170,7 @@ const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
170 170
 const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
171 171
 // For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
172 172
 
173
+//#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
173 174
 
174 175
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
175 176
 #define X_ENABLE_ON 0

+ 5
- 0
Marlin/Marlin.pde Просмотреть файл

@@ -528,6 +528,8 @@ FORCE_INLINE void process_commands()
528 528
       saved_feedmultiply = feedmultiply;
529 529
       feedmultiply = 100;
530 530
       
531
+      enable_endstops(true);
532
+      
531 533
       for(int8_t i=0; i < NUM_AXIS; i++) {
532 534
         destination[i] = current_position[i];
533 535
       }
@@ -563,6 +565,9 @@ FORCE_INLINE void process_commands()
563 565
         HOMEAXIS(Z);
564 566
 	current_position[2]=code_value()+add_homeing[2];
565 567
       }       
568
+      #ifdef ENDSTOPS_ONLY_FOR_HOMING
569
+        enable_endstops(false);
570
+      #endif
566 571
       
567 572
       feedrate = saved_feedrate;
568 573
       feedmultiply = saved_feedmultiply;

+ 81
- 55
Marlin/stepper.cpp Просмотреть файл

@@ -79,6 +79,8 @@ static bool old_y_max_endstop=false;
79 79
 static bool old_z_min_endstop=false;
80 80
 static bool old_z_max_endstop=false;
81 81
 
82
+static bool check_endstops = true;
83
+
82 84
 volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
83 85
 volatile char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
84 86
 
@@ -191,6 +193,11 @@ void endstops_hit_on_purpose()
191 193
   endstop_z_hit=false;
192 194
 }
193 195
 
196
+void enable_endstops(bool check)
197
+{
198
+  check_endstops = check;
199
+}
200
+
194 201
 //         __________________________
195 202
 //        /|                        |\     _________________         ^
196 203
 //       / |                        | \   /|               |\        |
@@ -309,82 +316,94 @@ ISR(TIMER1_COMPA_vect)
309 316
     if ((out_bits & (1<<X_AXIS)) != 0) {   // -direction
310 317
       WRITE(X_DIR_PIN, INVERT_X_DIR);
311 318
       count_direction[X_AXIS]=-1;
312
-      #if X_MIN_PIN > -1
313
-        bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
314
-        if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
315
-          endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
316
-          endstop_x_hit=true;
317
-          step_events_completed = current_block->step_event_count;
318
-        }
319
-        old_x_min_endstop = x_min_endstop;
320
-      #endif
319
+      if(check_endstops) {
320
+        #if X_MIN_PIN > -1
321
+          bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
322
+          if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
323
+            endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
324
+            endstop_x_hit=true;
325
+            step_events_completed = current_block->step_event_count;
326
+          }
327
+          old_x_min_endstop = x_min_endstop;
328
+        #endif
329
+      }
321 330
     }
322 331
     else { // +direction 
323 332
       WRITE(X_DIR_PIN,!INVERT_X_DIR);
324 333
       count_direction[X_AXIS]=1;
325
-      #if X_MAX_PIN > -1
326
-        bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
327
-        if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
328
-          endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
329
-          endstop_x_hit=true;
330
-          step_events_completed = current_block->step_event_count;
331
-        }
332
-        old_x_max_endstop = x_max_endstop;
333
-      #endif
334
+      if(check_endstops) {
335
+        #if X_MAX_PIN > -1
336
+          bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
337
+          if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
338
+            endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
339
+            endstop_x_hit=true;
340
+            step_events_completed = current_block->step_event_count;
341
+          }
342
+          old_x_max_endstop = x_max_endstop;
343
+        #endif
344
+      }
334 345
     }
335 346
 
336 347
     if ((out_bits & (1<<Y_AXIS)) != 0) {   // -direction
337 348
       WRITE(Y_DIR_PIN,INVERT_Y_DIR);
338 349
       count_direction[Y_AXIS]=-1;
339
-      #if Y_MIN_PIN > -1
340
-        bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
341
-        if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
342
-          endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
343
-          endstop_y_hit=true;
344
-          step_events_completed = current_block->step_event_count;
345
-        }
346
-        old_y_min_endstop = y_min_endstop;
347
-      #endif
350
+      if(check_endstops) {
351
+        #if Y_MIN_PIN > -1
352
+          bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
353
+          if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
354
+            endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
355
+            endstop_y_hit=true;
356
+            step_events_completed = current_block->step_event_count;
357
+          }
358
+          old_y_min_endstop = y_min_endstop;
359
+        #endif
360
+      }
348 361
     }
349 362
     else { // +direction
350 363
     WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
351 364
       count_direction[Y_AXIS]=1;
352
-      #if Y_MAX_PIN > -1
353
-        bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
354
-        if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
355
-          endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
356
-          endstop_y_hit=true;
357
-          step_events_completed = current_block->step_event_count;
358
-        }
359
-        old_y_max_endstop = y_max_endstop;
360
-      #endif
365
+      if(check_endstops) {
366
+        #if Y_MAX_PIN > -1
367
+          bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
368
+          if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
369
+            endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
370
+            endstop_y_hit=true;
371
+            step_events_completed = current_block->step_event_count;
372
+          }
373
+          old_y_max_endstop = y_max_endstop;
374
+        #endif
375
+      }
361 376
     }
362 377
 
363 378
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction
364 379
       WRITE(Z_DIR_PIN,INVERT_Z_DIR);
365 380
       count_direction[Z_AXIS]=-1;
366
-      #if Z_MIN_PIN > -1
367
-        bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
368
-        if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
369
-          endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
370
-          endstop_z_hit=true;
371
-          step_events_completed = current_block->step_event_count;
372
-        }
373
-        old_z_min_endstop = z_min_endstop;
374
-      #endif
381
+      if(check_endstops) {
382
+        #if Z_MIN_PIN > -1
383
+          bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
384
+          if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
385
+            endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
386
+            endstop_z_hit=true;
387
+            step_events_completed = current_block->step_event_count;
388
+          }
389
+          old_z_min_endstop = z_min_endstop;
390
+        #endif
391
+      }
375 392
     }
376 393
     else { // +direction
377 394
       WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
378
-        count_direction[Z_AXIS]=1;
379
-      #if Z_MAX_PIN > -1
380
-        bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
381
-        if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
382
-          endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
383
-          endstop_z_hit=true;
384
-          step_events_completed = current_block->step_event_count;
385
-        }
386
-        old_z_max_endstop = z_max_endstop;
387
-      #endif
395
+      count_direction[Z_AXIS]=1;
396
+      if(check_endstops) {
397
+        #if Z_MAX_PIN > -1
398
+          bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
399
+          if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
400
+            endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
401
+            endstop_z_hit=true;
402
+            step_events_completed = current_block->step_event_count;
403
+          }
404
+          old_z_max_endstop = z_max_endstop;
405
+        #endif
406
+      }
388 407
     }
389 408
 
390 409
     #ifndef ADVANCE
@@ -666,6 +685,13 @@ void st_init()
666 685
     e_steps = 0;
667 686
     TIMSK0 |= (1<<OCIE0A);
668 687
   #endif //ADVANCE
688
+  
689
+  #ifdef ENDSTOPS_ONLY_FOR_HOMING
690
+    enable_endstops(false);
691
+  #else
692
+    enable_endstops(true);
693
+  #endif
694
+  
669 695
   sei();
670 696
 }
671 697
 

+ 2
- 0
Marlin/stepper.h Просмотреть файл

@@ -44,6 +44,8 @@ void st_wake_up();
44 44
 void checkHitEndstops(); //call from somwhere to create an serial error message with the locations the endstops where hit, in case they were triggered
45 45
 void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homeing and before a routine call of checkHitEndstops();
46 46
 
47
+void enable_endstops(bool check); // Enable/disable endstop checking
48
+
47 49
 void checkStepperErrors(); //Print errors detected by the stepper
48 50
 
49 51
 void finishAndDisableSteppers();

Загрузка…
Отмена
Сохранить