Browse Source

ARRAY_BY_EXTRUDERS, shorthand to sync planner

- Add some documentation to planner and stepper headers
- Patch up RAMBO pins with undefs
- Add `sync_plan_position` inline to set current XYZE
- Swap indices in `extruder_offset` to fix initialization values
Scott Lahteine 10 years ago
parent
commit
afff968e88
5 changed files with 111 additions and 136 deletions
  1. 76
    129
      Marlin/Marlin_main.cpp
  2. 12
    0
      Marlin/pins_RAMBO.h
  3. 1
    1
      Marlin/planner.cpp
  4. 21
    5
      Marlin/planner.h
  5. 1
    1
      Marlin/stepper.cpp

+ 76
- 129
Marlin/Marlin_main.cpp View File

211
 int feedmultiply = 100; //100->1 200->2
211
 int feedmultiply = 100; //100->1 200->2
212
 int saved_feedmultiply;
212
 int saved_feedmultiply;
213
 int extrudemultiply = 100; //100->1 200->2
213
 int extrudemultiply = 100; //100->1 200->2
214
-int extruder_multiply[EXTRUDERS] = { 100
215
-  #if EXTRUDERS > 1
216
-    , 100
217
-    #if EXTRUDERS > 2
218
-      , 100
219
-      #if EXTRUDERS > 3
220
-        , 100
221
-      #endif
222
-    #endif
223
-  #endif
224
-};
214
+int extruder_multiply[EXTRUDERS] = ARRAY_BY_EXTRUDERS(100, 100, 100, 100);
225
 bool volumetric_enabled = false;
215
 bool volumetric_enabled = false;
226
-float filament_size[EXTRUDERS] = { DEFAULT_NOMINAL_FILAMENT_DIA
227
-  #if EXTRUDERS > 1
228
-      , DEFAULT_NOMINAL_FILAMENT_DIA
229
-    #if EXTRUDERS > 2
230
-       , DEFAULT_NOMINAL_FILAMENT_DIA
231
-      #if EXTRUDERS > 3
232
-        , DEFAULT_NOMINAL_FILAMENT_DIA
233
-      #endif
234
-    #endif
235
-  #endif
236
-};
237
-float volumetric_multiplier[EXTRUDERS] = {1.0
238
-  #if EXTRUDERS > 1
239
-    , 1.0
240
-    #if EXTRUDERS > 2
241
-      , 1.0
242
-      #if EXTRUDERS > 3
243
-        , 1.0
244
-      #endif
245
-    #endif
246
-  #endif
247
-};
248
-float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
249
-float home_offset[3] = { 0, 0, 0 };
216
+float filament_size[EXTRUDERS] = ARRAY_BY_EXTRUDERS(DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA, DEFAULT_NOMINAL_FILAMENT_DIA);
217
+float volumetric_multiplier[EXTRUDERS] = ARRAY_BY_EXTRUDERS(1.0, 1.0, 1.0, 1.0);
218
+float current_position[NUM_AXIS] = { 0.0 };
219
+float home_offset[3] = { 0 };
250
 #ifdef DELTA
220
 #ifdef DELTA
251
-  float endstop_adj[3] = { 0, 0, 0 };
221
+  float endstop_adj[3] = { 0 };
252
 #elif defined(Z_DUAL_ENDSTOPS)
222
 #elif defined(Z_DUAL_ENDSTOPS)
253
   float z_endstop_adj = 0;
223
   float z_endstop_adj = 0;
254
 #endif
224
 #endif
255
 
225
 
256
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
226
 float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
257
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
227
 float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
258
-bool axis_known_position[3] = { false, false, false };
228
+bool axis_known_position[3] = { false };
259
 
229
 
260
 // Extruder offset
230
 // Extruder offset
261
 #if EXTRUDERS > 1
231
 #if EXTRUDERS > 1
262
-#ifndef DUAL_X_CARRIAGE
263
-  #define NUM_EXTRUDER_OFFSETS 2 // only in XY plane
264
-#else
265
-  #define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
266
-#endif
267
-float extruder_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = {
268
-  #if defined(EXTRUDER_OFFSET_X)
269
-    EXTRUDER_OFFSET_X
270
-  #else
271
-    0
232
+  #ifndef EXTRUDER_OFFSET_X
233
+    #define EXTRUDER_OFFSET_X 0
272
   #endif
234
   #endif
273
-  ,
274
-  #if defined(EXTRUDER_OFFSET_Y)
275
-    EXTRUDER_OFFSET_Y
235
+  #ifndef EXTRUDER_OFFSET_Y
236
+    #define EXTRUDER_OFFSET_Y 0
237
+  #endif
238
+  #ifndef DUAL_X_CARRIAGE
239
+    #define NUM_EXTRUDER_OFFSETS 2 // only in XY plane
276
   #else
240
   #else
277
-    0
241
+    #define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
278
   #endif
242
   #endif
279
-};
243
+  #define _EXY { EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y }
244
+  float extruder_offset[EXTRUDERS][NUM_EXTRUDER_OFFSETS] = ARRAY_BY_EXTRUDERS(_EXY, _EXY, _EXY, _EXY);
280
 #endif
245
 #endif
281
 
246
 
282
 uint8_t active_extruder = 0;
247
 uint8_t active_extruder = 0;
295
 #ifdef FWRETRACT
260
 #ifdef FWRETRACT
296
 
261
 
297
   bool autoretract_enabled = false;
262
   bool autoretract_enabled = false;
298
-  bool retracted[EXTRUDERS] = { false
299
-    #if EXTRUDERS > 1
300
-      , false
301
-      #if EXTRUDERS > 2
302
-        , false
303
-        #if EXTRUDERS > 3
304
-          , false
305
-        #endif
306
-      #endif
307
-    #endif
308
-  };
309
-  bool retracted_swap[EXTRUDERS] = { false
310
-    #if EXTRUDERS > 1
311
-      , false
312
-      #if EXTRUDERS > 2
313
-        , false
314
-        #if EXTRUDERS > 3
315
-          , false
316
-        #endif
317
-      #endif
318
-    #endif
319
-  };
263
+  bool retracted[EXTRUDERS] = { false };
264
+  bool retracted_swap[EXTRUDERS] = { false };
320
 
265
 
321
   float retract_length = RETRACT_LENGTH;
266
   float retract_length = RETRACT_LENGTH;
322
   float retract_length_swap = RETRACT_LENGTH_SWAP;
267
   float retract_length_swap = RETRACT_LENGTH_SWAP;
385
 const char echomagic[] PROGMEM = "echo:";
330
 const char echomagic[] PROGMEM = "echo:";
386
 
331
 
387
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
332
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
388
-static float destination[NUM_AXIS] = { 0, 0, 0, 0 };
333
+static float destination[NUM_AXIS] = { 0 };
389
 
334
 
390
-static float offset[3] = { 0, 0, 0 };
335
+static float offset[3] = { 0 };
391
 
336
 
392
 #ifndef DELTA
337
 #ifndef DELTA
393
   static bool home_all_axis = true;
338
   static bool home_all_axis = true;
993
       // second X-carriage offset when homed - otherwise X2_HOME_POS is used.
938
       // second X-carriage offset when homed - otherwise X2_HOME_POS is used.
994
       // This allow soft recalibration of the second extruder offset position without firmware reflash
939
       // This allow soft recalibration of the second extruder offset position without firmware reflash
995
       // (through the M218 command).
940
       // (through the M218 command).
996
-      return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
941
+      return (extruder_offset[1][X_AXIS] > 0) ? extruder_offset[1][X_AXIS] : X2_HOME_POS;
997
   }
942
   }
998
 
943
 
999
   static int x_home_dir(int extruder) {
944
   static int x_home_dir(int extruder) {
1017
       if (active_extruder != 0) {
962
       if (active_extruder != 0) {
1018
         current_position[X_AXIS] = x_home_pos(active_extruder);
963
         current_position[X_AXIS] = x_home_pos(active_extruder);
1019
         min_pos[X_AXIS] = X2_MIN_POS;
964
         min_pos[X_AXIS] = X2_MIN_POS;
1020
-        max_pos[X_AXIS] = max(extruder_offset[X_AXIS][1], X2_MAX_POS);
965
+        max_pos[X_AXIS] = max(extruder_offset[1][X_AXIS], X2_MAX_POS);
1021
         return;
966
         return;
1022
       }
967
       }
1023
       else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) {
968
       else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) {
1024
         current_position[X_AXIS] = base_home_pos(X_AXIS) + home_offset[X_AXIS];
969
         current_position[X_AXIS] = base_home_pos(X_AXIS) + home_offset[X_AXIS];
1025
         min_pos[X_AXIS] = base_min_pos(X_AXIS) + home_offset[X_AXIS];
970
         min_pos[X_AXIS] = base_min_pos(X_AXIS) + home_offset[X_AXIS];
1026
         max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + home_offset[X_AXIS],
971
         max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + home_offset[X_AXIS],
1027
-                                max(extruder_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
972
+                                max(extruder_offset[1][X_AXIS], X2_MAX_POS) - duplicate_extruder_x_offset);
1028
         return;
973
         return;
1029
       }
974
       }
1030
     }
975
     }
1077
   #endif
1022
   #endif
1078
 }
1023
 }
1079
 
1024
 
1025
+/**
1026
+ * Shorthand to tell the planner our current position (in mm).
1027
+ */
1028
+inline void sync_plan_position() {
1029
+  plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1030
+}
1031
+
1080
 #ifdef ENABLE_AUTO_BED_LEVELING
1032
 #ifdef ENABLE_AUTO_BED_LEVELING
1081
 #ifdef AUTO_BED_LEVELING_GRID
1033
 #ifdef AUTO_BED_LEVELING_GRID
1082
 
1034
 
1083
 #ifndef DELTA
1035
 #ifndef DELTA
1084
-static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
1085
-{
1036
+  static void set_bed_level_equation_lsq(double *plane_equation_coefficients) {
1086
     vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
1037
     vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
1087
     planeNormal.debug("planeNormal");
1038
     planeNormal.debug("planeNormal");
1088
     plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
1039
     plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
1093
     //uncorrected_position.debug("position before");
1044
     //uncorrected_position.debug("position before");
1094
 
1045
 
1095
     vector_3 corrected_position = plan_get_position();
1046
     vector_3 corrected_position = plan_get_position();
1096
-//    corrected_position.debug("position after");
1047
+    //corrected_position.debug("position after");
1097
     current_position[X_AXIS] = corrected_position.x;
1048
     current_position[X_AXIS] = corrected_position.x;
1098
     current_position[Y_AXIS] = corrected_position.y;
1049
     current_position[Y_AXIS] = corrected_position.y;
1099
-    current_position[Z_AXIS] = corrected_position.z;
1050
+    current_position[Z_AXIS] = zprobe_zoffset; // was: corrected_position.z
1100
 
1051
 
1101
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1102
-}
1052
+    sync_plan_position();
1053
+  }
1103
 #endif
1054
 #endif
1104
 
1055
 
1105
 #else // not AUTO_BED_LEVELING_GRID
1056
 #else // not AUTO_BED_LEVELING_GRID
1124
     vector_3 corrected_position = plan_get_position();
1075
     vector_3 corrected_position = plan_get_position();
1125
     current_position[X_AXIS] = corrected_position.x;
1076
     current_position[X_AXIS] = corrected_position.x;
1126
     current_position[Y_AXIS] = corrected_position.y;
1077
     current_position[Y_AXIS] = corrected_position.y;
1127
-    current_position[Z_AXIS] = corrected_position.z;
1078
+    current_position[Z_AXIS] = zprobe_zoffset; // was: corrected_position.z
1128
 
1079
 
1129
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1080
+    sync_plan_position();
1130
 }
1081
 }
1131
 
1082
 
1132
 #endif // AUTO_BED_LEVELING_GRID
1083
 #endif // AUTO_BED_LEVELING_GRID
1172
     endstops_hit_on_purpose();
1123
     endstops_hit_on_purpose();
1173
 
1124
 
1174
     // move back down slowly to find bed
1125
     // move back down slowly to find bed
1175
-    
1176
-    if (homing_bump_divisor[Z_AXIS] >= 1)
1177
-    {
1178
-        feedrate = homing_feedrate[Z_AXIS]/homing_bump_divisor[Z_AXIS];
1126
+    if (homing_bump_divisor[Z_AXIS] >= 1) {
1127
+      feedrate = homing_feedrate[Z_AXIS]/homing_bump_divisor[Z_AXIS];
1179
     } 
1128
     } 
1180
-    else
1181
-    {
1182
-        feedrate = homing_feedrate[Z_AXIS]/10;
1183
-        SERIAL_ECHOLN("Warning: The Homing Bump Feedrate Divisor cannot be less then 1");
1129
+    else {
1130
+      feedrate = homing_feedrate[Z_AXIS]/10;
1131
+      SERIAL_ECHOLN("Warning: The Homing Bump Feedrate Divisor cannot be less then 1");
1184
     }
1132
     }
1185
 
1133
 
1186
-    
1187
     zPosition -= home_retract_mm(Z_AXIS) * 2;
1134
     zPosition -= home_retract_mm(Z_AXIS) * 2;
1188
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1135
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder);
1189
     st_synchronize();
1136
     st_synchronize();
1191
 
1138
 
1192
     current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
1139
     current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
1193
     // make sure the planner knows where we are as it may be a bit different than we last said to move to
1140
     // make sure the planner knows where we are as it may be a bit different than we last said to move to
1194
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1141
+    sync_plan_position();
1195
     
1142
     
1196
   #endif
1143
   #endif
1197
 }
1144
 }
1471
 #endif
1418
 #endif
1472
 
1419
 
1473
     current_position[axis] = 0;
1420
     current_position[axis] = 0;
1474
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1421
+    sync_plan_position();
1475
 
1422
 
1476
 
1423
 
1477
 #ifndef Z_PROBE_SLED
1424
 #ifndef Z_PROBE_SLED
1497
     st_synchronize();
1444
     st_synchronize();
1498
 
1445
 
1499
     current_position[axis] = 0;
1446
     current_position[axis] = 0;
1500
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1447
+    sync_plan_position();
1501
     destination[axis] = -home_retract_mm(axis) * axis_home_dir;
1448
     destination[axis] = -home_retract_mm(axis) * axis_home_dir;
1502
     plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
1449
     plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
1503
     st_synchronize();
1450
     st_synchronize();
1520
       if (axis==Z_AXIS)
1467
       if (axis==Z_AXIS)
1521
       {
1468
       {
1522
         feedrate = homing_feedrate[axis];
1469
         feedrate = homing_feedrate[axis];
1523
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1470
+        sync_plan_position();
1524
         if (axis_home_dir > 0)
1471
         if (axis_home_dir > 0)
1525
         {
1472
         {
1526
           destination[axis] = (-1) * fabs(z_endstop_adj);
1473
           destination[axis] = (-1) * fabs(z_endstop_adj);
1540
 #ifdef DELTA
1487
 #ifdef DELTA
1541
     // retrace by the amount specified in endstop_adj
1488
     // retrace by the amount specified in endstop_adj
1542
     if (endstop_adj[axis] * axis_home_dir < 0) {
1489
     if (endstop_adj[axis] * axis_home_dir < 0) {
1543
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1490
+      sync_plan_position();
1544
       destination[axis] = endstop_adj[axis];
1491
       destination[axis] = endstop_adj[axis];
1545
       plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
1492
       plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
1546
       st_synchronize();
1493
       st_synchronize();
1596
          calculate_delta(current_position); // change cartesian kinematic to  delta kinematic;
1543
          calculate_delta(current_position); // change cartesian kinematic to  delta kinematic;
1597
          plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
1544
          plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
1598
 #else
1545
 #else
1599
-         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1546
+         sync_plan_position();
1600
 #endif
1547
 #endif
1601
          prepare_move();
1548
          prepare_move();
1602
       }
1549
       }
1612
          calculate_delta(current_position); // change cartesian kinematic  to  delta kinematic;
1559
          calculate_delta(current_position); // change cartesian kinematic  to  delta kinematic;
1613
          plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
1560
          plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
1614
 #else
1561
 #else
1615
-         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1562
+         sync_plan_position();
1616
 #endif
1563
 #endif
1617
          //prepare_move();
1564
          //prepare_move();
1618
       }
1565
       }
1789
 
1736
 
1790
     // Move all carriages up together until the first endstop is hit.
1737
     // Move all carriages up together until the first endstop is hit.
1791
     for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = 0;
1738
     for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = 0;
1792
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1739
+    sync_plan_position();
1793
 
1740
 
1794
     for (int i = X_AXIS; i <= Z_AXIS; i++) destination[i] = 3 * Z_MAX_LENGTH;
1741
     for (int i = X_AXIS; i <= Z_AXIS; i++) destination[i] = 3 * Z_MAX_LENGTH;
1795
     feedrate = 1.732 * homing_feedrate[X_AXIS];
1742
     feedrate = 1.732 * homing_feedrate[X_AXIS];
1829
           extruder_duplication_enabled = false;
1776
           extruder_duplication_enabled = false;
1830
         #endif
1777
         #endif
1831
 
1778
 
1832
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1779
+        sync_plan_position();
1833
         destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;
1780
         destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;
1834
         destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS);
1781
         destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS);
1835
         feedrate = homing_feedrate[X_AXIS];
1782
         feedrate = homing_feedrate[X_AXIS];
1844
 
1791
 
1845
         axis_is_at_home(X_AXIS);
1792
         axis_is_at_home(X_AXIS);
1846
         axis_is_at_home(Y_AXIS);
1793
         axis_is_at_home(Y_AXIS);
1847
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1794
+        sync_plan_position();
1848
         destination[X_AXIS] = current_position[X_AXIS];
1795
         destination[X_AXIS] = current_position[X_AXIS];
1849
         destination[Y_AXIS] = current_position[Y_AXIS];
1796
         destination[Y_AXIS] = current_position[Y_AXIS];
1850
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
1797
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
1921
           feedrate = XY_TRAVEL_SPEED / 60;
1868
           feedrate = XY_TRAVEL_SPEED / 60;
1922
           current_position[Z_AXIS] = 0;
1869
           current_position[Z_AXIS] = 0;
1923
 
1870
 
1924
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1871
+          sync_plan_position();
1925
           plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1872
           plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1926
           st_synchronize();
1873
           st_synchronize();
1927
           current_position[X_AXIS] = destination[X_AXIS];
1874
           current_position[X_AXIS] = destination[X_AXIS];
1973
       if (home_all_axis || code_seen(axis_codes[Z_AXIS]))
1920
       if (home_all_axis || code_seen(axis_codes[Z_AXIS]))
1974
         current_position[Z_AXIS] += zprobe_zoffset;  //Add Z_Probe offset (the distance is negative)
1921
         current_position[Z_AXIS] += zprobe_zoffset;  //Add Z_Probe offset (the distance is negative)
1975
     #endif
1922
     #endif
1976
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1923
+    sync_plan_position();
1977
 
1924
 
1978
   #endif // else DELTA
1925
   #endif // else DELTA
1979
 
1926
 
1998
       plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1945
       plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
1999
       st_synchronize();
1946
       st_synchronize();
2000
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
1947
       current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2001
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1948
+      sync_plan_position();
2002
       mbl.active = 1;
1949
       mbl.active = 1;
2003
     }
1950
     }
2004
   #endif
1951
   #endif
2069
       int ix, iy;
2016
       int ix, iy;
2070
       if (probe_point == 0) {
2017
       if (probe_point == 0) {
2071
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2018
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2072
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2019
+        sync_plan_position();
2073
       } else {
2020
       } else {
2074
         ix = (probe_point-1) % MESH_NUM_X_POINTS;
2021
         ix = (probe_point-1) % MESH_NUM_X_POINTS;
2075
         iy = (probe_point-1) / MESH_NUM_X_POINTS;
2022
         iy = (probe_point-1) / MESH_NUM_X_POINTS;
2242
         current_position[X_AXIS] = uncorrected_position.x;
2189
         current_position[X_AXIS] = uncorrected_position.x;
2243
         current_position[Y_AXIS] = uncorrected_position.y;
2190
         current_position[Y_AXIS] = uncorrected_position.y;
2244
         current_position[Z_AXIS] = uncorrected_position.z;
2191
         current_position[Z_AXIS] = uncorrected_position.z;
2245
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2192
+        sync_plan_position();
2246
 
2193
 
2247
       #endif
2194
       #endif
2248
     }
2195
     }
2443
 
2390
 
2444
         apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
2391
         apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);         //Apply the correction sending the probe offset
2445
         current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
2392
         current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS];   //The difference is added to current position and sent to planner.
2446
-        plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2393
+        sync_plan_position();
2447
       }
2394
       }
2448
     #endif // !DELTA
2395
     #endif // !DELTA
2449
 
2396
 
2504
         didXYZ = true;
2451
         didXYZ = true;
2505
     }
2452
     }
2506
   }
2453
   }
2507
-  if (didXYZ) plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
2454
+  if (didXYZ) sync_plan_position();
2508
 }
2455
 }
2509
 
2456
 
2510
 #ifdef ULTIPANEL
2457
 #ifdef ULTIPANEL
3762
   inline void gcode_M218() {
3709
   inline void gcode_M218() {
3763
     if (setTargetedHotend(218)) return;
3710
     if (setTargetedHotend(218)) return;
3764
 
3711
 
3765
-    if (code_seen('X')) extruder_offset[X_AXIS][tmp_extruder] = code_value();
3766
-    if (code_seen('Y')) extruder_offset[Y_AXIS][tmp_extruder] = code_value();
3712
+    if (code_seen('X')) extruder_offset[tmp_extruder][X_AXIS] = code_value();
3713
+    if (code_seen('Y')) extruder_offset[tmp_extruder][Y_AXIS] = code_value();
3767
 
3714
 
3768
     #ifdef DUAL_X_CARRIAGE
3715
     #ifdef DUAL_X_CARRIAGE
3769
-      if (code_seen('Z')) extruder_offset[Z_AXIS][tmp_extruder] = code_value();
3716
+      if (code_seen('Z')) extruder_offset[tmp_extruder][Z_AXIS] = code_value();
3770
     #endif
3717
     #endif
3771
 
3718
 
3772
     SERIAL_ECHO_START;
3719
     SERIAL_ECHO_START;
3773
     SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
3720
     SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
3774
     for (tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++) {
3721
     for (tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++) {
3775
       SERIAL_ECHO(" ");
3722
       SERIAL_ECHO(" ");
3776
-      SERIAL_ECHO(extruder_offset[X_AXIS][tmp_extruder]);
3723
+      SERIAL_ECHO(extruder_offset[tmp_extruder][X_AXIS]);
3777
       SERIAL_ECHO(",");
3724
       SERIAL_ECHO(",");
3778
-      SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]);
3725
+      SERIAL_ECHO(extruder_offset[tmp_extruder][Y_AXIS]);
3779
       #ifdef DUAL_X_CARRIAGE
3726
       #ifdef DUAL_X_CARRIAGE
3780
         SERIAL_ECHO(",");
3727
         SERIAL_ECHO(",");
3781
-        SERIAL_ECHO(extruder_offset[Z_AXIS][tmp_extruder]);
3728
+        SERIAL_ECHO(extruder_offset[tmp_extruder][Z_AXIS]);
3782
       #endif
3729
       #endif
3783
     }
3730
     }
3784
     SERIAL_EOL;
3731
     SERIAL_EOL;
4469
         SERIAL_ECHO_START;
4416
         SERIAL_ECHO_START;
4470
         SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
4417
         SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
4471
         SERIAL_ECHO(" ");
4418
         SERIAL_ECHO(" ");
4472
-        SERIAL_ECHO(extruder_offset[X_AXIS][0]);
4419
+        SERIAL_ECHO(extruder_offset[0][X_AXIS]);
4473
         SERIAL_ECHO(",");
4420
         SERIAL_ECHO(",");
4474
-        SERIAL_ECHO(extruder_offset[Y_AXIS][0]);
4421
+        SERIAL_ECHO(extruder_offset[0][Y_AXIS]);
4475
         SERIAL_ECHO(" ");
4422
         SERIAL_ECHO(" ");
4476
         SERIAL_ECHO(duplicate_extruder_x_offset);
4423
         SERIAL_ECHO(duplicate_extruder_x_offset);
4477
         SERIAL_ECHO(",");
4424
         SERIAL_ECHO(",");
4478
-        SERIAL_ECHOLN(extruder_offset[Y_AXIS][1]);
4425
+        SERIAL_ECHOLN(extruder_offset[1][Y_AXIS]);
4479
         break;
4426
         break;
4480
       case DXC_FULL_CONTROL_MODE:
4427
       case DXC_FULL_CONTROL_MODE:
4481
       case DXC_AUTO_PARK_MODE:
4428
       case DXC_AUTO_PARK_MODE:
4610
 
4557
 
4611
           // apply Y & Z extruder offset (x offset is already used in determining home pos)
4558
           // apply Y & Z extruder offset (x offset is already used in determining home pos)
4612
           current_position[Y_AXIS] = current_position[Y_AXIS] -
4559
           current_position[Y_AXIS] = current_position[Y_AXIS] -
4613
-                       extruder_offset[Y_AXIS][active_extruder] +
4614
-                       extruder_offset[Y_AXIS][tmp_extruder];
4560
+                       extruder_offset[active_extruder][Y_AXIS] +
4561
+                       extruder_offset[tmp_extruder][Y_AXIS];
4615
           current_position[Z_AXIS] = current_position[Z_AXIS] -
4562
           current_position[Z_AXIS] = current_position[Z_AXIS] -
4616
-                       extruder_offset[Z_AXIS][active_extruder] +
4617
-                       extruder_offset[Z_AXIS][tmp_extruder];
4563
+                       extruder_offset[active_extruder][Z_AXIS] +
4564
+                       extruder_offset[tmp_extruder][Z_AXIS];
4618
 
4565
 
4619
           active_extruder = tmp_extruder;
4566
           active_extruder = tmp_extruder;
4620
 
4567
 
4644
         #else // !DUAL_X_CARRIAGE
4591
         #else // !DUAL_X_CARRIAGE
4645
           // Offset extruder (only by XY)
4592
           // Offset extruder (only by XY)
4646
           for (int i=X_AXIS; i<=Y_AXIS; i++)
4593
           for (int i=X_AXIS; i<=Y_AXIS; i++)
4647
-            current_position[i] += extruder_offset[i][tmp_extruder] - extruder_offset[i][active_extruder];
4594
+            current_position[i] += extruder_offset[tmp_extruder][i] - extruder_offset[active_extruder][i];
4648
           // Set the new active extruder and position
4595
           // Set the new active extruder and position
4649
           active_extruder = tmp_extruder;
4596
           active_extruder = tmp_extruder;
4650
         #endif // !DUAL_X_CARRIAGE
4597
         #endif // !DUAL_X_CARRIAGE
4653
           //sent position to plan_set_position();
4600
           //sent position to plan_set_position();
4654
           plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]);
4601
           plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]);
4655
         #else
4602
         #else
4656
-          plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
4603
+          sync_plan_position();
4657
         #endif
4604
         #endif
4658
         // Move to the old position if 'F' was in the parameters
4605
         // Move to the old position if 'F' was in the parameters
4659
         if (make_move && !Stopped) prepare_move();
4606
         if (make_move && !Stopped) prepare_move();
5494
       plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
5441
       plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
5495
       plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
5442
       plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS],
5496
           current_position[E_AXIS], max_feedrate[X_AXIS], 1);
5443
           current_position[E_AXIS], max_feedrate[X_AXIS], 1);
5497
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
5444
+      sync_plan_position();
5498
       st_synchronize();
5445
       st_synchronize();
5499
       extruder_duplication_enabled = true;
5446
       extruder_duplication_enabled = true;
5500
       active_extruder_parked = false;
5447
       active_extruder_parked = false;

+ 12
- 0
Marlin/pins_RAMBO.h View File

22
   #endif
22
   #endif
23
 #endif
23
 #endif
24
 
24
 
25
+#undef X_MS1_PIN
26
+#undef X_MS2_PIN
27
+#undef Y_MS1_PIN
28
+#undef Y_MS2_PIN
29
+#undef Z_MS1_PIN
30
+#undef Z_MS2_PIN
31
+#undef E0_MS1_PIN
32
+#undef E0_MS2_PIN
33
+#undef E1_MS1_PIN
34
+#undef E1_MS2_PIN
35
+ 
25
 #define X_STEP_PIN 37
36
 #define X_STEP_PIN 37
26
 #define X_DIR_PIN 48
37
 #define X_DIR_PIN 48
27
 #define X_MIN_PIN 12
38
 #define X_MIN_PIN 12
75
 #define E1_MS1_PIN 63
86
 #define E1_MS1_PIN 63
76
 #define E1_MS2_PIN 64
87
 #define E1_MS2_PIN 64
77
 
88
 
89
+#undef DIGIPOTSS_PIN
78
 #define DIGIPOTSS_PIN 38
90
 #define DIGIPOTSS_PIN 38
79
 #define DIGIPOT_CHANNELS {4,5,3,0,1} // X Y Z E0 E1 digipot channels to stepper driver mapping
91
 #define DIGIPOT_CHANNELS {4,5,3,0,1} // X Y Z E0 E1 digipot channels to stepper driver mapping
80
 
92
 

+ 1
- 1
Marlin/planner.cpp View File

342
 //     b. No speed reduction within one block requires faster deceleration than the one, true constant 
342
 //     b. No speed reduction within one block requires faster deceleration than the one, true constant 
343
 //        acceleration.
343
 //        acceleration.
344
 //   2. Go over every block in chronological order and dial down junction speed reduction values if 
344
 //   2. Go over every block in chronological order and dial down junction speed reduction values if 
345
-//     a. The speed increase within one block would require faster accelleration than the one, true 
345
+//     a. The speed increase within one block would require faster acceleration than the one, true 
346
 //        constant acceleration.
346
 //        constant acceleration.
347
 //
347
 //
348
 // When these stages are complete all blocks have an entry_factor that will allow all speed changes to 
348
 // When these stages are complete all blocks have an entry_factor that will allow all speed changes to 

+ 21
- 5
Marlin/planner.h View File

80
 FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
80
 FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
81
 
81
 
82
 #if defined(ENABLE_AUTO_BED_LEVELING) || defined(MESH_BED_LEVELING)
82
 #if defined(ENABLE_AUTO_BED_LEVELING) || defined(MESH_BED_LEVELING)
83
+
83
   #if defined(ENABLE_AUTO_BED_LEVELING)
84
   #if defined(ENABLE_AUTO_BED_LEVELING)
84
     #include "vector_3.h"
85
     #include "vector_3.h"
85
-    // this holds the required transform to compensate for bed level
86
+
87
+    // Transform required to compensate for bed level
86
     extern matrix_3x3 plan_bed_level_matrix;
88
     extern matrix_3x3 plan_bed_level_matrix;
87
-    // Get the position applying the bed level matrix if enabled
89
+
90
+    /**
91
+     * Get the position applying the bed level matrix
92
+     */
88
     vector_3 plan_get_position();
93
     vector_3 plan_get_position();
89
   #endif  // ENABLE_AUTO_BED_LEVELING
94
   #endif  // ENABLE_AUTO_BED_LEVELING
90
-  // Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in 
91
-  // millimeters. Feed rate specifies the speed of the motion.
95
+
96
+  /**
97
+   * Add a new linear movement to the buffer. x, y, z are the signed, absolute target position in
98
+   * millimeters. Feed rate specifies the (target) speed of the motion.
99
+   */
92
   void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder);
100
   void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder);
93
-  // Set position. Used for G92 instructions.
101
+
102
+  /**
103
+   * Set the planner positions. Used for G92 instructions.
104
+   * Multiplies by axis_steps_per_unit[] to set stepper positions.
105
+   * Clears previous speed values.
106
+   */
94
   void plan_set_position(float x, float y, float z, const float &e);
107
   void plan_set_position(float x, float y, float z, const float &e);
108
+
95
 #else
109
 #else
110
+
96
   void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder);
111
   void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder);
97
   void plan_set_position(const float &x, const float &y, const float &z, const float &e);
112
   void plan_set_position(const float &x, const float &y, const float &z, const float &e);
113
+
98
 #endif // ENABLE_AUTO_BED_LEVELING || MESH_BED_LEVELING
114
 #endif // ENABLE_AUTO_BED_LEVELING || MESH_BED_LEVELING
99
 
115
 
100
 void plan_set_e_position(const float &e);
116
 void plan_set_e_position(const float &e);

+ 1
- 1
Marlin/stepper.cpp View File

1205
     pinMode(E0_MS1_PIN,OUTPUT);
1205
     pinMode(E0_MS1_PIN,OUTPUT);
1206
     pinMode(E0_MS2_PIN,OUTPUT);
1206
     pinMode(E0_MS2_PIN,OUTPUT);
1207
     const uint8_t microstep_modes[] = MICROSTEP_MODES;
1207
     const uint8_t microstep_modes[] = MICROSTEP_MODES;
1208
-    for (int i = 0; i < sizeof(microstep_modes) / sizeof(microstep_modes[0]); i++)
1208
+    for (uint16_t i = 0; i < sizeof(microstep_modes) / sizeof(microstep_modes[0]); i++)
1209
       microstep_mode(i, microstep_modes[i]);
1209
       microstep_mode(i, microstep_modes[i]);
1210
   #endif
1210
   #endif
1211
 }
1211
 }

Loading…
Cancel
Save