Browse Source

COREYZ stepper, planner, endstop, babysteps

Scott Lahteine 8 years ago
parent
commit
5172d4ba40
5 changed files with 76 additions and 48 deletions
  1. 11
    11
      Marlin/endstops.cpp
  2. 34
    14
      Marlin/planner.cpp
  3. 1
    1
      Marlin/planner.h
  4. 20
    13
      Marlin/stepper.cpp
  5. 10
    9
      Marlin/temperature.h

+ 11
- 11
Marlin/endstops.cpp View File

239
 
239
 
240
   #if ENABLED(COREXY) || ENABLED(COREXZ)
240
   #if ENABLED(COREXY) || ENABLED(COREXZ)
241
     // Head direction in -X axis for CoreXY and CoreXZ bots.
241
     // Head direction in -X axis for CoreXY and CoreXZ bots.
242
-    // If Delta1 == -Delta2, the movement is only in Y or Z axis
243
-    if ((stepper.current_block->steps[A_AXIS] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(A_AXIS) == stepper.motor_direction(CORE_AXIS_2))) {
242
+    // If DeltaA == -DeltaB, the movement is only in Y or Z axis
243
+    if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) == stepper.motor_direction(CORE_AXIS_2))) {
244
       if (stepper.motor_direction(X_HEAD))
244
       if (stepper.motor_direction(X_HEAD))
245
   #else
245
   #else
246
     if (stepper.motor_direction(X_AXIS))   // stepping along -X axis (regular Cartesian bot)
246
     if (stepper.motor_direction(X_AXIS))   // stepping along -X axis (regular Cartesian bot)
271
     }
271
     }
272
   #endif
272
   #endif
273
 
273
 
274
-  #if ENABLED(COREXY)
275
-    // Head direction in -Y axis for CoreXY bots.
276
-    // If DeltaX == DeltaY, the movement is only in X axis
277
-    if ((stepper.current_block->steps[A_AXIS] != stepper.current_block->steps[B_AXIS]) || (stepper.motor_direction(A_AXIS) != stepper.motor_direction(B_AXIS))) {
274
+  #if ENABLED(COREXY) || ENABLED(COREYZ)
275
+    // Head direction in -Y axis for CoreXY / CoreYZ bots.
276
+    // If DeltaA == DeltaB, the movement is only in X or Y axis
277
+    if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) != stepper.motor_direction(CORE_AXIS_2))) {
278
       if (stepper.motor_direction(Y_HEAD))
278
       if (stepper.motor_direction(Y_HEAD))
279
   #else
279
   #else
280
       if (stepper.motor_direction(Y_AXIS))   // -direction
280
       if (stepper.motor_direction(Y_AXIS))   // -direction
289
           UPDATE_ENDSTOP(Y, MAX);
289
           UPDATE_ENDSTOP(Y, MAX);
290
         #endif
290
         #endif
291
       }
291
       }
292
-  #if ENABLED(COREXY)
292
+  #if ENABLED(COREXY) || ENABLED(COREYZ)
293
     }
293
     }
294
   #endif
294
   #endif
295
 
295
 
296
-  #if ENABLED(COREXZ)
297
-    // Head direction in -Z axis for CoreXZ bots.
298
-    // If DeltaX == DeltaZ, the movement is only in X axis
299
-    if ((stepper.current_block->steps[A_AXIS] != stepper.current_block->steps[C_AXIS]) || (stepper.motor_direction(A_AXIS) != stepper.motor_direction(C_AXIS))) {
296
+  #if ENABLED(COREXZ) || ENABLED(COREYZ)
297
+    // Head direction in -Z axis for CoreXZ or CoreYZ bots.
298
+    // If DeltaA == DeltaB, the movement is only in X or Y axis
299
+    if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) != stepper.motor_direction(CORE_AXIS_2))) {
300
       if (stepper.motor_direction(Z_HEAD))
300
       if (stepper.motor_direction(Z_HEAD))
301
   #else
301
   #else
302
       if (stepper.motor_direction(Z_AXIS))
302
       if (stepper.motor_direction(Z_AXIS))

+ 34
- 14
Marlin/planner.cpp View File

543
     block->steps[A_AXIS] = labs(dx + dz);
543
     block->steps[A_AXIS] = labs(dx + dz);
544
     block->steps[Y_AXIS] = labs(dy);
544
     block->steps[Y_AXIS] = labs(dy);
545
     block->steps[C_AXIS] = labs(dx - dz);
545
     block->steps[C_AXIS] = labs(dx - dz);
546
+  #elif ENABLED(COREYZ)
547
+    // coreyz planning
548
+    block->steps[X_AXIS] = labs(dx);
549
+    block->steps[B_AXIS] = labs(dy + dz);
550
+    block->steps[C_AXIS] = labs(dy - dz);
546
   #else
551
   #else
547
     // default non-h-bot planning
552
     // default non-h-bot planning
548
     block->steps[X_AXIS] = labs(dx);
553
     block->steps[X_AXIS] = labs(dx);
581
     if (dy < 0) SBI(db, Y_AXIS);
586
     if (dy < 0) SBI(db, Y_AXIS);
582
     if (dz < 0) SBI(db, Z_HEAD); // ...and Z
587
     if (dz < 0) SBI(db, Z_HEAD); // ...and Z
583
     if (dx + dz < 0) SBI(db, A_AXIS); // Motor A direction
588
     if (dx + dz < 0) SBI(db, A_AXIS); // Motor A direction
584
-    if (dx - dz < 0) SBI(db, C_AXIS); // Motor B direction
589
+    if (dx - dz < 0) SBI(db, C_AXIS); // Motor C direction
590
+  #elif ENABLED(COREYZ)
591
+    if (dx < 0) SBI(db, X_AXIS);
592
+    if (dy < 0) SBI(db, Y_HEAD); // Save the real Extruder (head) direction in Y Axis
593
+    if (dz < 0) SBI(db, Z_HEAD); // ...and Z
594
+    if (dy + dz < 0) SBI(db, B_AXIS); // Motor B direction
595
+    if (dy - dz < 0) SBI(db, C_AXIS); // Motor C direction
585
   #else
596
   #else
586
     if (dx < 0) SBI(db, X_AXIS);
597
     if (dx < 0) SBI(db, X_AXIS);
587
     if (dy < 0) SBI(db, Y_AXIS);
598
     if (dy < 0) SBI(db, Y_AXIS);
698
    * So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
709
    * So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
699
    * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
710
    * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
700
    */
711
    */
701
-  #if ENABLED(COREXY)
712
+  #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
702
     float delta_mm[6];
713
     float delta_mm[6];
703
-    delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
704
-    delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
705
-    delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
706
-    delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_unit[A_AXIS];
707
-    delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_unit[B_AXIS];
708
-  #elif ENABLED(COREXZ)
709
-    float delta_mm[6];
710
-    delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
711
-    delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
712
-    delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
713
-    delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_unit[A_AXIS];
714
-    delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_unit[C_AXIS];
714
+    #if ENABLED(COREXY)
715
+      delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
716
+      delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
717
+      delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
718
+      delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_unit[A_AXIS];
719
+      delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_unit[B_AXIS];
720
+    #elif ENABLED(COREXZ)
721
+      delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
722
+      delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
723
+      delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
724
+      delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_unit[A_AXIS];
725
+      delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_unit[C_AXIS];
726
+    #elif ENABLED(COREYZ)
727
+      delta_mm[X_AXIS] = dx / axis_steps_per_unit[A_AXIS];
728
+      delta_mm[Y_HEAD] = dy / axis_steps_per_unit[Y_AXIS];
729
+      delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
730
+      delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_unit[B_AXIS];
731
+      delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_unit[C_AXIS];
732
+    #endif
715
   #else
733
   #else
716
     float delta_mm[4];
734
     float delta_mm[4];
717
     delta_mm[X_AXIS] = dx / axis_steps_per_unit[X_AXIS];
735
     delta_mm[X_AXIS] = dx / axis_steps_per_unit[X_AXIS];
729
         square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])
747
         square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])
730
       #elif ENABLED(COREXZ)
748
       #elif ENABLED(COREXZ)
731
         square(delta_mm[X_HEAD]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_HEAD])
749
         square(delta_mm[X_HEAD]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_HEAD])
750
+      #elif ENABLED(COREYZ)
751
+        square(delta_mm[X_AXIS]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_HEAD])
732
       #else
752
       #else
733
         square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])
753
         square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])
734
       #endif
754
       #endif

+ 1
- 1
Marlin/planner.h View File

204
        * Used by G92, G28, G29, and other procedures.
204
        * Used by G92, G28, G29, and other procedures.
205
        *
205
        *
206
        * Multiplies by axis_steps_per_unit[] and does necessary conversion
206
        * Multiplies by axis_steps_per_unit[] and does necessary conversion
207
-       * for COREXY / COREXZ to set the corresponding stepper positions.
207
+       * for COREXY / COREXZ / COREYZ to set the corresponding stepper positions.
208
        *
208
        *
209
        * Clears previous speed values.
209
        * Clears previous speed values.
210
        */
210
        */

+ 20
- 13
Marlin/stepper.cpp View File

204
 /**
204
 /**
205
  * Set the stepper direction of each axis
205
  * Set the stepper direction of each axis
206
  *
206
  *
207
- *   X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY
208
- *   X_AXIS=A_AXIS and Z_AXIS=C_AXIS for COREXZ
207
+ *   COREXY: X_AXIS=A_AXIS and Y_AXIS=B_AXIS
208
+ *   COREXZ: X_AXIS=A_AXIS and Z_AXIS=C_AXIS
209
+ *   COREYZ: Y_AXIS=B_AXIS and Z_AXIS=C_AXIS
209
  */
210
  */
210
 void Stepper::set_directions() {
211
 void Stepper::set_directions() {
211
 
212
 
649
     count_position[A_AXIS] = x + z;
650
     count_position[A_AXIS] = x + z;
650
     count_position[Y_AXIS] = y;
651
     count_position[Y_AXIS] = y;
651
     count_position[C_AXIS] = x - z;
652
     count_position[C_AXIS] = x - z;
653
+  #elif ENABLED(COREYZ)
654
+    // coreyz planning
655
+    count_position[X_AXIS] = x;
656
+    count_position[B_AXIS] = y + z;
657
+    count_position[C_AXIS] = y - z;
652
   #else
658
   #else
653
     // default non-h-bot planning
659
     // default non-h-bot planning
654
     count_position[X_AXIS] = x;
660
     count_position[X_AXIS] = x;
682
  */
688
  */
683
 float Stepper::get_axis_position_mm(AxisEnum axis) {
689
 float Stepper::get_axis_position_mm(AxisEnum axis) {
684
   float axis_steps;
690
   float axis_steps;
685
-  #if ENABLED(COREXY) | ENABLED(COREXZ)
686
-    if (axis == X_AXIS || axis == CORE_AXIS_2) {
691
+  #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
692
+    // Requesting one of the "core" axes?
693
+    if (axis == CORE_AXIS_1 || axis == CORE_AXIS_2) {
687
       CRITICAL_SECTION_START;
694
       CRITICAL_SECTION_START;
688
-      long pos1 = count_position[A_AXIS],
695
+      long pos1 = count_position[CORE_AXIS_1],
689
            pos2 = count_position[CORE_AXIS_2];
696
            pos2 = count_position[CORE_AXIS_2];
690
       CRITICAL_SECTION_END;
697
       CRITICAL_SECTION_END;
691
       // ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
698
       // ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
692
       // ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2
699
       // ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2
693
-      axis_steps = (pos1 + ((axis == X_AXIS) ? pos2 : -pos2)) / 2.0f;
700
+      axis_steps = (pos1 + ((axis == CORE_AXIS_1) ? pos2 : -pos2)) / 2.0f;
694
     }
701
     }
695
     else
702
     else
696
       axis_steps = position(axis);
703
       axis_steps = position(axis);
715
 
722
 
716
 void Stepper::endstop_triggered(AxisEnum axis) {
723
 void Stepper::endstop_triggered(AxisEnum axis) {
717
 
724
 
718
-  #if ENABLED(COREXY) || ENABLED(COREXZ)
725
+  #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
719
 
726
 
720
     float axis_pos = count_position[axis];
727
     float axis_pos = count_position[axis];
721
-    if (axis == A_AXIS)
728
+    if (axis == CORE_AXIS_1)
722
       axis_pos = (axis_pos + count_position[CORE_AXIS_2]) / 2;
729
       axis_pos = (axis_pos + count_position[CORE_AXIS_2]) / 2;
723
     else if (axis == CORE_AXIS_2)
730
     else if (axis == CORE_AXIS_2)
724
-      axis_pos = (count_position[A_AXIS] - axis_pos) / 2;
731
+      axis_pos = (count_position[CORE_AXIS_1] - axis_pos) / 2;
725
     endstops_trigsteps[axis] = axis_pos;
732
     endstops_trigsteps[axis] = axis_pos;
726
 
733
 
727
-  #else // !COREXY && !COREXZ
734
+  #else // !COREXY && !COREXZ && !COREYZ
728
 
735
 
729
     endstops_trigsteps[axis] = count_position[axis];
736
     endstops_trigsteps[axis] = count_position[axis];
730
 
737
 
731
-  #endif // !COREXY && !COREXZ
738
+  #endif // !COREXY && !COREXZ && !COREYZ
732
 
739
 
733
   kill_current_block();
740
   kill_current_block();
734
 }
741
 }
747
   #endif
754
   #endif
748
   SERIAL_PROTOCOL(xpos);
755
   SERIAL_PROTOCOL(xpos);
749
 
756
 
750
-  #if ENABLED(COREXY) || ENABLED(COREXZ)
757
+  #if ENABLED(COREXY) || ENABLED(COREYZ)
751
     SERIAL_PROTOCOLPGM(" B:");
758
     SERIAL_PROTOCOLPGM(" B:");
752
   #else
759
   #else
753
     SERIAL_PROTOCOLPGM(" Y:");
760
     SERIAL_PROTOCOLPGM(" Y:");
754
   #endif
761
   #endif
755
   SERIAL_PROTOCOL(ypos);
762
   SERIAL_PROTOCOL(ypos);
756
 
763
 
757
-  #if ENABLED(COREXZ) || ENABLED(COREXZ)
764
+  #if ENABLED(COREXZ) || ENABLED(COREYZ)
758
     SERIAL_PROTOCOLPGM(" C:");
765
     SERIAL_PROTOCOLPGM(" C:");
759
   #else
766
   #else
760
     SERIAL_PROTOCOLPGM(" Z:");
767
     SERIAL_PROTOCOLPGM(" Z:");

+ 10
- 9
Marlin/temperature.h View File

306
     #if ENABLED(BABYSTEPPING)
306
     #if ENABLED(BABYSTEPPING)
307
 
307
 
308
       FORCE_INLINE void babystep_axis(AxisEnum axis, int distance) {
308
       FORCE_INLINE void babystep_axis(AxisEnum axis, int distance) {
309
-        #if ENABLED(COREXY) || ENABLED(COREXZ)
309
+        #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
310
           #if ENABLED(BABYSTEP_XY)
310
           #if ENABLED(BABYSTEP_XY)
311
             switch (axis) {
311
             switch (axis) {
312
-              case X_AXIS: // X on CoreXY and CoreXZ
313
-                babystepsTodo[A_AXIS] += distance * 2;
312
+              case CORE_AXIS_1: // X on CoreXY and CoreXZ, Y on CoreYZ
313
+                babystepsTodo[CORE_AXIS_1] += distance * 2;
314
                 babystepsTodo[CORE_AXIS_2] += distance * 2;
314
                 babystepsTodo[CORE_AXIS_2] += distance * 2;
315
                 break;
315
                 break;
316
-              case CORE_AXIS_2: // Y on CoreXY, Z on CoreXZ
317
-                babystepsTodo[A_AXIS] += distance * 2;
316
+              case CORE_AXIS_2: // Y on CoreXY, Z on CoreXZ and CoreYZ
317
+                babystepsTodo[CORE_AXIS_1] += distance * 2;
318
                 babystepsTodo[CORE_AXIS_2] -= distance * 2;
318
                 babystepsTodo[CORE_AXIS_2] -= distance * 2;
319
                 break;
319
                 break;
320
-              case CORE_AXIS_3: // Z on CoreXY, Y on CoreXZ
320
+              case CORE_AXIS_3: // Z on CoreXY, Y on CoreXZ, X on CoreYZ
321
                 babystepsTodo[CORE_AXIS_3] += distance;
321
                 babystepsTodo[CORE_AXIS_3] += distance;
322
                 break;
322
                 break;
323
             }
323
             }
324
-          #elif ENABLED(COREXZ)
325
-            babystepsTodo[A_AXIS] += distance * 2;
326
-            babystepsTodo[C_AXIS] -= distance * 2;
324
+          #elif ENABLED(COREXZ) || ENABLED(COREYZ)
325
+            // Only Z stepping needs to be handled here
326
+            babystepsTodo[CORE_AXIS_1] += distance * 2;
327
+            babystepsTodo[CORE_AXIS_2] -= distance * 2;
327
           #else
328
           #else
328
             babystepsTodo[Z_AXIS] += distance;
329
             babystepsTodo[Z_AXIS] += distance;
329
           #endif
330
           #endif

Loading…
Cancel
Save