Переглянути джерело

Merge pull request #1024 from oliasmage/Marlin_v1

Adding Z Probe via sled mounted endstop
Erik van der Zalm 10 роки тому
джерело
коміт
68dd5e635e
3 змінених файлів з 143 додано та 37 видалено
  1. 2
    0
      Marlin/Configuration.h
  2. 66
    7
      Marlin/Marlin_main.cpp
  3. 75
    30
      README.md

+ 2
- 0
Marlin/Configuration.h Переглянути файл

@@ -437,6 +437,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
437 437
   #define Z_RAISE_BEFORE_PROBING 15    //How much the extruder will be raised before traveling to the first probing point.
438 438
   #define Z_RAISE_BETWEEN_PROBINGS 5  //How much the extruder will be raised when traveling from between next probing points
439 439
 
440
+  //#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
441
+  //#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.
440 442
 
441 443
   //If defined, the Probe servo will be turned on only during movement and then turned off to avoid jerk
442 444
   //The value is the delay to turn the servo off after powered on - depends on the servo speed; 300ms is good value, but you can try lower it.

+ 66
- 7
Marlin/Marlin_main.cpp Переглянути файл

@@ -78,6 +78,8 @@
78 78
 // G28 - Home all Axis
79 79
 // G29 - Detailed Z-Probe, probes the bed at 3 or more points.  Will fail if you haven't homed yet.
80 80
 // G30 - Single Z Probe, probes bed at current XY location.
81
+// G31 - Dock sled (Z_PROBE_SLED only)
82
+// G32 - Undock sled (Z_PROBE_SLED only)
81 83
 // G90 - Use Absolute Coordinates
82 84
 // G91 - Use Relative Coordinates
83 85
 // G92 - Set current position to coordinates given
@@ -548,6 +550,10 @@ void setup()
548 550
   #ifdef DIGIPOT_I2C
549 551
     digipot_i2c_init();
550 552
   #endif
553
+#ifdef Z_PROBE_SLED
554
+  pinMode(SERVO0_PIN, OUTPUT);
555
+  digitalWrite(SERVO0_PIN, LOW); // turn it off
556
+#endif // Z_PROBE_SLED
551 557
 }
552 558
 
553 559
 
@@ -1035,10 +1041,14 @@ static float probe_pt(float x, float y, float z_before) {
1035 1041
   do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
1036 1042
   do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
1037 1043
 
1044
+#ifndef Z_PROBE_SLED
1038 1045
   engage_z_probe();   // Engage Z Servo endstop if available
1046
+#endif // Z_PROBE_SLED
1039 1047
   run_z_probe();
1040 1048
   float measured_z = current_position[Z_AXIS];
1049
+#ifndef Z_PROBE_SLED
1041 1050
   retract_z_probe();
1051
+#endif // Z_PROBE_SLED
1042 1052
 
1043 1053
   SERIAL_PROTOCOLPGM(MSG_BED);
1044 1054
   SERIAL_PROTOCOLPGM(" x: ");
@@ -1071,6 +1081,7 @@ static void homeaxis(int axis) {
1071 1081
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1072 1082
 
1073 1083
 
1084
+#ifndef Z_PROBE_SLED
1074 1085
     // Engage Servo endstop if enabled
1075 1086
     #ifdef SERVO_ENDSTOPS
1076 1087
       #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
@@ -1083,7 +1094,7 @@ static void homeaxis(int axis) {
1083 1094
         servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]);
1084 1095
       }
1085 1096
     #endif
1086
-
1097
+#endif // Z_PROBE_SLED
1087 1098
     destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
1088 1099
     feedrate = homing_feedrate[axis];
1089 1100
     plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
@@ -1125,7 +1136,7 @@ static void homeaxis(int axis) {
1125 1136
       }
1126 1137
     #endif
1127 1138
 #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
1128
-    if (axis==Z_AXIS) retract_z_probe();
1139
+//    if (axis==Z_AXIS) retract_z_probe();
1129 1140
 #endif
1130 1141
 
1131 1142
   }
@@ -1180,6 +1191,42 @@ void refresh_cmd_timeout(void)
1180 1191
   } //retract
1181 1192
 #endif //FWRETRACT
1182 1193
 
1194
+#ifdef ENABLE_AUTO_BED_LEVELING
1195
+//
1196
+// Method to dock/undock a sled designed by Charles Bell.
1197
+//
1198
+// dock[in]     If true, move to MAX_X and engage the electromagnet
1199
+// offset[in]   The additional distance to move to adjust docking location
1200
+//
1201
+static void dock_sled(bool dock, int offset=0) {
1202
+ int z_loc;
1203
+ 
1204
+ if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) {
1205
+   LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
1206
+   SERIAL_ECHO_START;
1207
+   SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
1208
+   return;
1209
+ }
1210
+
1211
+ if (dock) {
1212
+   do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset,
1213
+                       current_position[Y_AXIS],
1214
+                       current_position[Z_AXIS]);
1215
+   // turn off magnet
1216
+   digitalWrite(SERVO0_PIN, LOW);
1217
+ } else {
1218
+   if (current_position[Z_AXIS] < (Z_RAISE_BEFORE_PROBING + 5))
1219
+     z_loc = Z_RAISE_BEFORE_PROBING;
1220
+   else
1221
+     z_loc = current_position[Z_AXIS];
1222
+   do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset,
1223
+                       Y_PROBE_OFFSET_FROM_EXTRUDER, z_loc);
1224
+   // turn on magnet
1225
+   digitalWrite(SERVO0_PIN, HIGH);
1226
+ }
1227
+}
1228
+#endif
1229
+
1183 1230
 void process_commands()
1184 1231
 {
1185 1232
   unsigned long codenum; //throw away variable
@@ -1490,6 +1537,9 @@ void process_commands()
1490 1537
                 break; // abort G29, since we don't know where we are
1491 1538
             }
1492 1539
 
1540
+#ifdef Z_PROBE_SLED
1541
+            dock_sled(false);
1542
+#endif // Z_PROBE_SLED
1493 1543
             st_synchronize();
1494 1544
             // make sure the bed_level_rotation_matrix is identity or the planner will get it incorectly
1495 1545
             //vector_3 corrected_position = plan_get_position_mm();
@@ -1615,13 +1665,15 @@ void process_commands()
1615 1665
             apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
1616 1666
             current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
1617 1667
             plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1668
+#ifdef Z_PROBE_SLED
1669
+            dock_sled(true, -SLED_DOCKING_OFFSET); // correct for over travel.
1670
+#endif // Z_PROBE_SLED
1618 1671
         }
1619 1672
         break;
1620
-
1673
+#ifndef Z_PROBE_SLED
1621 1674
     case 30: // G30 Single Z Probe
1622 1675
         {
1623 1676
             engage_z_probe(); // Engage Z Servo endstop if available
1624
-
1625 1677
             st_synchronize();
1626 1678
             // TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
1627 1679
             setup_for_endstop_move();
@@ -1639,10 +1691,17 @@ void process_commands()
1639 1691
             SERIAL_PROTOCOLPGM("\n");
1640 1692
 
1641 1693
             clean_up_after_endstop_move();
1642
-
1643 1694
             retract_z_probe(); // Retract Z Servo endstop if available
1644 1695
         }
1645 1696
         break;
1697
+#else
1698
+    case 31: // dock the sled
1699
+        dock_sled(true);
1700
+        break;
1701
+    case 32: // undock the sled
1702
+        dock_sled(false);
1703
+        break;
1704
+#endif // Z_PROBE_SLED
1646 1705
 #endif // ENABLE_AUTO_BED_LEVELING
1647 1706
     case 90: // G90
1648 1707
       relative_mode = false;
@@ -2256,7 +2315,7 @@ Sigma_Exit:
2256 2315
 
2257 2316
       /* See if we are heating up or cooling down */
2258 2317
       target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
2259
-      
2318
+
2260 2319
       cancel_heatup = false;
2261 2320
 
2262 2321
       #ifdef TEMP_RESIDENCY_TIME
@@ -3032,7 +3091,7 @@ Sigma_Exit:
3032 3091
       st_synchronize();
3033 3092
     }
3034 3093
     break;
3035
-#if defined(ENABLE_AUTO_BED_LEVELING) && defined(SERVO_ENDSTOPS)
3094
+#if defined(ENABLE_AUTO_BED_LEVELING) && defined(SERVO_ENDSTOPS) && not defined(Z_PROBE_SLED)
3036 3095
     case 401:
3037 3096
     {
3038 3097
         engage_z_probe();    // Engage Z Servo endstop if available

+ 75
- 30
README.md Переглянути файл

@@ -1,8 +1,8 @@
1 1
 ==========================
2 2
 Marlin 3D Printer Firmware
3 3
 ==========================
4
-[![Coverity Scan Build Status](https://scan.coverity.com/projects/2224/badge.svg)](https://scan.coverity.com/projects/2224)
5
-
4
+[![Coverity Scan Build Status](https://scan.coverity.com/projects/2224/badge.svg)](https://scan.coverity.com/projects/2224)
5
+
6 6
 Marlin has a GPL license because I believe in open development.
7 7
 Please do not use this code in products (3D printers, CNC etc) that are closed source or are crippled by a patent.
8 8
 
@@ -159,6 +159,8 @@ Implemented G Codes:
159 159
 *  G28 - Home all Axis
160 160
 *  G29 - Detailed Z-Probe, probes the bed at 3 points.  You must de at the home position for this to work correctly.
161 161
 *  G30 - Single Z Probe, probes bed at current XY location.
162
+*  G31 - Dock Z Probe sled (if enabled)
163
+*  G32 - Undock Z Probe sled (if enabled)
162 164
 *  G90 - Use Absolute Coordinates
163 165
 *  G91 - Use Relative Coordinates
164 166
 *  G92 - Set current position to cordinates given
@@ -207,15 +209,15 @@ M Codes
207 209
 *  M140 - Set bed target temp
208 210
 *  M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
209 211
 *         Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
210
-*  M200 D<millimeters>- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).
212
+*  M200 D<millimeters>- set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).
211 213
 *  M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
212 214
 *  M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
213 215
 *  M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
214 216
 *  M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2  also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
215 217
 *  M205 -  advanced settings:  minimum travel speed S=while printing T=travel only,  B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk
216 218
 *  M206 - set additional homeing offset
217
-*  M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting
218
-*  M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/min]
219
+*  M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting
220
+*  M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/min]
219 221
 *  M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
220 222
 *  M218 - set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y>
221 223
 *  M220 S<factor in percent>- set speed factor override percentage
@@ -272,8 +274,46 @@ That's ok.  Enjoy Silky Smooth Printing.
272 274
 ===============================================
273 275
 Instructions for configuring Bed Auto Leveling
274 276
 ===============================================
277
+There are two options for this feature. You may choose to use a servo mounted on the X carriage or you may use a sled that mounts on the X axis and can be docked when not in use.
278
+See the section for each option below for specifics about installation and configuration. Also included are instructions that apply to both options.
279
+
280
+Note for RAMPS users:
281
+---------------------
282
+
283
+By default, RAMPS have no power on servo bus (if you happen to have a multimeter, check the voltage on servo power pins).
284
+In order to get the servo working, you need to supply 5V to 5V pin.. You can do it using your power supply (if it has a 5V output) or jumping the "Vcc" from Arduino to the 5V RAMPS rail.
285
+These 2 pins are located just between the Reset Button and the yellow fuses... There are marks in the board showing 5V and VCC.. just connect them..
286
+If jumping the arduino Vcc do RAMPS 5V rail, take care to not use a power hungry servo, otherwise you will cause a blackout in the arduino board ;-)
287
+
288
+Instructions for Both Options
289
+-----------------------------
290
+
275 291
 Uncomment the "ENABLE_AUTO_BED_LEVELING" define (commented by default)
276 292
 
293
+The following options define the probing positions. These are good starting values.
294
+I recommend to keep a better clearance from borders in the first run and then make the probes as close as possible to borders:
295
+
296
+* \#define LEFT_PROBE_BED_POSITION 30
297
+* \#define RIGHT_PROBE_BED_POSITION 140
298
+* \#define BACK_PROBE_BED_POSITION 140
299
+* \#define FRONT_PROBE_BED_POSITION 30
300
+
301
+A few more options:
302
+
303
+* \#define XY_TRAVEL_SPEED 6000
304
+
305
+X and Y axis travel speed between probes, in mm/min.
306
+Bear in mind that really fast moves may render step skipping. 6000 mm/min (100mm/s) is a good value.
307
+
308
+* \#define Z_RAISE_BEFORE_PROBING 10
309
+* \#define Z_RAISE_BETWEEN_PROBINGS 10
310
+
311
+The Z axis is lifted when traveling to the first probe point by Z_RAISE_BEFORE_PROBING value
312
+and then lifted when traveling from first to second and second to third point by Z_RAISE_BETWEEN_PROBINGS.
313
+All values are in mm as usual.
314
+
315
+Servo Option Notes
316
+------------------
277 317
 You will probably need a swivel Z-MIN endstop in the extruder. A rc servo do a great job.
278 318
 Check the system working here: http://www.youtube.com/watch?v=3IKMeOYz-1Q (Enable English subtitles)
279 319
 Teasing ;-) video: http://www.youtube.com/watch?v=x8eqSQNAyro
@@ -286,20 +326,10 @@ In order to get the servo working, you need to enable:
286 326
 
287 327
 * \#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 165,60} // X,Y,Z Axis Extend and Retract angles
288 328
 
289
-
290 329
 The first define tells firmware how many servos you have.
291 330
 The second tells what axis this servo will be attached to. In the example above, we have a servo in Z axis.
292 331
 The third one tells the angle in 2 situations: Probing (165º) and resting (60º). Check this with command M280 P0 S{angle} (example: M280 P0 S60 moves the servo to 60º)
293 332
 
294
-For RAMPS users:
295
-----------------
296
-
297
-By default, RAMPS have no power on servo bus (if you happen to have a multimeter, check the voltage on servo power pins).
298
-In order to get the servo working, you need to supply 5V to 5V pin.. You can do it using your power supply (if it has a 5V output) or jumping the "Vcc" from Arduino to the 5V RAMPS rail.
299
-These 2 pins are located just between the Reset Button and the yellow fuses... There are marks in the board showing 5V and VCC.. just connect them..
300
-If jumping the arduino Vcc do RAMPS 5V rail, take care to not use a power hungry servo, otherwise you will cause a blackout in the arduino board ;-)
301
-
302
-
303 333
 Next you need to define the Z endstop (probe) offset from hotend.
304 334
 My preferred method:
305 335
 
@@ -317,27 +347,42 @@ My preferred method:
317 347
 * \#define Z_PROBE_OFFSET_FROM_EXTRUDER -5.1
318 348
 
319 349
 
320
-The following options define the probing positions. These are good starting values.
321
-I recommend to keep a better clearance from borders in the first run and then make the probes as close as possible to borders:
350
+Sled Option Notes
351
+-----------------
352
+The sled option uses an electromagnet to attach and detach to/from the X carriage. See http://www.thingiverse.com/thing:396692 for more details on how to print and install this feature. It uses the same connections as the servo option.
322 353
 
323
-* \#define LEFT_PROBE_BED_POSITION 30
324
-* \#define RIGHT_PROBE_BED_POSITION 140
325
-* \#define BACK_PROBE_BED_POSITION 140
326
-* \#define FRONT_PROBE_BED_POSITION 30
354
+To use the sled option, you must define two additional things in Configuration.h:
327 355
 
328
-A few more options:
356
+* \#define Z_PROBE_SLED
357
+* \#define SLED_DOCKING_OFFSET 5
329 358
 
330
-* \#define XY_TRAVEL_SPEED 6000
359
+Uncomment the Z_PROBE_SLED to define to enable the sled (commented out by default).
331 360
 
332
-X and Y axis travel speed between probes, in mm/min.
333
-Bear in mind that really fast moves may render step skipping. 6000 mm/min (100mm/s) is a good value.
361
+Uncomment the SLED_DOCKING_OFFSET to set the extra distance the X axis must travel to dock the sled. This value can be found by moving the X axis to its maximum position then measure the distance to the right X end and subtract the width of the sled (23mm if you printed the sled from Thingiverse).
334 362
 
335
-* \#define Z_RAISE_BEFORE_PROBING 10
336
-* \#define Z_RAISE_BETWEEN_PROBINGS 10
363
+Next you need to define the Z endstop (probe) offset from hotend.
364
+My preferred method:
337 365
 
338
-The Z axis is lifted when traveling to the first probe point by Z_RAISE_BEFORE_PROBING value
339
-and then lifted when traveling from first to second and second to third point by Z_RAISE_BETWEEN_PROBINGS.
340
-All values are in mm as usual. 
366
+* a) Home the X and Y axes.
367
+* b) Move the X axis to about the center of the print bed. Make a mark on the print bed.
368
+* c) Move the Y axis to the maximum position. Make another mark.
369
+* d) Home the X axis and use a straight edge to make a line between the two points.
370
+* e) Repeat (b)-(d) reversing the X and Y. When you are done you will have two lines on the print bed. We will use these to measure the offset for the Z probe endstop.
371
+* f) Move the nozzle so that it is positioned on the center point of the two lines. You can use fine movement of 0.1mm to get it as close as possible. Note the position of X and Y.
372
+* g) Zero the Z axis with the G92 Z0 command.
373
+* h) Raise the Z axis about 20mmm.
374
+* i) Use the G32 command to retrieve the sled.
375
+* j) Now more the X and Y axis to the position recorded in (f).
376
+* k) Lower the Z axis in 0.1mm steps until you hear the "click" meaning the mechanical endstop was trigged. You can confirm with the M119 command. Note the position of the Z axis.
377
+* l) Make a mark on the print bed where the endstop lever has touched the print bed. Raise the Z-axis about 30mm to give yourself some room.
378
+* m) Now measure the distance from the center point to the endstop impact site along the X and Y axis using the lines drawn previously.
379
+* n) Fill in the values below. If the endstop mark is in front of the line running left-to-right, use positive values. If it is behind, use negative values. For the Z axis use the value from (k) and subtract 0.1mm.
380
+
381
+For example, suppose you measured the endstop position and it was 20mm to the right of the line running front-to-back, 10mm toward the front of the line running left-to-right, and the value from (k) was 2.85. The values for the defines would be:
382
+
383
+* \#define X_PROBE_OFFSET_FROM_EXTRUDER 20
384
+* \#define Y_PROBE_OFFSET_FROM_EXTRUDER 10
385
+* \#define Z_PROBE_OFFSET_FROM_EXTRUDER 2.75
341 386
 
342 387
 That's it.. enjoy never having to calibrate your Z endstop neither leveling your bed by hand anymore ;-)
343 388
 

Завантаження…
Відмінити
Зберегти