Browse Source

Merge branch 'Development' into fixup_probing

Latest upstream commits
Scott Lahteine 10 years ago
parent
commit
c0ca26cd50

+ 9
- 0
.gitignore View File

1
+// Our automatic versioning scheme generates the following file
2
+// NEVER put it in the repository
3
+_Version.h
4
+
5
+// All of the following OS, IDE and compiler generated file
6
+// references should be moved from this file
7
+// They are needed, but they belong in your global .gitignore
8
+// rather than in a per-project file such as this
9
+
1
 *.o
10
 *.o
2
 applet/
11
 applet/
3
 *~
12
 *~

+ 1
- 0
ArduinoAddons/Arduino_1.5.x/hardware/marlin/avr/platform.local.txt View File

1
+compiler.cpp.extra_flags=-DHAS_AUTOMATIC_VERSIONING

+ 3
- 0
Marlin/Conditionals.h View File

191
       #define ENDSTOPPULLUP_YMIN
191
       #define ENDSTOPPULLUP_YMIN
192
       #define ENDSTOPPULLUP_ZMIN
192
       #define ENDSTOPPULLUP_ZMIN
193
     #endif
193
     #endif
194
+    #ifndef DISABLE_Z_PROBE_ENDSTOP
195
+      #define ENDSTOPPULLUP_ZPROBE
196
+    #endif
194
   #endif
197
   #endif
195
 
198
 
196
   /**
199
   /**

+ 21
- 0
Marlin/Configuration.h View File

319
   // #define ENDSTOPPULLUP_XMIN
319
   // #define ENDSTOPPULLUP_XMIN
320
   // #define ENDSTOPPULLUP_YMIN
320
   // #define ENDSTOPPULLUP_YMIN
321
   // #define ENDSTOPPULLUP_ZMIN
321
   // #define ENDSTOPPULLUP_ZMIN
322
+  // #define ENDSTOPPULLUP_ZPROBE
322
 #endif
323
 #endif
323
 
324
 
324
 // Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup).
325
 // Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup).
328
 const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
329
 const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
329
 const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
330
 const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
330
 const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
331
 const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
332
+const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
331
 //#define DISABLE_MAX_ENDSTOPS
333
 //#define DISABLE_MAX_ENDSTOPS
332
 //#define DISABLE_MIN_ENDSTOPS
334
 //#define DISABLE_MIN_ENDSTOPS
335
+// If you want to enable the Z Probe pin, but disable its use, uncomment the line below.
336
+// This only affects a Z Probe Endstop if you have separate Z min endstop as well and have
337
+// activated Z_PROBE_ENDSTOP below. If you are using the Z Min endstop on your Z Probe,
338
+// this has no effect.
339
+//#define DISABLE_Z_PROBE_ENDSTOP
333
 
340
 
334
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
341
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
335
 #define X_ENABLE_ON 0
342
 #define X_ENABLE_ON 0
492
 
499
 
493
   #endif
500
   #endif
494
 
501
 
502
+// Support for a dedicated Z PROBE endstop separate from the Z MIN endstop.
503
+// If you would like to use both a Z PROBE and a Z MIN endstop together or just a Z PROBE with a custom pin, uncomment #define Z_PROBE_ENDSTOP and read the instructions below.
504
+// If you want to still use the Z min endstop for homing, disable Z_SAFE_HOMING above. Eg; to park the head outside the bed area when homing with G28.
505
+// WARNING: The Z MIN endstop will need to set properly as it would without a Z PROBE to prevent head crashes and premature stopping during a print.
506
+// To use a separte Z PROBE endstop, you must have a Z_PROBE_PIN defined in the pins.h file for your control board.
507
+// If you are using a servo based Z PROBE, you will need to enable NUM_SERVOS, SERVO_ENDSTOPS and SERVO_ENDSTOPS_ANGLES in the R/C Servo below.
508
+// RAMPS 1.3/1.4 boards may be able to use the 5V, Ground and the D32 pin in the Aux 4 section of the RAMPS board. Use 5V for powered sensors, otherwise connect to ground and D32
509
+// for normally closed configuration and 5V and D32 for normally open configurations. Normally closed configuration is advised and assumed.
510
+// The D32 pin in Aux 4 on RAMPS maps to the Arduino D32 pin. Z_PROBE_PIN is setting the pin to use on the Arduino. Since the D32 pin on the RAMPS maps to D32 on Arduino, this works.
511
+// D32 is currently selected in the RAMPS 1.3/1.4 pin file. All other boards will need changes to the respective pins_XXXXX.h file.
512
+// WARNING: Setting the wrong pin may have unexpected and potentially disastrous outcomes. Use with caution and do your homework.
513
+
514
+//  #define Z_PROBE_ENDSTOP
515
+
495
 #endif // ENABLE_AUTO_BED_LEVELING
516
 #endif // ENABLE_AUTO_BED_LEVELING
496
 
517
 
497
 
518
 

+ 25
- 6
Marlin/Marlin_main.cpp View File

1225
       prepare_move_raw();
1225
       prepare_move_raw();
1226
       
1226
       
1227
       st_synchronize();
1227
       st_synchronize();
1228
-      
1228
+
1229
+    #if defined(Z_PROBE_ENDSTOP)
1230
+      bool z_probe_endstop = (READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING);
1231
+      if (z_probe_endstop) {
1232
+    #else
1229
       bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
1233
       bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
1230
       if (z_min_endstop) {
1234
       if (z_min_endstop) {
1235
+    #endif
1231
         if (!Stopped) {
1236
         if (!Stopped) {
1232
           SERIAL_ERROR_START;
1237
           SERIAL_ERROR_START;
1233
           SERIAL_ERRORLNPGM("Z-Probe failed to engage!");
1238
           SERIAL_ERRORLNPGM("Z-Probe failed to engage!");
1294
       prepare_move_raw();
1299
       prepare_move_raw();
1295
       
1300
       
1296
       st_synchronize();
1301
       st_synchronize();
1297
-      
1302
+
1303
+    #if defined(Z_PROBE_ENDSTOP)
1304
+      bool z_probe_endstop = (READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING);
1305
+      if (!z_probe_endstop) {
1306
+    #else
1298
       bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
1307
       bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
1299
       if (!z_min_endstop) {
1308
       if (!z_min_endstop) {
1309
+    #endif
1300
         if (!Stopped) {
1310
         if (!Stopped) {
1301
           SERIAL_ERROR_START;
1311
           SERIAL_ERROR_START;
1302
           SERIAL_ERRORLNPGM("Z-Probe failed to retract!");
1312
           SERIAL_ERRORLNPGM("Z-Probe failed to retract!");
2765
   } // code_seen('S')
2775
   } // code_seen('S')
2766
 }
2776
 }
2767
 
2777
 
2768
-
2769
 #if defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
2778
 #if defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
2770
 
2779
 
2771
-  #if Z_MIN_PIN == -1
2772
-    #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability."
2780
+  // This is redudant since the SanityCheck.h already checks for a valid Z_PROBE_PIN, but here for clarity.
2781
+  #if defined (Z_PROBE_ENDSTOP)
2782
+    #if (! defined (Z_PROBE_PIN) || Z_PROBE_PIN == -1)
2783
+      #error "You must have a Z_PROBE_PIN defined in order to enable calculation of Z-Probe repeatability."
2784
+    #endif
2785
+  #else
2786
+    #if (Z_MIN_PIN == -1)
2787
+      #error "You must have a Z_MIN_PIN defined in order to enable calculation of Z-Probe repeatability."
2788
+    #endif
2773
   #endif
2789
   #endif
2774
 
2790
 
2775
   /**
2791
   /**
3499
     SERIAL_PROTOCOLPGM(MSG_Z2_MAX);
3515
     SERIAL_PROTOCOLPGM(MSG_Z2_MAX);
3500
     SERIAL_PROTOCOLLN(((READ(Z2_MAX_PIN)^Z2_MAX_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
3516
     SERIAL_PROTOCOLLN(((READ(Z2_MAX_PIN)^Z2_MAX_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
3501
   #endif
3517
   #endif
3502
-  
3518
+  #if defined(Z_PROBE_PIN) && Z_PROBE_PIN > -1
3519
+    SERIAL_PROTOCOLPGM(MSG_Z_PROBE);
3520
+    SERIAL_PROTOCOLLN(((READ(Z_PROBE_PIN)^Z_PROBE_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
3521
+  #endif
3503
 }
3522
 }
3504
 
3523
 
3505
 /**
3524
 /**

+ 30
- 4
Marlin/SanityCheck.h View File

100
      * Require a Z Min pin
100
      * Require a Z Min pin
101
      */
101
      */
102
     #if Z_MIN_PIN == -1
102
     #if Z_MIN_PIN == -1
103
-      #ifdef Z_PROBE_REPEATABILITY_TEST
104
-        #error You must have a Z_MIN endstop to enable Z_PROBE_REPEATABILITY_TEST.
105
-      #else
106
-        #error ENABLE_AUTO_BED_LEVELING requires a Z_MIN endstop. Z_MIN_PIN must point to a valid hardware pin.
103
+      #if Z_PROBE_PIN == -1 || (! defined (Z_PROBE_ENDSTOP) || defined (DISABLE_Z_PROBE_ENDSTOP)) // It's possible for someone to set a pin for the Z Probe, but not enable it.
104
+        #ifdef Z_PROBE_REPEATABILITY_TEST
105
+          #error You must have a Z_MIN or Z_PROBE endstop to enable Z_PROBE_REPEATABILITY_TEST.
106
+        #else
107
+          #error ENABLE_AUTO_BED_LEVELING requires a Z_MIN or Z_PROBE endstop. Z_MIN_PIN or Z_PROBE_PIN must point to a valid hardware pin.
108
+        #endif
107
       #endif
109
       #endif
108
     #endif
110
     #endif
109
 
111
 
110
     /**
112
     /**
113
+     * Require a Z Probe Pin if Z_PROBE_ENDSTOP is enabled.
114
+     */
115
+    #if defined(Z_PROBE_ENDSTOP)
116
+      #ifndef Z_PROBE_PIN
117
+        #error You must have a Z_PROBE_PIN defined in your pins_XXXX.h file if you enable Z_PROBE_ENDSTOP
118
+      #endif
119
+      #if Z_PROBE_PIN == -1
120
+        #error You must set Z_PROBE_PIN to a valid pin if you enable Z_PROBE_ENDSTOP
121
+      #endif
122
+// Forcing Servo definitions can break some hall effect sensor setups. Leaving these here for further comment.
123
+//      #ifndef NUM_SERVOS
124
+//        #error You must have NUM_SERVOS defined and there must be at least 1 configured to use Z_PROBE_ENDSTOP
125
+//      #endif
126
+//      #if defined(NUM_SERVOS) && NUM_SERVOS < 1
127
+//        #error You must have at least 1 servo defined for NUM_SERVOS to use Z_PROBE_ENDSTOP
128
+//      #endif
129
+//      #ifndef SERVO_ENDSTOPS
130
+//        #error You must have SERVO_ENDSTOPS defined and have the Z index set to at least 0 or above to use Z_PROBE_ENDSTOP
131
+//      #endif
132
+//      #ifndef SERVO_ENDSTOP_ANGLES
133
+//        #error You must have SERVO_ENDSTOP_ANGLES defined for Z Extend and Retract to use Z_PROBE_AND_ENSTOP
134
+//      #endif
135
+    #endif
136
+    /**
111
      * Check if Probe_Offset * Grid Points is greater than Probing Range
137
      * Check if Probe_Offset * Grid Points is greater than Probing Range
112
      */
138
      */
113
     #ifdef AUTO_BED_LEVELING_GRID
139
     #ifdef AUTO_BED_LEVELING_GRID

+ 1
- 0
Marlin/boards.h View File

37
 #define BOARD_BRAINWAVE         82   // Brainwave (AT90USB646)
37
 #define BOARD_BRAINWAVE         82   // Brainwave (AT90USB646)
38
 #define BOARD_SAV_MKI           83   // SAV Mk-I (AT90USB1286)
38
 #define BOARD_SAV_MKI           83   // SAV Mk-I (AT90USB1286)
39
 #define BOARD_TEENSY2           84   // Teensy++2.0 (AT90USB1286) - CLI compile: DEFINES=AT90USBxx_TEENSYPP_ASSIGNMENTS HARDWARE_MOTHERBOARD=84  make
39
 #define BOARD_TEENSY2           84   // Teensy++2.0 (AT90USB1286) - CLI compile: DEFINES=AT90USBxx_TEENSYPP_ASSIGNMENTS HARDWARE_MOTHERBOARD=84  make
40
+#define BOARD_BRAINWAVE_PRO     85   // Brainwave Pro (AT90USB1286)
40
 #define BOARD_GEN3_PLUS         9    // Gen3+
41
 #define BOARD_GEN3_PLUS         9    // Gen3+
41
 #define BOARD_GEN3_MONOLITHIC   22   // Gen3 Monolithic Electronics
42
 #define BOARD_GEN3_MONOLITHIC   22   // Gen3 Monolithic Electronics
42
 #define BOARD_MEGATRONICS       70   // Megatronics
43
 #define BOARD_MEGATRONICS       70   // Megatronics

+ 29
- 5
Marlin/language.h View File

36
   #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en)
36
   #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en)
37
 #endif
37
 #endif
38
 
38
 
39
+#ifdef HAS_AUTOMATIC_VERSIONING
40
+  #include "_Version.h"
41
+#endif
42
+
39
 #define PROTOCOL_VERSION "1.0"
43
 #define PROTOCOL_VERSION "1.0"
40
-#define FIRMWARE_URL "https://github.com/MarlinFirmware/Marlin"
41
 
44
 
42
 #if MB(ULTIMAKER)|| MB(ULTIMAKER_OLD)|| MB(ULTIMAIN_2)
45
 #if MB(ULTIMAKER)|| MB(ULTIMAKER_OLD)|| MB(ULTIMAIN_2)
43
   #undef FIRMWARE_URL
46
   #undef FIRMWARE_URL
65
   #define MACHINE_NAME "HEPHESTOS"
68
   #define MACHINE_NAME "HEPHESTOS"
66
   #undef FIRMWARE_URL
69
   #undef FIRMWARE_URL
67
   #define FIRMWARE_URL "http://www.bq.com/gb/downloads-prusa-i3-hephestos.html"
70
   #define FIRMWARE_URL "http://www.bq.com/gb/downloads-prusa-i3-hephestos.html"
68
-#else // Default firmware set to Mendel
69
-  #define MACHINE_NAME "Mendel"
71
+#elif MB(BRAINWAVE_PRO)
72
+  #define MACHINE_NAME "Kossel Pro"
73
+  #ifndef FIRMWARE_URL
74
+    #define FIRMWARE_URL "https://github.com/OpenBeamUSA/Marlin/"
75
+  #endif
76
+#else
77
+  #ifndef MACHINE_NAME
78
+    #define MACHINE_NAME "Mendel"
79
+  #endif
70
 #endif
80
 #endif
71
 
81
 
72
 #ifdef CUSTOM_MENDEL_NAME
82
 #ifdef CUSTOM_MENDEL_NAME
83
+  #warning CUSTOM_MENDEL_NAME deprecated - use CUSTOM_MACHINE_NAME
84
+  #define CUSTOM_MACHINE_NAME CUSTOM_MENDEL_NAME
85
+#endif
86
+
87
+#ifdef CUSTOM_MACHINE_NAME
73
   #undef MACHINE_NAME
88
   #undef MACHINE_NAME
74
-  #define MACHINE_NAME CUSTOM_MENDEL_NAME
89
+  #define MACHINE_NAME CUSTOM_MACHINE_NAME
90
+#endif
91
+
92
+#ifndef FIRMWARE_URL
93
+  #define FIRMWARE_URL "https://github.com/MarlinFirmware/Marlin"
94
+#endif
95
+
96
+#ifndef BUILD_VERSION
97
+  #define BUILD_VERSION "V1; Sprinter/grbl mashup for gen6"
75
 #endif
98
 #endif
76
 
99
 
77
 #ifndef MACHINE_UUID
100
 #ifndef MACHINE_UUID
122
 #define MSG_HEATING_COMPLETE                "Heating done."
145
 #define MSG_HEATING_COMPLETE                "Heating done."
123
 #define MSG_BED_HEATING                     "Bed Heating."
146
 #define MSG_BED_HEATING                     "Bed Heating."
124
 #define MSG_BED_DONE                        "Bed done."
147
 #define MSG_BED_DONE                        "Bed done."
125
-#define MSG_M115_REPORT                     "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
148
+#define MSG_M115_REPORT                     "FIRMWARE_NAME:Marlin " BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
126
 #define MSG_COUNT_X                         " Count X: "
149
 #define MSG_COUNT_X                         " Count X: "
127
 #define MSG_ERR_KILLED                      "Printer halted. kill() called!"
150
 #define MSG_ERR_KILLED                      "Printer halted. kill() called!"
128
 #define MSG_ERR_STOPPED                     "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
151
 #define MSG_ERR_STOPPED                     "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
138
 #define MSG_Z_MIN                           "z_min: "
161
 #define MSG_Z_MIN                           "z_min: "
139
 #define MSG_Z_MAX                           "z_max: "
162
 #define MSG_Z_MAX                           "z_max: "
140
 #define MSG_Z2_MAX                          "z2_max: "
163
 #define MSG_Z2_MAX                          "z2_max: "
164
+#define MSG_Z_PROBE                         "z_probe: "
141
 #define MSG_M119_REPORT                     "Reporting endstop status"
165
 #define MSG_M119_REPORT                     "Reporting endstop status"
142
 #define MSG_ENDSTOP_HIT                     "TRIGGERED"
166
 #define MSG_ENDSTOP_HIT                     "TRIGGERED"
143
 #define MSG_ENDSTOP_OPEN                    "open"
167
 #define MSG_ENDSTOP_OPEN                    "open"

+ 5
- 1
Marlin/pins.h View File

187
   #define Z_MIN_PIN          -1
187
   #define Z_MIN_PIN          -1
188
 #endif
188
 #endif
189
 
189
 
190
+#if defined (DISABLE_Z_PROBE_ENDSTOP) || ! defined (Z_PROBE_ENDSTOP) // Allow code to compile regardless of Z_PROBE_ENDSTOP setting.
191
+  #define Z_PROBE_PIN        -1
192
+#endif
193
+
190
 #ifdef DISABLE_XMAX_ENDSTOP
194
 #ifdef DISABLE_XMAX_ENDSTOP
191
   #undef X_MAX_PIN
195
   #undef X_MAX_PIN
192
   #define X_MAX_PIN          -1
196
   #define X_MAX_PIN          -1
216
   #define Z_MIN_PIN          -1
220
   #define Z_MIN_PIN          -1
217
 #endif
221
 #endif
218
 
222
 
219
-#define SENSITIVE_PINS { 0, 1, X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, PS_ON_PIN, \
223
+#define SENSITIVE_PINS { 0, 1, X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_MIN_PIN, X_MAX_PIN, Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_MIN_PIN, Y_MAX_PIN, Z_STEP_PIN, Z_DIR_PIN, Z_ENABLE_PIN, Z_MIN_PIN, Z_MAX_PIN, Z_PROBE_PIN, PS_ON_PIN, \
220
                         HEATER_BED_PIN, FAN_PIN, \
224
                         HEATER_BED_PIN, FAN_PIN, \
221
                         _E0_PINS _E1_PINS _E2_PINS _E3_PINS \
225
                         _E0_PINS _E1_PINS _E2_PINS _E3_PINS \
222
                         analogInputToDigitalPin(TEMP_BED_PIN) \
226
                         analogInputToDigitalPin(TEMP_BED_PIN) \

+ 6
- 0
Marlin/pins_RAMPS_13.h View File

34
 #define Z_ENABLE_PIN       62
34
 #define Z_ENABLE_PIN       62
35
 #define Z_MIN_PIN          18
35
 #define Z_MIN_PIN          18
36
 #define Z_MAX_PIN          19
36
 #define Z_MAX_PIN          19
37
+#define Z_PROBE_PIN        -1
37
 
38
 
38
 #define Y2_STEP_PIN        36
39
 #define Y2_STEP_PIN        36
39
 #define Y2_DIR_PIN         34
40
 #define Y2_DIR_PIN         34
61
   #define FILWIDTH_PIN        5
62
   #define FILWIDTH_PIN        5
62
 #endif
63
 #endif
63
 
64
 
65
+#if defined(Z_PROBE_ENDSTOP)
66
+  // Define a pin to use as the signal pin on Arduino for the Z_PROBE endstop.
67
+ #define Z_PROBE_PIN 32
68
+#endif
69
+
64
 #if defined(FILAMENT_RUNOUT_SENSOR)
70
 #if defined(FILAMENT_RUNOUT_SENSOR)
65
   // define digital pin 4 for the filament runout sensor. Use the RAMPS 1.4 digital input 4 on the servos connector
71
   // define digital pin 4 for the filament runout sensor. Use the RAMPS 1.4 digital input 4 on the servos connector
66
   #define FILRUNOUT_PIN        4
72
   #define FILRUNOUT_PIN        4

+ 46
- 3
Marlin/stepper.cpp View File

76
 static volatile bool endstop_x_hit = false;
76
 static volatile bool endstop_x_hit = false;
77
 static volatile bool endstop_y_hit = false;
77
 static volatile bool endstop_y_hit = false;
78
 static volatile bool endstop_z_hit = false;
78
 static volatile bool endstop_z_hit = false;
79
+static volatile bool endstop_z_probe_hit = false; // Leaving this in even if Z_PROBE_ENDSTOP isn't defined, keeps code below cleaner. #ifdef it and usage below to save space.
79
 
80
 
80
 #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
81
 #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
81
   bool abort_on_endstop_hit = false;
82
   bool abort_on_endstop_hit = false;
112
   #endif
113
   #endif
113
 #endif
114
 #endif
114
 
115
 
116
+#ifdef Z_PROBE_ENDSTOP // No need to check for valid pin, SanityCheck.h already does this.
117
+static bool old_z_probe_endstop = false;
118
+#endif
119
+
115
 static bool check_endstops = true;
120
 static bool check_endstops = true;
116
 
121
 
117
 volatile long count_position[NUM_AXIS] = { 0 };
122
 volatile long count_position[NUM_AXIS] = { 0 };
254
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~BIT(OCIE1A)
259
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~BIT(OCIE1A)
255
 
260
 
256
 void endstops_hit_on_purpose() {
261
 void endstops_hit_on_purpose() {
257
-  endstop_x_hit = endstop_y_hit = endstop_z_hit = false;
262
+  endstop_x_hit = endstop_y_hit = endstop_z_hit = endstop_z_probe_hit = false; // #ifdef endstop_z_probe_hit = to save space if needed.
258
 }
263
 }
259
 
264
 
260
 void checkHitEndstops() {
265
 void checkHitEndstops() {
261
-  if (endstop_x_hit || endstop_y_hit || endstop_z_hit) {
266
+  if (endstop_x_hit || endstop_y_hit || endstop_z_hit || endstop_z_probe_hit) { // #ifdef || endstop_z_probe_hit to save space if needed.
262
     SERIAL_ECHO_START;
267
     SERIAL_ECHO_START;
263
     SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
268
     SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
264
     if (endstop_x_hit) {
269
     if (endstop_x_hit) {
273
       SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
278
       SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
274
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
279
       LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
275
     }
280
     }
281
+    #ifdef Z_PROBE_ENDSTOP
282
+    if (endstop_z_probe_hit) {
283
+    	SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
284
+    	LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
285
+    }
286
+    #endif
276
     SERIAL_EOL;
287
     SERIAL_EOL;
277
 
288
 
278
     endstops_hit_on_purpose();
289
     endstops_hit_on_purpose();
551
 
562
 
552
         #endif // Z_MIN_PIN
563
         #endif // Z_MIN_PIN
553
 
564
 
565
+        #ifdef Z_PROBE_ENDSTOP
566
+          UPDATE_ENDSTOP(z, Z, probe, PROBE);
567
+          z_probe_endstop=(READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING);
568
+          if(z_probe_endstop && old_z_probe_endstop)
569
+          {
570
+        	  endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
571
+        	  endstop_z_probe_hit=true;
572
+
573
+//        	  if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true");
574
+          }
575
+          old_z_probe_endstop = z_probe_endstop;
576
+        #endif
577
+        
554
       } // check_endstops
578
       } // check_endstops
555
 
579
 
556
     }
580
     }
596
           #endif // !Z_DUAL_ENDSTOPS
620
           #endif // !Z_DUAL_ENDSTOPS
597
 
621
 
598
         #endif // Z_MAX_PIN
622
         #endif // Z_MAX_PIN
623
+        
624
+        #ifdef Z_PROBE_ENDSTOP
625
+          UPDATE_ENDSTOP(z, Z, probe, PROBE);
626
+          z_probe_endstop=(READ(Z_PROBE_PIN) != Z_PROBE_ENDSTOP_INVERTING);
627
+          if(z_probe_endstop && old_z_probe_endstop)
628
+          {
629
+        	  endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
630
+        	  endstop_z_probe_hit=true;
631
+//        	  if (z_probe_endstop && old_z_probe_endstop) SERIAL_ECHOLN("z_probe_endstop = true");
632
+          }
633
+          old_z_probe_endstop = z_probe_endstop;
634
+        #endif
599
 
635
 
600
       } // check_endstops
636
       } // check_endstops
601
 
637
 
679
       step_events_completed++;
715
       step_events_completed++;
680
       if (step_events_completed >= current_block->step_event_count) break;
716
       if (step_events_completed >= current_block->step_event_count) break;
681
     }
717
     }
682
-    // Calculare new timer value
718
+    // Calculate new timer value
683
     unsigned short timer;
719
     unsigned short timer;
684
     unsigned short step_rate;
720
     unsigned short step_rate;
685
     if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
721
     if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
962
     #endif
998
     #endif
963
   #endif  
999
   #endif  
964
   
1000
   
1001
+#if (defined(Z_PROBE_PIN) && Z_PROBE_PIN >= 0) && defined(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
1002
+  SET_INPUT(Z_PROBE_PIN);
1003
+  #ifdef ENDSTOPPULLUP_ZPROBE
1004
+    WRITE(Z_PROBE_PIN,HIGH);
1005
+  #endif
1006
+#endif
1007
+
965
   #define AXIS_INIT(axis, AXIS, PIN) \
1008
   #define AXIS_INIT(axis, AXIS, PIN) \
966
     AXIS ##_STEP_INIT; \
1009
     AXIS ##_STEP_INIT; \
967
     AXIS ##_STEP_WRITE(INVERT_## PIN ##_STEP_PIN); \
1010
     AXIS ##_STEP_WRITE(INVERT_## PIN ##_STEP_PIN); \

Loading…
Cancel
Save