Преглед изворни кода

Enabled separate Z Probe and Z Axis endstop use at same time.

Typo fixes in comments in existing code.
Chris Roadfeldt пре 9 година
родитељ
комит
9f3ff14008
4 измењених фајлова са 84 додато и 1 уклоњено
  1. 28
    0
      Marlin/Configuration.h
  2. 4
    0
      Marlin/pins.h
  3. 1
    0
      Marlin/pins_RAMPS_13.h
  4. 51
    1
      Marlin/stepper.cpp

+ 28
- 0
Marlin/Configuration.h Прегледај датотеку

@@ -317,6 +317,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
317 317
 const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
318 318
 const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
319 319
 const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
320
+
320 321
 //#define DISABLE_MAX_ENDSTOPS
321 322
 //#define DISABLE_MIN_ENDSTOPS
322 323
 
@@ -483,6 +484,33 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
483 484
 
484 485
   #endif
485 486
 
487
+// If you have are a Z Probe in addition to endstop(s) for Z Homing, uncomment the #define Z_PROBE_AND_ENDSTOP line below and configure Z Probe settings.
488
+// Only use this if you have both a Z PROBE and Z HOMING ENDSTOP(S). If you are using Z_SAFE_HOMING above, then you probably don't need this unless you want to make use of
489
+// a non-default pin for your Z Probe.
490
+// Note: It's expected that your Z Probe triggers in the direction towards your bed. If your Z Probe does not trigger when traveling towards you bed, it will trigger when it's moving
491
+// away from the bed.
492
+
493
+//  #define Z_PROBE_AND_ENDSTOP
494
+
495
+  #ifdef Z_PROBE_AND_ENDSTOP
496
+
497
+// As of 3-28-2015, there are NO Z Probe pins defined in any board config files.
498
+// Z_PROBE_PIN is for the signal pin only. RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D1 pin in the Aux 1 section of the RAMPS board for the signal.
499
+// The D1 pin in Aux 1 on RAMPS maps to the Arduino D1 pin. The Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D1 pin on the RAMPS maps to D1 on Arduino, this works.
500
+// If you have RAMPS 1.3/1.4 and want to use the RAMPS D1 pin, set Z_PROBE_PIN to 1 and use ground and 5v next to it as needed. Check the RAMPS 1.3/1.4 pinout diagram for details.
501
+// WARNING: Setting the wrong pin may have unexpected and disastrous outcomes. Use with caution and do your homework.
502
+  #define Z_PROBE_PIN -1
503
+
504
+// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup).
505
+    const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
506
+
507
+// The pullups are needed if you directly connect a mechanical endstop between the signal and ground pins.
508
+    #define ENDSTOPPULLUP_ZPROBE
509
+
510
+// If you want to enable the Z Probe pin, but disable its use, uncomment the line below.
511
+//    #define DISABLE_Z_PROBE_ENDSTOP
512
+  #endif
513
+
486 514
 #endif // ENABLE_AUTO_BED_LEVELING
487 515
 
488 516
 

+ 4
- 0
Marlin/pins.h Прегледај датотеку

@@ -178,6 +178,10 @@
178 178
   #define Z_MIN_PIN          -1
179 179
 #endif
180 180
 
181
+#ifdef DISABLE_Z_PROBE_ENDSTOP
182
+  #define Z_PROBE_PIN        -1
183
+#endif
184
+
181 185
 #ifdef DISABLE_XMAX_ENDSTOP
182 186
   #undef X_MAX_PIN
183 187
   #define X_MAX_PIN          -1

+ 1
- 0
Marlin/pins_RAMPS_13.h Прегледај датотеку

@@ -34,6 +34,7 @@
34 34
 #define Z_ENABLE_PIN       62
35 35
 #define Z_MIN_PIN          18
36 36
 #define Z_MAX_PIN          19
37
+#define Z_PROBE_PIN        -1
37 38
 
38 39
 #define Y2_STEP_PIN        36
39 40
 #define Y2_DIR_PIN         34

+ 51
- 1
Marlin/stepper.cpp Прегледај датотеку

@@ -97,6 +97,9 @@ static bool old_x_min_endstop = false,
97 97
               old_z2_min_endstop = false,
98 98
               old_z2_max_endstop = false;
99 99
             #endif
100
+            #if defined Z_PROBE_AND_ENDSTOP
101
+              old_z_probe_endstop = false;
102
+            #endif
100 103
 
101 104
 static bool check_endstops = true;
102 105
 
@@ -520,6 +523,26 @@ ISR(TIMER1_COMPA_vect) {
520 523
             old_z2_min_endstop = z2_min_endstop;
521 524
           #endif
522 525
         #endif
526
+
527
+        #if defined(Z_PROBE_PIN) && Z_PROBE_PIN > -1
528
+          UPDATE_ENDSTOP(z, Z, probe, PROBE);
529
+          bool z_probe_endstop(READ(Z_PROBE_PIN) != Z_MIN_ENDSTOP_INVERTING);
530
+          if(z_probe_endstop && old_z_probe_endstop)
531
+          {
532
+        	  endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
533
+        	  endstop_z_hit=true;
534
+
535
+//        	  if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true");
536
+
537
+
538
+        	  if (!(performing_homing)) //if not performing home
539
+        	  {
540
+        		  step_events_completed = current_block->step_event_count;
541
+        	  }
542
+          }
543
+          old_z_probe_endstop = z_probe_endstop;
544
+          old_z2_probe_endstop = z2_probe_endstop;
545
+        #endif
523 546
       }
524 547
     }
525 548
     else { // +direction
@@ -554,6 +577,26 @@ ISR(TIMER1_COMPA_vect) {
554 577
             old_z2_max_endstop = z2_max_endstop;
555 578
           #endif
556 579
         #endif
580
+
581
+        #if defined(Z_PROBE_PIN) && Z_PROBE_PIN > -1
582
+          UPDATE_ENDSTOP(z, Z, probe, PROBE);
583
+          bool z_probe_endstop(READ(Z_PROBE_PIN) != Z_MAX_ENDSTOP_INVERTING);
584
+          if(z_probe_endstop && old_z_probe_endstop)
585
+          {
586
+        	  endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
587
+        	  endstop_z_hit=true;
588
+
589
+//        	  if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true");
590
+
591
+
592
+        	  if (!(performing_homing)) //if not performing home
593
+        	  {
594
+        		  step_events_completed = current_block->step_event_count;
595
+        	  }
596
+          }
597
+          old_z_probe_endstop = z_probe_endstop;
598
+          old_z2_probe_endstop = z2_probe_endstop;
599
+        #endif
557 600
       }
558 601
     }
559 602
 
@@ -635,7 +678,7 @@ ISR(TIMER1_COMPA_vect) {
635 678
       step_events_completed++;
636 679
       if (step_events_completed >= current_block->step_event_count) break;
637 680
     }
638
-    // Calculare new timer value
681
+    // Calculate new timer value
639 682
     unsigned short timer;
640 683
     unsigned short step_rate;
641 684
     if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
@@ -918,6 +961,13 @@ void st_init() {
918 961
     #endif
919 962
   #endif  
920 963
   
964
+#if defined(Z_PROBE_PIN) && Z_PROBE_PIN >= 0
965
+  SET_INPUT(Z_PROBE_PIN);
966
+  #ifdef ENDSTOPPULLUP_ZPROBE
967
+    WRITE(Z_PROBE_PIN,HIGH);
968
+  #endif
969
+#endif
970
+
921 971
   #define AXIS_INIT(axis, AXIS, PIN) \
922 972
     AXIS ##_STEP_INIT; \
923 973
     AXIS ##_STEP_WRITE(INVERT_## PIN ##_STEP_PIN); \

Loading…
Откажи
Сачувај