Browse Source

Added servo actuated enstop coding to allow G28 command to engage and retract a servo to specified angles.

Gord Christmas 11 years ago
parent
commit
f4f30c9d64
2 changed files with 31 additions and 3 deletions
  1. 9
    1
      Marlin/Configuration.h
  2. 22
    2
      Marlin/Marlin_main.cpp

+ 9
- 1
Marlin/Configuration.h View File

@@ -470,7 +470,15 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
470 470
 // leaving it undefined or defining as 0 will disable the servo subsystem
471 471
 // If unsure, leave commented / disabled
472 472
 //
473
-// #define NUM_SERVOS 3
473
+//#define NUM_SERVOS 3 // Servo index starts with 0
474
+
475
+// Servo Endstops
476
+// 
477
+// This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
478
+// Use M206 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
479
+// 
480
+//#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
481
+//#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 70,0} // X,Y,Z Axis Extend and Retract angles
474 482
 
475 483
 #include "Configuration_adv.h"
476 484
 #include "thermistortables.h"

+ 22
- 2
Marlin/Marlin_main.cpp View File

@@ -351,6 +351,16 @@ void servo_init()
351 351
   #if (NUM_SERVOS >= 5)
352 352
     #error "TODO: enter initalisation code for more servos"
353 353
   #endif
354
+
355
+  // Set position of Servo Endstops that are defined
356
+  #ifdef SERVO_ENDSTOPS
357
+  for(int8_t i = 0; i < 3; i++)
358
+  {
359
+    if(servo_endstops[i] > -1) {
360
+      servos[servo_endstops[i]].write(servo_endstop_angles[i * 2 + 1]);
361
+    }
362
+  }
363
+  #endif
354 364
 }
355 365
 
356 366
 void setup()
@@ -664,11 +674,16 @@ static void axis_is_at_home(int axis) {
664 674
 static void homeaxis(int axis) {
665 675
 #define HOMEAXIS_DO(LETTER) \
666 676
   ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
667
-
668 677
   if (axis==X_AXIS ? HOMEAXIS_DO(X) :
669 678
       axis==Y_AXIS ? HOMEAXIS_DO(Y) :
670 679
       axis==Z_AXIS ? HOMEAXIS_DO(Z) :
671 680
       0) {
681
+
682
+    // Engage Servo endstop if enabled
683
+    #ifdef SERVO_ENDSTOPS[axis] > -1
684
+      servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]);
685
+    #endif
686
+
672 687
     current_position[axis] = 0;
673 688
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
674 689
     destination[axis] = 1.5 * max_length(axis) * home_dir(axis);
@@ -691,6 +706,11 @@ static void homeaxis(int axis) {
691 706
     destination[axis] = current_position[axis];
692 707
     feedrate = 0.0;
693 708
     endstops_hit_on_purpose();
709
+
710
+    // Retract Servo endstop if enabled
711
+    #ifdef SERVO_ENDSTOPS[axis] > -1
712
+      servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2 + 1]);
713
+    #endif
694 714
   }
695 715
 }
696 716
 #define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
@@ -2281,4 +2301,4 @@ bool setTargetedHotend(int code){
2281 2301
     }
2282 2302
   }
2283 2303
   return false;
2284
-}
2304
+}

Loading…
Cancel
Save