Browse Source

Include sync_plan_position_delta for SCARA also

Scott Lahteine 10 years ago
parent
commit
1c7391717e
1 changed files with 92 additions and 100 deletions
  1. 92
    100
      Marlin/Marlin_main.cpp

+ 92
- 100
Marlin/Marlin_main.cpp View File

@@ -1034,7 +1034,7 @@ inline void line_to_destination() {
1034 1034
 inline void sync_plan_position() {
1035 1035
   plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1036 1036
 }
1037
-#ifdef DELTA
1037
+#if defined(DELTA) || defined(SCARA)
1038 1038
   inline void sync_plan_position_delta() {
1039 1039
     calculate_delta(current_position);
1040 1040
     plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
@@ -2177,8 +2177,7 @@ inline void gcode_G28() {
2177 2177
         bool do_topography_map = verbose_level > 2 || code_seen('T') || code_seen('t');
2178 2178
       #endif
2179 2179
 
2180
-      if (verbose_level > 0)
2181
-      {
2180
+      if (verbose_level > 0) {
2182 2181
         SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n");
2183 2182
         if (dryrun) SERIAL_ECHOLN("Running in DRY-RUN mode");
2184 2183
       }
@@ -2253,10 +2252,9 @@ inline void gcode_G28() {
2253 2252
         current_position[Y_AXIS] = uncorrected_position.y;
2254 2253
         current_position[Z_AXIS] = uncorrected_position.z;
2255 2254
         sync_plan_position();
2256
-
2257 2255
       #endif // !DELTA
2258 2256
     }
2259
-    
2257
+
2260 2258
     setup_for_endstop_move();
2261 2259
 
2262 2260
     feedrate = homing_feedrate[Z_AXIS];
@@ -2264,8 +2262,8 @@ inline void gcode_G28() {
2264 2262
     #ifdef AUTO_BED_LEVELING_GRID
2265 2263
 
2266 2264
       // probe at the points of a lattice grid
2267
-      const int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points-1);
2268
-      const int yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points-1);
2265
+      const int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points - 1),
2266
+                yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points - 1);
2269 2267
 
2270 2268
       #ifdef DELTA
2271 2269
         delta_grid_spacing[0] = xGridSpacing;
@@ -5255,104 +5253,99 @@ void clamp_to_software_endstops(float target[3])
5255 5253
 }
5256 5254
 
5257 5255
 #ifdef DELTA
5258
-void recalc_delta_settings(float radius, float diagonal_rod)
5259
-{
5260
-   delta_tower1_x= -SIN_60*radius; // front left tower
5261
-   delta_tower1_y= -COS_60*radius;     
5262
-   delta_tower2_x=  SIN_60*radius; // front right tower
5263
-   delta_tower2_y= -COS_60*radius;     
5264
-   delta_tower3_x= 0.0;                  // back middle tower
5265
-   delta_tower3_y= radius;
5266
-   delta_diagonal_rod_2= sq(diagonal_rod);
5267
-}
5268 5256
 
5269
-void calculate_delta(float cartesian[3])
5270
-{
5271
-  delta[X_AXIS] = sqrt(delta_diagonal_rod_2
5272
-                       - sq(delta_tower1_x-cartesian[X_AXIS])
5273
-                       - sq(delta_tower1_y-cartesian[Y_AXIS])
5274
-                       ) + cartesian[Z_AXIS];
5275
-  delta[Y_AXIS] = sqrt(delta_diagonal_rod_2
5276
-                       - sq(delta_tower2_x-cartesian[X_AXIS])
5277
-                       - sq(delta_tower2_y-cartesian[Y_AXIS])
5278
-                       ) + cartesian[Z_AXIS];
5279
-  delta[Z_AXIS] = sqrt(delta_diagonal_rod_2
5280
-                       - sq(delta_tower3_x-cartesian[X_AXIS])
5281
-                       - sq(delta_tower3_y-cartesian[Y_AXIS])
5282
-                       ) + cartesian[Z_AXIS];
5283
-  /*
5284
-  SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);
5285
-  SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]);
5286
-  SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]);
5257
+  void recalc_delta_settings(float radius, float diagonal_rod) {
5258
+    delta_tower1_x = -SIN_60 * radius;  // front left tower
5259
+    delta_tower1_y = -COS_60 * radius;
5260
+    delta_tower2_x =  SIN_60 * radius;  // front right tower
5261
+    delta_tower2_y = -COS_60 * radius;
5262
+    delta_tower3_x = 0.0;               // back middle tower
5263
+    delta_tower3_y = radius;
5264
+    delta_diagonal_rod_2 = sq(diagonal_rod);
5265
+  }
5287 5266
 
5288
-  SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]);
5289
-  SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]);
5290
-  SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]);
5291
-  */
5292
-}
5267
+  void calculate_delta(float cartesian[3]) {
5268
+    delta[X_AXIS] = sqrt(delta_diagonal_rod_2
5269
+                         - sq(delta_tower1_x-cartesian[X_AXIS])
5270
+                         - sq(delta_tower1_y-cartesian[Y_AXIS])
5271
+                         ) + cartesian[Z_AXIS];
5272
+    delta[Y_AXIS] = sqrt(delta_diagonal_rod_2
5273
+                         - sq(delta_tower2_x-cartesian[X_AXIS])
5274
+                         - sq(delta_tower2_y-cartesian[Y_AXIS])
5275
+                         ) + cartesian[Z_AXIS];
5276
+    delta[Z_AXIS] = sqrt(delta_diagonal_rod_2
5277
+                         - sq(delta_tower3_x-cartesian[X_AXIS])
5278
+                         - sq(delta_tower3_y-cartesian[Y_AXIS])
5279
+                         ) + cartesian[Z_AXIS];
5280
+    /*
5281
+    SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]);
5282
+    SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]);
5283
+    SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]);
5284
+
5285
+    SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]);
5286
+    SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]);
5287
+    SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]);
5288
+    */
5289
+  }
5293 5290
 
5294
-#ifdef ENABLE_AUTO_BED_LEVELING
5295
-// Adjust print surface height by linear interpolation over the bed_level array.
5296
-int delta_grid_spacing[2] = { 0, 0 };
5297
-void adjust_delta(float cartesian[3])
5298
-{
5299
-  if (delta_grid_spacing[0] == 0 || delta_grid_spacing[1] == 0)
5300
-    return; // G29 not done
5301
-
5302
-  int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
5303
-  float grid_x = max(0.001-half, min(half-0.001, cartesian[X_AXIS] / delta_grid_spacing[0]));
5304
-  float grid_y = max(0.001-half, min(half-0.001, cartesian[Y_AXIS] / delta_grid_spacing[1]));
5305
-  int floor_x = floor(grid_x);
5306
-  int floor_y = floor(grid_y);
5307
-  float ratio_x = grid_x - floor_x;
5308
-  float ratio_y = grid_y - floor_y;
5309
-  float z1 = bed_level[floor_x+half][floor_y+half];
5310
-  float z2 = bed_level[floor_x+half][floor_y+half+1];
5311
-  float z3 = bed_level[floor_x+half+1][floor_y+half];
5312
-  float z4 = bed_level[floor_x+half+1][floor_y+half+1];
5313
-  float left = (1-ratio_y)*z1 + ratio_y*z2;
5314
-  float right = (1-ratio_y)*z3 + ratio_y*z4;
5315
-  float offset = (1-ratio_x)*left + ratio_x*right;
5316
-
5317
-  delta[X_AXIS] += offset;
5318
-  delta[Y_AXIS] += offset;
5319
-  delta[Z_AXIS] += offset;
5291
+  #ifdef ENABLE_AUTO_BED_LEVELING
5320 5292
 
5321
-  /*
5322
-  SERIAL_ECHOPGM("grid_x="); SERIAL_ECHO(grid_x);
5323
-  SERIAL_ECHOPGM(" grid_y="); SERIAL_ECHO(grid_y);
5324
-  SERIAL_ECHOPGM(" floor_x="); SERIAL_ECHO(floor_x);
5325
-  SERIAL_ECHOPGM(" floor_y="); SERIAL_ECHO(floor_y);
5326
-  SERIAL_ECHOPGM(" ratio_x="); SERIAL_ECHO(ratio_x);
5327
-  SERIAL_ECHOPGM(" ratio_y="); SERIAL_ECHO(ratio_y);
5328
-  SERIAL_ECHOPGM(" z1="); SERIAL_ECHO(z1);
5329
-  SERIAL_ECHOPGM(" z2="); SERIAL_ECHO(z2);
5330
-  SERIAL_ECHOPGM(" z3="); SERIAL_ECHO(z3);
5331
-  SERIAL_ECHOPGM(" z4="); SERIAL_ECHO(z4);
5332
-  SERIAL_ECHOPGM(" left="); SERIAL_ECHO(left);
5333
-  SERIAL_ECHOPGM(" right="); SERIAL_ECHO(right);
5334
-  SERIAL_ECHOPGM(" offset="); SERIAL_ECHOLN(offset);
5335
-  */
5336
-}
5337
-#endif //ENABLE_AUTO_BED_LEVELING
5293
+    // Adjust print surface height by linear interpolation over the bed_level array.
5294
+    int delta_grid_spacing[2] = { 0, 0 };
5295
+    void adjust_delta(float cartesian[3]) {
5296
+      if (delta_grid_spacing[0] == 0 || delta_grid_spacing[1] == 0) return; // G29 not done!
5297
+
5298
+      int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
5299
+      float h1 = 0.001 - half, h2 = half - 0.001,
5300
+            grid_x = max(h1, min(h2, cartesian[X_AXIS] / delta_grid_spacing[0])),
5301
+            grid_y = max(h1, min(h2, cartesian[Y_AXIS] / delta_grid_spacing[1]));
5302
+      int floor_x = floor(grid_x), floor_y = floor(grid_y);
5303
+      float ratio_x = grid_x - floor_x, ratio_y = grid_y - floor_y,
5304
+            z1 = bed_level[floor_x + half][floor_y + half],
5305
+            z2 = bed_level[floor_x + half][floor_y + half + 1],
5306
+            z3 = bed_level[floor_x + half + 1][floor_y + half],
5307
+            z4 = bed_level[floor_x + half + 1][floor_y + half + 1],
5308
+            left = (1 - ratio_y) * z1 + ratio_y * z2,
5309
+            right = (1 - ratio_y) * z3 + ratio_y * z4,
5310
+            offset = (1 - ratio_x) * left + ratio_x * right;
5311
+
5312
+      delta[X_AXIS] += offset;
5313
+      delta[Y_AXIS] += offset;
5314
+      delta[Z_AXIS] += offset;
5315
+
5316
+      /*
5317
+      SERIAL_ECHOPGM("grid_x="); SERIAL_ECHO(grid_x);
5318
+      SERIAL_ECHOPGM(" grid_y="); SERIAL_ECHO(grid_y);
5319
+      SERIAL_ECHOPGM(" floor_x="); SERIAL_ECHO(floor_x);
5320
+      SERIAL_ECHOPGM(" floor_y="); SERIAL_ECHO(floor_y);
5321
+      SERIAL_ECHOPGM(" ratio_x="); SERIAL_ECHO(ratio_x);
5322
+      SERIAL_ECHOPGM(" ratio_y="); SERIAL_ECHO(ratio_y);
5323
+      SERIAL_ECHOPGM(" z1="); SERIAL_ECHO(z1);
5324
+      SERIAL_ECHOPGM(" z2="); SERIAL_ECHO(z2);
5325
+      SERIAL_ECHOPGM(" z3="); SERIAL_ECHO(z3);
5326
+      SERIAL_ECHOPGM(" z4="); SERIAL_ECHO(z4);
5327
+      SERIAL_ECHOPGM(" left="); SERIAL_ECHO(left);
5328
+      SERIAL_ECHOPGM(" right="); SERIAL_ECHO(right);
5329
+      SERIAL_ECHOPGM(" offset="); SERIAL_ECHOLN(offset);
5330
+      */
5331
+    }
5332
+  #endif // ENABLE_AUTO_BED_LEVELING
5338 5333
 
5339
-void prepare_move_raw()
5340
-{
5341
-  previous_millis_cmd = millis();
5342
-  calculate_delta(destination);
5343
-  plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],
5344
-                   destination[E_AXIS], feedrate*feedmultiply/60/100.0,
5345
-                   active_extruder);
5346
-  for(int8_t i=0; i < NUM_AXIS; i++) {
5347
-    current_position[i] = destination[i];
5334
+  void prepare_move_raw() {
5335
+    previous_millis_cmd = millis();
5336
+    calculate_delta(destination);
5337
+    plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], (feedrate/60)*(feedmultiply/100.0), active_extruder);
5338
+    for (int i = 0; i < NUM_AXIS; i++) current_position[i] = destination[i];
5348 5339
   }
5349
-}
5350
-#endif //DELTA
5340
+
5341
+#endif // DELTA
5351 5342
 
5352 5343
 #if defined(MESH_BED_LEVELING)
5353
-#if !defined(MIN)
5354
-#define MIN(_v1, _v2) (((_v1) < (_v2)) ? (_v1) : (_v2))
5355
-#endif  // ! MIN
5344
+
5345
+  #if !defined(MIN)
5346
+    #define MIN(_v1, _v2) (((_v1) < (_v2)) ? (_v1) : (_v2))
5347
+  #endif  // ! MIN
5348
+
5356 5349
 // This function is used to split lines on mesh borders so each segment is only part of one mesh area
5357 5350
 void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_rate, const uint8_t &extruder, uint8_t x_splits=0xff, uint8_t y_splits=0xff)
5358 5351
 {
@@ -5424,8 +5417,7 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
5424 5417
 }
5425 5418
 #endif  // MESH_BED_LEVELING
5426 5419
 
5427
-void prepare_move()
5428
-{
5420
+void prepare_move() {
5429 5421
   clamp_to_software_endstops(destination);
5430 5422
   previous_millis_cmd = millis();
5431 5423
   
@@ -5539,7 +5531,7 @@ void prepare_move()
5539 5531
   }
5540 5532
 #endif //DUAL_X_CARRIAGE
5541 5533
 
5542
-#if ! (defined DELTA || defined SCARA)
5534
+#if !defined(DELTA) && !defined(SCARA)
5543 5535
   // Do not use feedmultiply for E or Z only moves
5544 5536
   if( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
5545 5537
     line_to_destination();

Loading…
Cancel
Save