Browse Source

Fixed soft limits when the origin is in the middle.

HOME_POS is now always where the endstop is and can be outside the limits.
The limits are now defined by MIN_POS and MAX_POS rather than HOME_POS and MAX_LENGTH.
The Z is axis now homed first if direction is away from the bed.

Saguinololu limit pins change from MIN to MAX according to the homing direction.
Chris Palmer 12 years ago
parent
commit
538189cc19
3 changed files with 51 additions and 19 deletions
  1. 11
    3
      Marlin/Configuration.h
  2. 19
    10
      Marlin/Marlin.pde
  3. 21
    6
      Marlin/pins.h

+ 11
- 3
Marlin/Configuration.h View File

187
 
187
 
188
 #define min_software_endstops true //If true, axis won't move to coordinates less than HOME_POS.
188
 #define min_software_endstops true //If true, axis won't move to coordinates less than HOME_POS.
189
 #define max_software_endstops true  //If true, axis won't move to coordinates greater than the defined lengths below.
189
 #define max_software_endstops true  //If true, axis won't move to coordinates greater than the defined lengths below.
190
-#define X_MAX_LENGTH 205
191
-#define Y_MAX_LENGTH 205
192
-#define Z_MAX_LENGTH 200
190
+// Travel limits after homing
191
+#define X_MAX_POS 205
192
+#define X_MIN_POS 0
193
+#define Y_MAX_POS 205
194
+#define Y_MIN_POS 0
195
+#define Z_MAX_POS 200
196
+#define Z_MIN_POS 0
197
+
198
+#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
199
+#define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
200
+#define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
193
 
201
 
194
 // The position of the homing switches. Use MAX_LENGTH * -0.5 if the center should be 0, 0, 0
202
 // The position of the homing switches. Use MAX_LENGTH * -0.5 if the center should be 0, 0, 0
195
 #define X_HOME_POS 0
203
 #define X_HOME_POS 0

+ 19
- 10
Marlin/Marlin.pde View File

562
     plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
562
     plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
563
     st_synchronize();\
563
     st_synchronize();\
564
     \
564
     \
565
-    current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? LETTER##_HOME_POS : LETTER##_MAX_LENGTH;\
565
+    current_position[LETTER##_AXIS] = LETTER##_HOME_POS;\
566
     destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
566
     destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
567
     feedrate = 0.0;\
567
     feedrate = 0.0;\
568
     endstops_hit_on_purpose();\
568
     endstops_hit_on_purpose();\
656
       }
656
       }
657
       feedrate = 0.0;
657
       feedrate = 0.0;
658
       home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
658
       home_all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2])));
659
+      
660
+      #if Z_HOME_DIR > 0                      // If homing away from BED do Z first
661
+      if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
662
+        HOMEAXIS(Z);
663
+      }
664
+      #endif
665
+      
659
       #ifdef QUICK_HOME
666
       #ifdef QUICK_HOME
660
       if((home_all_axis)||( code_seen(axis_codes[X_AXIS]) && code_seen(axis_codes[Y_AXIS])) )  //first diagonal move
667
       if((home_all_axis)||( code_seen(axis_codes[X_AXIS]) && code_seen(axis_codes[Y_AXIS])) )  //first diagonal move
661
       {
668
       {
669
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
676
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
670
         st_synchronize();
677
         st_synchronize();
671
     
678
     
672
-        current_position[X_AXIS] = (X_HOME_DIR == -1) ? X_HOME_POS : X_MAX_LENGTH;
673
-        current_position[Y_AXIS] = (Y_HOME_DIR == -1) ? Y_HOME_POS : Y_MAX_LENGTH;
679
+        current_position[X_AXIS] = X_HOME_POS;
680
+        current_position[Y_AXIS] = Y_HOME_POS;
674
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
681
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
675
         destination[X_AXIS] = current_position[X_AXIS];
682
         destination[X_AXIS] = current_position[X_AXIS];
676
         destination[Y_AXIS] = current_position[Y_AXIS];
683
         destination[Y_AXIS] = current_position[Y_AXIS];
687
       }
694
       }
688
 
695
 
689
       if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
696
       if((home_all_axis) || (code_seen(axis_codes[Y_AXIS]))) {
690
-       HOMEAXIS(Y);
697
+        HOMEAXIS(Y);
691
       }
698
       }
692
       
699
       
700
+      #if Z_HOME_DIR < 0                      // If homing towards BED do Z last
693
       if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
701
       if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
694
         HOMEAXIS(Z);
702
         HOMEAXIS(Z);
695
       }
703
       }
704
+      #endif
696
       
705
       
697
       if(code_seen(axis_codes[X_AXIS])) 
706
       if(code_seen(axis_codes[X_AXIS])) 
698
       {
707
       {
1533
 void prepare_move()
1542
 void prepare_move()
1534
 {
1543
 {
1535
   if (min_software_endstops) {
1544
   if (min_software_endstops) {
1536
-    if (destination[X_AXIS] < X_HOME_POS) destination[X_AXIS] = X_HOME_POS;
1537
-    if (destination[Y_AXIS] < Y_HOME_POS) destination[Y_AXIS] = Y_HOME_POS;
1538
-    if (destination[Z_AXIS] < Z_HOME_POS) destination[Z_AXIS] = Z_HOME_POS;
1545
+    if (destination[X_AXIS] < X_MIN_POS) destination[X_AXIS] = X_MIN_POS;
1546
+    if (destination[Y_AXIS] < Y_MIN_POS) destination[Y_AXIS] = Y_MIN_POS;
1547
+    if (destination[Z_AXIS] < Z_MIN_POS) destination[Z_AXIS] = Z_MIN_POS;
1539
   }
1548
   }
1540
 
1549
 
1541
   if (max_software_endstops) {
1550
   if (max_software_endstops) {
1542
-    if (destination[X_AXIS] > X_MAX_LENGTH) destination[X_AXIS] = X_MAX_LENGTH;
1543
-    if (destination[Y_AXIS] > Y_MAX_LENGTH) destination[Y_AXIS] = Y_MAX_LENGTH;
1544
-    if (destination[Z_AXIS] > Z_MAX_LENGTH) destination[Z_AXIS] = Z_MAX_LENGTH;
1551
+    if (destination[X_AXIS] > X_MAX_POS) destination[X_AXIS] = X_MAX_POS;
1552
+    if (destination[Y_AXIS] > Y_MAX_POS) destination[Y_AXIS] = Y_MAX_POS;
1553
+    if (destination[Z_AXIS] > Z_MAX_POS) destination[Z_AXIS] = Z_MAX_POS;
1545
   }
1554
   }
1546
   previous_millis_cmd = millis();  
1555
   previous_millis_cmd = millis();  
1547
   plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
1556
   plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);

+ 21
- 6
Marlin/pins.h View File

572
 
572
 
573
 #define X_STEP_PIN         15
573
 #define X_STEP_PIN         15
574
 #define X_DIR_PIN          21
574
 #define X_DIR_PIN          21
575
-#define X_MIN_PIN          18
576
-#define X_MAX_PIN           -1
575
+#if X_HOME_DIR < 0
576
+# define X_MIN_PIN          18 
577
+# define X_MAX_PIN          -1
578
+#else
579
+# define X_MIN_PIN          -1
580
+# define X_MAX_PIN          18
581
+#endif
577
 
582
 
578
 #define Y_STEP_PIN         22
583
 #define Y_STEP_PIN         22
579
 #define Y_DIR_PIN          23
584
 #define Y_DIR_PIN          23
580
-#define Y_MIN_PIN          19
581
-#define Y_MAX_PIN          -1
585
+#if Y_HOME_DIR < 0
586
+# define Y_MIN_PIN          19 
587
+# define Y_MAX_PIN          -1
588
+#else
589
+# define Y_MIN_PIN          -1
590
+# define Y_MAX_PIN          19
591
+#endif
582
 
592
 
583
 #define Z_STEP_PIN         3
593
 #define Z_STEP_PIN         3
584
 #define Z_DIR_PIN          2
594
 #define Z_DIR_PIN          2
585
-#define Z_MIN_PIN          20
586
-#define Z_MAX_PIN          -1
595
+#if Z_HOME_DIR < 0
596
+# define Z_MIN_PIN          20 
597
+# define Z_MAX_PIN          -1
598
+#else
599
+# define Z_MIN_PIN          -1
600
+# define Z_MAX_PIN          20
601
+#endif
587
 
602
 
588
 #define E0_STEP_PIN         1
603
 #define E0_STEP_PIN         1
589
 #define E0_DIR_PIN          0
604
 #define E0_DIR_PIN          0

Loading…
Cancel
Save