Browse Source

Merge pull request #3991 from thinkyhead/rc_axis_units

Rename some vars to clarify their relationship to acceleration
Scott Lahteine 9 years ago
parent
commit
e2d4919c01

+ 1
- 1
Marlin/Conditionals.h View File

420
    */
420
    */
421
   #if ENABLED(ADVANCE)
421
   #if ENABLED(ADVANCE)
422
     #define EXTRUSION_AREA (0.25 * (D_FILAMENT) * (D_FILAMENT) * M_PI)
422
     #define EXTRUSION_AREA (0.25 * (D_FILAMENT) * (D_FILAMENT) * M_PI)
423
-    #define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS] / (EXTRUSION_AREA))
423
+    #define STEPS_PER_CUBIC_MM_E (axis_steps_per_mm[E_AXIS] / (EXTRUSION_AREA))
424
   #endif
424
   #endif
425
 
425
 
426
   #if ENABLED(ULTIPANEL) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)
426
   #if ENABLED(ULTIPANEL) && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)

+ 12
- 12
Marlin/Marlin_main.cpp View File

155
  * M84  - Disable steppers until next move,
155
  * M84  - Disable steppers until next move,
156
  *        or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled.  S0 to disable the timeout.
156
  *        or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled.  S0 to disable the timeout.
157
  * M85  - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
157
  * M85  - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
158
- * M92  - Set planner.axis_steps_per_unit - same syntax as G92
158
+ * M92  - Set planner.axis_steps_per_mm - same syntax as G92
159
  * M104 - Set extruder target temp
159
  * M104 - Set extruder target temp
160
  * M105 - Read current temp
160
  * M105 - Read current temp
161
  * M106 - Fan on
161
  * M106 - Fan on
1683
        * is not where we said to go.
1683
        * is not where we said to go.
1684
        */
1684
        */
1685
       long stop_steps = stepper.position(Z_AXIS);
1685
       long stop_steps = stepper.position(Z_AXIS);
1686
-      float mm = start_z - float(start_steps - stop_steps) / planner.axis_steps_per_unit[Z_AXIS];
1686
+      float mm = start_z - float(start_steps - stop_steps) / planner.axis_steps_per_mm[Z_AXIS];
1687
       current_position[Z_AXIS] = mm;
1687
       current_position[Z_AXIS] = mm;
1688
 
1688
 
1689
       #if ENABLED(DEBUG_LEVELING_FEATURE)
1689
       #if ENABLED(DEBUG_LEVELING_FEATURE)
5155
       if (i == E_AXIS) {
5155
       if (i == E_AXIS) {
5156
         float value = code_value_per_axis_unit(i);
5156
         float value = code_value_per_axis_unit(i);
5157
         if (value < 20.0) {
5157
         if (value < 20.0) {
5158
-          float factor = planner.axis_steps_per_unit[i] / value; // increase e constants if M92 E14 is given for netfab.
5158
+          float factor = planner.axis_steps_per_mm[i] / value; // increase e constants if M92 E14 is given for netfab.
5159
           planner.max_e_jerk *= factor;
5159
           planner.max_e_jerk *= factor;
5160
           planner.max_feedrate[i] *= factor;
5160
           planner.max_feedrate[i] *= factor;
5161
-          planner.axis_steps_per_sqr_second[i] *= factor;
5161
+          planner.max_acceleration_steps_per_s2[i] *= factor;
5162
         }
5162
         }
5163
-        planner.axis_steps_per_unit[i] = value;
5163
+        planner.axis_steps_per_mm[i] = value;
5164
       }
5164
       }
5165
       else {
5165
       else {
5166
-        planner.axis_steps_per_unit[i] = code_value_per_axis_unit(i);
5166
+        planner.axis_steps_per_mm[i] = code_value_per_axis_unit(i);
5167
       }
5167
       }
5168
     }
5168
     }
5169
   }
5169
   }
5198
     SERIAL_EOL;
5198
     SERIAL_EOL;
5199
 
5199
 
5200
     SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:");
5200
     SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:");
5201
-    SERIAL_PROTOCOL(delta[X_AXIS] / 90 * planner.axis_steps_per_unit[X_AXIS]);
5201
+    SERIAL_PROTOCOL(delta[X_AXIS] / 90 * planner.axis_steps_per_mm[X_AXIS]);
5202
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
5202
     SERIAL_PROTOCOLPGM("   Psi+Theta:");
5203
-    SERIAL_PROTOCOL((delta[Y_AXIS] - delta[X_AXIS]) / 90 * planner.axis_steps_per_unit[Y_AXIS]);
5203
+    SERIAL_PROTOCOL((delta[Y_AXIS] - delta[X_AXIS]) / 90 * planner.axis_steps_per_mm[Y_AXIS]);
5204
     SERIAL_EOL; SERIAL_EOL;
5204
     SERIAL_EOL; SERIAL_EOL;
5205
   #endif
5205
   #endif
5206
 }
5206
 }
5345
 inline void gcode_M201() {
5345
 inline void gcode_M201() {
5346
   for (int8_t i = 0; i < NUM_AXIS; i++) {
5346
   for (int8_t i = 0; i < NUM_AXIS; i++) {
5347
     if (code_seen(axis_codes[i])) {
5347
     if (code_seen(axis_codes[i])) {
5348
-      planner.max_acceleration_units_per_sq_second[i] = code_value_axis_units(i);
5348
+      planner.max_acceleration_mm_per_s2[i] = code_value_axis_units(i);
5349
     }
5349
     }
5350
   }
5350
   }
5351
   // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
5351
   // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
5355
 #if 0 // Not used for Sprinter/grbl gen6
5355
 #if 0 // Not used for Sprinter/grbl gen6
5356
   inline void gcode_M202() {
5356
   inline void gcode_M202() {
5357
     for (int8_t i = 0; i < NUM_AXIS; i++) {
5357
     for (int8_t i = 0; i < NUM_AXIS; i++) {
5358
-      if (code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value_axis_units(i) * planner.axis_steps_per_unit[i];
5358
+      if (code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value_axis_units(i) * planner.axis_steps_per_mm[i];
5359
     }
5359
     }
5360
   }
5360
   }
5361
 #endif
5361
 #endif
8226
         }
8226
         }
8227
         float oldepos = current_position[E_AXIS], oldedes = destination[E_AXIS];
8227
         float oldepos = current_position[E_AXIS], oldedes = destination[E_AXIS];
8228
         planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS],
8228
         planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS],
8229
-                         destination[E_AXIS] + (EXTRUDER_RUNOUT_EXTRUDE) * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_unit[E_AXIS],
8230
-                         (EXTRUDER_RUNOUT_SPEED) / 60. * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_unit[E_AXIS], active_extruder);
8229
+                         destination[E_AXIS] + (EXTRUDER_RUNOUT_EXTRUDE) * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_mm[E_AXIS],
8230
+                         (EXTRUDER_RUNOUT_SPEED) / 60. * (EXTRUDER_RUNOUT_ESTEPS) / planner.axis_steps_per_mm[E_AXIS], active_extruder);
8231
       current_position[E_AXIS] = oldepos;
8231
       current_position[E_AXIS] = oldepos;
8232
       destination[E_AXIS] = oldedes;
8232
       destination[E_AXIS] = oldedes;
8233
       planner.set_e_position_mm(oldepos);
8233
       planner.set_e_position_mm(oldepos);

+ 16
- 16
Marlin/configuration_store.cpp View File

43
  *
43
  *
44
  *  100  Version (char x4)
44
  *  100  Version (char x4)
45
  *
45
  *
46
- *  104  M92 XYZE  planner.axis_steps_per_unit (float x4)
46
+ *  104  M92 XYZE  planner.axis_steps_per_mm (float x4)
47
  *  120  M203 XYZE planner.max_feedrate (float x4)
47
  *  120  M203 XYZE planner.max_feedrate (float x4)
48
- *  136  M201 XYZE planner.max_acceleration_units_per_sq_second (uint32_t x4)
48
+ *  136  M201 XYZE planner.max_acceleration_mm_per_s2 (uint32_t x4)
49
  *  152  M204 P    planner.acceleration (float)
49
  *  152  M204 P    planner.acceleration (float)
50
  *  156  M204 R    planner.retract_acceleration (float)
50
  *  156  M204 R    planner.retract_acceleration (float)
51
  *  160  M204 T    planner.travel_acceleration (float)
51
  *  160  M204 T    planner.travel_acceleration (float)
173
   char ver[4] = "000";
173
   char ver[4] = "000";
174
   int i = EEPROM_OFFSET;
174
   int i = EEPROM_OFFSET;
175
   EEPROM_WRITE_VAR(i, ver); // invalidate data first
175
   EEPROM_WRITE_VAR(i, ver); // invalidate data first
176
-  EEPROM_WRITE_VAR(i, planner.axis_steps_per_unit);
176
+  EEPROM_WRITE_VAR(i, planner.axis_steps_per_mm);
177
   EEPROM_WRITE_VAR(i, planner.max_feedrate);
177
   EEPROM_WRITE_VAR(i, planner.max_feedrate);
178
-  EEPROM_WRITE_VAR(i, planner.max_acceleration_units_per_sq_second);
178
+  EEPROM_WRITE_VAR(i, planner.max_acceleration_mm_per_s2);
179
   EEPROM_WRITE_VAR(i, planner.acceleration);
179
   EEPROM_WRITE_VAR(i, planner.acceleration);
180
   EEPROM_WRITE_VAR(i, planner.retract_acceleration);
180
   EEPROM_WRITE_VAR(i, planner.retract_acceleration);
181
   EEPROM_WRITE_VAR(i, planner.travel_acceleration);
181
   EEPROM_WRITE_VAR(i, planner.travel_acceleration);
353
     float dummy = 0;
353
     float dummy = 0;
354
 
354
 
355
     // version number match
355
     // version number match
356
-    EEPROM_READ_VAR(i, planner.axis_steps_per_unit);
356
+    EEPROM_READ_VAR(i, planner.axis_steps_per_mm);
357
     EEPROM_READ_VAR(i, planner.max_feedrate);
357
     EEPROM_READ_VAR(i, planner.max_feedrate);
358
-    EEPROM_READ_VAR(i, planner.max_acceleration_units_per_sq_second);
358
+    EEPROM_READ_VAR(i, planner.max_acceleration_mm_per_s2);
359
 
359
 
360
     // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
360
     // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
361
     planner.reset_acceleration_rates();
361
     planner.reset_acceleration_rates();
527
   float tmp2[] = DEFAULT_MAX_FEEDRATE;
527
   float tmp2[] = DEFAULT_MAX_FEEDRATE;
528
   long tmp3[] = DEFAULT_MAX_ACCELERATION;
528
   long tmp3[] = DEFAULT_MAX_ACCELERATION;
529
   for (uint8_t i = 0; i < NUM_AXIS; i++) {
529
   for (uint8_t i = 0; i < NUM_AXIS; i++) {
530
-    planner.axis_steps_per_unit[i] = tmp1[i];
530
+    planner.axis_steps_per_mm[i] = tmp1[i];
531
     planner.max_feedrate[i] = tmp2[i];
531
     planner.max_feedrate[i] = tmp2[i];
532
-    planner.max_acceleration_units_per_sq_second[i] = tmp3[i];
532
+    planner.max_acceleration_mm_per_s2[i] = tmp3[i];
533
     #if ENABLED(SCARA)
533
     #if ENABLED(SCARA)
534
       if (i < COUNT(axis_scaling))
534
       if (i < COUNT(axis_scaling))
535
         axis_scaling[i] = 1;
535
         axis_scaling[i] = 1;
652
     SERIAL_ECHOLNPGM("Steps per unit:");
652
     SERIAL_ECHOLNPGM("Steps per unit:");
653
     CONFIG_ECHO_START;
653
     CONFIG_ECHO_START;
654
   }
654
   }
655
-  SERIAL_ECHOPAIR("  M92 X", planner.axis_steps_per_unit[X_AXIS]);
656
-  SERIAL_ECHOPAIR(" Y", planner.axis_steps_per_unit[Y_AXIS]);
657
-  SERIAL_ECHOPAIR(" Z", planner.axis_steps_per_unit[Z_AXIS]);
658
-  SERIAL_ECHOPAIR(" E", planner.axis_steps_per_unit[E_AXIS]);
655
+  SERIAL_ECHOPAIR("  M92 X", planner.axis_steps_per_mm[X_AXIS]);
656
+  SERIAL_ECHOPAIR(" Y", planner.axis_steps_per_mm[Y_AXIS]);
657
+  SERIAL_ECHOPAIR(" Z", planner.axis_steps_per_mm[Z_AXIS]);
658
+  SERIAL_ECHOPAIR(" E", planner.axis_steps_per_mm[E_AXIS]);
659
   SERIAL_EOL;
659
   SERIAL_EOL;
660
 
660
 
661
   CONFIG_ECHO_START;
661
   CONFIG_ECHO_START;
687
     SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
687
     SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
688
     CONFIG_ECHO_START;
688
     CONFIG_ECHO_START;
689
   }
689
   }
690
-  SERIAL_ECHOPAIR("  M201 X", planner.max_acceleration_units_per_sq_second[X_AXIS]);
691
-  SERIAL_ECHOPAIR(" Y", planner.max_acceleration_units_per_sq_second[Y_AXIS]);
692
-  SERIAL_ECHOPAIR(" Z", planner.max_acceleration_units_per_sq_second[Z_AXIS]);
693
-  SERIAL_ECHOPAIR(" E", planner.max_acceleration_units_per_sq_second[E_AXIS]);
690
+  SERIAL_ECHOPAIR("  M201 X", planner.max_acceleration_mm_per_s2[X_AXIS]);
691
+  SERIAL_ECHOPAIR(" Y", planner.max_acceleration_mm_per_s2[Y_AXIS]);
692
+  SERIAL_ECHOPAIR(" Z", planner.max_acceleration_mm_per_s2[Z_AXIS]);
693
+  SERIAL_ECHOPAIR(" E", planner.max_acceleration_mm_per_s2[E_AXIS]);
694
   SERIAL_EOL;
694
   SERIAL_EOL;
695
   CONFIG_ECHO_START;
695
   CONFIG_ECHO_START;
696
   if (!forReplay) {
696
   if (!forReplay) {

+ 48
- 48
Marlin/planner.cpp View File

81
 volatile uint8_t Planner::block_buffer_tail = 0;
81
 volatile uint8_t Planner::block_buffer_tail = 0;
82
 
82
 
83
 float Planner::max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
83
 float Planner::max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
84
-float Planner::axis_steps_per_unit[NUM_AXIS];
85
-unsigned long Planner::axis_steps_per_sqr_second[NUM_AXIS];
86
-unsigned long Planner::max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
84
+float Planner::axis_steps_per_mm[NUM_AXIS];
85
+unsigned long Planner::max_acceleration_steps_per_s2[NUM_AXIS];
86
+unsigned long Planner::max_acceleration_mm_per_s2[NUM_AXIS]; // Use M201 to override by software
87
 
87
 
88
 millis_t Planner::min_segment_time;
88
 millis_t Planner::min_segment_time;
89
 float Planner::min_feedrate;
89
 float Planner::min_feedrate;
155
   NOLESS(initial_rate, 120);
155
   NOLESS(initial_rate, 120);
156
   NOLESS(final_rate, 120);
156
   NOLESS(final_rate, 120);
157
 
157
 
158
-  long accel = block->acceleration_st;
158
+  long accel = block->acceleration_steps_per_s2;
159
   int32_t accelerate_steps = ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, accel));
159
   int32_t accelerate_steps = ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, accel));
160
   int32_t decelerate_steps = floor(estimate_acceleration_distance(block->nominal_rate, final_rate, -accel));
160
   int32_t decelerate_steps = floor(estimate_acceleration_distance(block->nominal_rate, final_rate, -accel));
161
 
161
 
549
   // Calculate target position in absolute steps
549
   // Calculate target position in absolute steps
550
   //this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
550
   //this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
551
   long target[NUM_AXIS] = {
551
   long target[NUM_AXIS] = {
552
-    lround(x * axis_steps_per_unit[X_AXIS]),
553
-    lround(y * axis_steps_per_unit[Y_AXIS]),
554
-    lround(z * axis_steps_per_unit[Z_AXIS]),
555
-    lround(e * axis_steps_per_unit[E_AXIS])
552
+    lround(x * axis_steps_per_mm[X_AXIS]),
553
+    lround(y * axis_steps_per_mm[Y_AXIS]),
554
+    lround(z * axis_steps_per_mm[Z_AXIS]),
555
+    lround(e * axis_steps_per_mm[E_AXIS])
556
   };
556
   };
557
 
557
 
558
   long dx = target[X_AXIS] - position[X_AXIS],
558
   long dx = target[X_AXIS] - position[X_AXIS],
574
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
574
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
575
       }
575
       }
576
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
576
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
577
-        if (labs(de) > axis_steps_per_unit[E_AXIS] * (EXTRUDE_MAXLENGTH)) {
577
+        if (labs(de) > axis_steps_per_mm[E_AXIS] * (EXTRUDE_MAXLENGTH)) {
578
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
578
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
579
           de = 0; // no difference
579
           de = 0; // no difference
580
           SERIAL_ECHO_START;
580
           SERIAL_ECHO_START;
771
   #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
771
   #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
772
     float delta_mm[6];
772
     float delta_mm[6];
773
     #if ENABLED(COREXY)
773
     #if ENABLED(COREXY)
774
-      delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
775
-      delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
776
-      delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
777
-      delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_unit[A_AXIS];
778
-      delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_unit[B_AXIS];
774
+      delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
775
+      delta_mm[Y_HEAD] = dy / axis_steps_per_mm[B_AXIS];
776
+      delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
777
+      delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_mm[A_AXIS];
778
+      delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_mm[B_AXIS];
779
     #elif ENABLED(COREXZ)
779
     #elif ENABLED(COREXZ)
780
-      delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
781
-      delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
782
-      delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
783
-      delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_unit[A_AXIS];
784
-      delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_unit[C_AXIS];
780
+      delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
781
+      delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
782
+      delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
783
+      delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_mm[A_AXIS];
784
+      delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_mm[C_AXIS];
785
     #elif ENABLED(COREYZ)
785
     #elif ENABLED(COREYZ)
786
-      delta_mm[X_AXIS] = dx / axis_steps_per_unit[A_AXIS];
787
-      delta_mm[Y_HEAD] = dy / axis_steps_per_unit[Y_AXIS];
788
-      delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
789
-      delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_unit[B_AXIS];
790
-      delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_unit[C_AXIS];
786
+      delta_mm[X_AXIS] = dx / axis_steps_per_mm[A_AXIS];
787
+      delta_mm[Y_HEAD] = dy / axis_steps_per_mm[Y_AXIS];
788
+      delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
789
+      delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_mm[B_AXIS];
790
+      delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_mm[C_AXIS];
791
     #endif
791
     #endif
792
   #else
792
   #else
793
     float delta_mm[4];
793
     float delta_mm[4];
794
-    delta_mm[X_AXIS] = dx / axis_steps_per_unit[X_AXIS];
795
-    delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
796
-    delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
794
+    delta_mm[X_AXIS] = dx / axis_steps_per_mm[X_AXIS];
795
+    delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
796
+    delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
797
   #endif
797
   #endif
798
-  delta_mm[E_AXIS] = (de / axis_steps_per_unit[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
798
+  delta_mm[E_AXIS] = (de / axis_steps_per_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
799
 
799
 
800
   if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
800
   if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
801
     block->millimeters = fabs(delta_mm[E_AXIS]);
801
     block->millimeters = fabs(delta_mm[E_AXIS]);
936
   float steps_per_mm = block->step_event_count / block->millimeters;
936
   float steps_per_mm = block->step_event_count / block->millimeters;
937
   long bsx = block->steps[X_AXIS], bsy = block->steps[Y_AXIS], bsz = block->steps[Z_AXIS], bse = block->steps[E_AXIS];
937
   long bsx = block->steps[X_AXIS], bsy = block->steps[Y_AXIS], bsz = block->steps[Z_AXIS], bse = block->steps[E_AXIS];
938
   if (bsx == 0 && bsy == 0 && bsz == 0) {
938
   if (bsx == 0 && bsy == 0 && bsz == 0) {
939
-    block->acceleration_st = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
939
+    block->acceleration_steps_per_s2 = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
940
   }
940
   }
941
   else if (bse == 0) {
941
   else if (bse == 0) {
942
-    block->acceleration_st = ceil(travel_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
942
+    block->acceleration_steps_per_s2 = ceil(travel_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
943
   }
943
   }
944
   else {
944
   else {
945
-    block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
945
+    block->acceleration_steps_per_s2 = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
946
   }
946
   }
947
   // Limit acceleration per axis
947
   // Limit acceleration per axis
948
-  unsigned long acc_st = block->acceleration_st,
949
-                xsteps = axis_steps_per_sqr_second[X_AXIS],
950
-                ysteps = axis_steps_per_sqr_second[Y_AXIS],
951
-                zsteps = axis_steps_per_sqr_second[Z_AXIS],
952
-                esteps = axis_steps_per_sqr_second[E_AXIS],
948
+  unsigned long acc_st = block->acceleration_steps_per_s2,
949
+                x_acc_st = max_acceleration_steps_per_s2[X_AXIS],
950
+                y_acc_st = max_acceleration_steps_per_s2[Y_AXIS],
951
+                z_acc_st = max_acceleration_steps_per_s2[Z_AXIS],
952
+                e_acc_st = max_acceleration_steps_per_s2[E_AXIS],
953
                 allsteps = block->step_event_count;
953
                 allsteps = block->step_event_count;
954
-  if (xsteps < (acc_st * bsx) / allsteps) acc_st = (xsteps * allsteps) / bsx;
955
-  if (ysteps < (acc_st * bsy) / allsteps) acc_st = (ysteps * allsteps) / bsy;
956
-  if (zsteps < (acc_st * bsz) / allsteps) acc_st = (zsteps * allsteps) / bsz;
957
-  if (esteps < (acc_st * bse) / allsteps) acc_st = (esteps * allsteps) / bse;
954
+  if (x_acc_st < (acc_st * bsx) / allsteps) acc_st = (x_acc_st * allsteps) / bsx;
955
+  if (y_acc_st < (acc_st * bsy) / allsteps) acc_st = (y_acc_st * allsteps) / bsy;
956
+  if (z_acc_st < (acc_st * bsz) / allsteps) acc_st = (z_acc_st * allsteps) / bsz;
957
+  if (e_acc_st < (acc_st * bse) / allsteps) acc_st = (e_acc_st * allsteps) / bse;
958
 
958
 
959
-  block->acceleration_st = acc_st;
959
+  block->acceleration_steps_per_s2 = acc_st;
960
   block->acceleration = acc_st / steps_per_mm;
960
   block->acceleration = acc_st / steps_per_mm;
961
   block->acceleration_rate = (long)(acc_st * 16777216.0 / (F_CPU / 8.0));
961
   block->acceleration_rate = (long)(acc_st * 16777216.0 / (F_CPU / 8.0));
962
 
962
 
1057
       block->advance = 0;
1057
       block->advance = 0;
1058
     }
1058
     }
1059
     else {
1059
     else {
1060
-      long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
1060
+      long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_steps_per_s2);
1061
       float advance = ((STEPS_PER_CUBIC_MM_E) * (EXTRUDER_ADVANCE_K)) * (cse * cse * (EXTRUSION_AREA) * (EXTRUSION_AREA)) * 256;
1061
       float advance = ((STEPS_PER_CUBIC_MM_E) * (EXTRUDER_ADVANCE_K)) * (cse * cse * (EXTRUSION_AREA) * (EXTRUSION_AREA)) * 256;
1062
       block->advance = advance;
1062
       block->advance = advance;
1063
       block->advance_rate = acc_dist ? advance / (float)acc_dist : 0;
1063
       block->advance_rate = acc_dist ? advance / (float)acc_dist : 0;
1127
       apply_rotation_xyz(bed_level_matrix, x, y, z);
1127
       apply_rotation_xyz(bed_level_matrix, x, y, z);
1128
     #endif
1128
     #endif
1129
 
1129
 
1130
-    long nx = position[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]),
1131
-         ny = position[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]),
1132
-         nz = position[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]),
1133
-         ne = position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]);
1130
+    long nx = position[X_AXIS] = lround(x * axis_steps_per_mm[X_AXIS]),
1131
+         ny = position[Y_AXIS] = lround(y * axis_steps_per_mm[Y_AXIS]),
1132
+         nz = position[Z_AXIS] = lround(z * axis_steps_per_mm[Z_AXIS]),
1133
+         ne = position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
1134
     stepper.set_position(nx, ny, nz, ne);
1134
     stepper.set_position(nx, ny, nz, ne);
1135
     previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
1135
     previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
1136
 
1136
 
1141
  * Directly set the planner E position (hence the stepper E position).
1141
  * Directly set the planner E position (hence the stepper E position).
1142
  */
1142
  */
1143
 void Planner::set_e_position_mm(const float& e) {
1143
 void Planner::set_e_position_mm(const float& e) {
1144
-  position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]);
1144
+  position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
1145
   stepper.set_e_position(position[E_AXIS]);
1145
   stepper.set_e_position(position[E_AXIS]);
1146
 }
1146
 }
1147
 
1147
 
1148
 // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
1148
 // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
1149
 void Planner::reset_acceleration_rates() {
1149
 void Planner::reset_acceleration_rates() {
1150
   for (int i = 0; i < NUM_AXIS; i++)
1150
   for (int i = 0; i < NUM_AXIS; i++)
1151
-    axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
1151
+    max_acceleration_steps_per_s2[i] = max_acceleration_mm_per_s2[i] * axis_steps_per_mm[i];
1152
 }
1152
 }
1153
 
1153
 
1154
 #if ENABLED(AUTOTEMP)
1154
 #if ENABLED(AUTOTEMP)

+ 20
- 21
Marlin/planner.h View File

58
   long steps[NUM_AXIS];                     // Step count along each axis
58
   long steps[NUM_AXIS];                     // Step count along each axis
59
   unsigned long step_event_count;           // The number of step events required to complete this block
59
   unsigned long step_event_count;           // The number of step events required to complete this block
60
 
60
 
61
-  long accelerate_until;                    // The index of the step event on which to stop acceleration
62
-  long decelerate_after;                    // The index of the step event on which to start decelerating
63
-  long acceleration_rate;                   // The acceleration rate used for acceleration calculation
61
+  long accelerate_until,                    // The index of the step event on which to stop acceleration
62
+       decelerate_after,                    // The index of the step event on which to start decelerating
63
+       acceleration_rate;                   // The acceleration rate used for acceleration calculation
64
 
64
 
65
   unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
65
   unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
66
 
66
 
72
   #endif
72
   #endif
73
 
73
 
74
   // Fields used by the motion planner to manage acceleration
74
   // Fields used by the motion planner to manage acceleration
75
-  float nominal_speed;                               // The nominal speed for this block in mm/sec
76
-  float entry_speed;                                 // Entry speed at previous-current junction in mm/sec
77
-  float max_entry_speed;                             // Maximum allowable junction entry speed in mm/sec
78
-  float millimeters;                                 // The total travel of this block in mm
79
-  float acceleration;                                // acceleration mm/sec^2
80
-  unsigned char recalculate_flag;                    // Planner flag to recalculate trapezoids on entry junction
81
-  unsigned char nominal_length_flag;                 // Planner flag for nominal speed always reached
75
+  float nominal_speed,                               // The nominal speed for this block in mm/sec
76
+        entry_speed,                                 // Entry speed at previous-current junction in mm/sec
77
+        max_entry_speed,                             // Maximum allowable junction entry speed in mm/sec
78
+        millimeters,                                 // The total travel of this block in mm
79
+        acceleration;                                // acceleration mm/sec^2
80
+  unsigned char recalculate_flag,                    // Planner flag to recalculate trapezoids on entry junction
81
+                nominal_length_flag;                 // Planner flag for nominal speed always reached
82
 
82
 
83
   // Settings for the trapezoid generator
83
   // Settings for the trapezoid generator
84
-  unsigned long nominal_rate;                        // The nominal step rate for this block in step_events/sec
85
-  unsigned long initial_rate;                        // The jerk-adjusted step rate at start of block
86
-  unsigned long final_rate;                          // The minimal rate at exit
87
-  unsigned long acceleration_st;                     // acceleration steps/sec^2
84
+  unsigned long nominal_rate,                        // The nominal step rate for this block in step_events/sec
85
+                initial_rate,                        // The jerk-adjusted step rate at start of block
86
+                final_rate,                          // The minimal rate at exit
87
+                acceleration_steps_per_s2;           // acceleration steps/sec^2
88
 
88
 
89
   #if FAN_COUNT > 0
89
   #if FAN_COUNT > 0
90
     unsigned long fan_speed[FAN_COUNT];
90
     unsigned long fan_speed[FAN_COUNT];
91
   #endif
91
   #endif
92
 
92
 
93
   #if ENABLED(BARICUDA)
93
   #if ENABLED(BARICUDA)
94
-    unsigned long valve_pressure;
95
-    unsigned long e_to_p_pressure;
94
+    unsigned long valve_pressure, e_to_p_pressure;
96
   #endif
95
   #endif
97
 
96
 
98
   volatile char busy;
97
   volatile char busy;
113
     static volatile uint8_t block_buffer_tail;
112
     static volatile uint8_t block_buffer_tail;
114
 
113
 
115
     static float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
114
     static float max_feedrate[NUM_AXIS]; // Max speeds in mm per minute
116
-    static float axis_steps_per_unit[NUM_AXIS];
117
-    static unsigned long axis_steps_per_sqr_second[NUM_AXIS];
118
-    static unsigned long max_acceleration_units_per_sq_second[NUM_AXIS]; // Use M201 to override by software
115
+    static float axis_steps_per_mm[NUM_AXIS];
116
+    static unsigned long max_acceleration_steps_per_s2[NUM_AXIS];
117
+    static unsigned long max_acceleration_mm_per_s2[NUM_AXIS]; // Use M201 to override by software
119
 
118
 
120
     static millis_t min_segment_time;
119
     static millis_t min_segment_time;
121
     static float min_feedrate;
120
     static float min_feedrate;
135
 
134
 
136
     /**
135
     /**
137
      * The current position of the tool in absolute steps
136
      * The current position of the tool in absolute steps
138
-     * Reclculated if any axis_steps_per_unit are changed by gcode
137
+     * Reclculated if any axis_steps_per_mm are changed by gcode
139
      */
138
      */
140
     static long position[NUM_AXIS];
139
     static long position[NUM_AXIS];
141
 
140
 
213
        * Set the planner.position and individual stepper positions.
212
        * Set the planner.position and individual stepper positions.
214
        * Used by G92, G28, G29, and other procedures.
213
        * Used by G92, G28, G29, and other procedures.
215
        *
214
        *
216
-       * Multiplies by axis_steps_per_unit[] and does necessary conversion
215
+       * Multiplies by axis_steps_per_mm[] and does necessary conversion
217
        * for COREXY / COREXZ / COREYZ to set the corresponding stepper positions.
216
        * for COREXY / COREXZ / COREYZ to set the corresponding stepper positions.
218
        *
217
        *
219
        * Clears previous speed values.
218
        * Clears previous speed values.

+ 1
- 1
Marlin/stepper.cpp View File

754
   #else
754
   #else
755
     axis_steps = position(axis);
755
     axis_steps = position(axis);
756
   #endif
756
   #endif
757
-  return axis_steps / planner.axis_steps_per_unit[axis];
757
+  return axis_steps / planner.axis_steps_per_mm[axis];
758
 }
758
 }
759
 
759
 
760
 void Stepper::finish_and_disable() {
760
 void Stepper::finish_and_disable() {

+ 1
- 1
Marlin/stepper.h View File

243
     // Triggered position of an axis in mm (not core-savvy)
243
     // Triggered position of an axis in mm (not core-savvy)
244
     //
244
     //
245
     static FORCE_INLINE float triggered_position_mm(AxisEnum axis) {
245
     static FORCE_INLINE float triggered_position_mm(AxisEnum axis) {
246
-      return endstops_trigsteps[axis] / planner.axis_steps_per_unit[axis];
246
+      return endstops_trigsteps[axis] / planner.axis_steps_per_mm[axis];
247
     }
247
     }
248
 
248
 
249
   private:
249
   private:

+ 1
- 1
Marlin/temperature.cpp View File

559
               lpq[lpq_ptr++] = 0;
559
               lpq[lpq_ptr++] = 0;
560
             }
560
             }
561
             if (lpq_ptr >= lpq_len) lpq_ptr = 0;
561
             if (lpq_ptr >= lpq_len) lpq_ptr = 0;
562
-            cTerm[_CTERM_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_unit[E_AXIS]) * PID_PARAM(Kc, e);
562
+            cTerm[_CTERM_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_mm[E_AXIS]) * PID_PARAM(Kc, e);
563
             pid_output += cTerm[e];
563
             pid_output += cTerm[e];
564
           }
564
           }
565
         #endif //PID_ADD_EXTRUSION_RATE
565
         #endif //PID_ADD_EXTRUSION_RATE

+ 9
- 9
Marlin/ultralcd.cpp View File

1686
   MENU_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.max_feedrate[E_AXIS], 1, 999);
1686
   MENU_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.max_feedrate[E_AXIS], 1, 999);
1687
   MENU_ITEM_EDIT(float3, MSG_VMIN, &planner.min_feedrate, 0, 999);
1687
   MENU_ITEM_EDIT(float3, MSG_VMIN, &planner.min_feedrate, 0, 999);
1688
   MENU_ITEM_EDIT(float3, MSG_VTRAV_MIN, &planner.min_travel_feedrate, 0, 999);
1688
   MENU_ITEM_EDIT(float3, MSG_VTRAV_MIN, &planner.min_travel_feedrate, 0, 999);
1689
-  MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_X, &planner.max_acceleration_units_per_sq_second[X_AXIS], 100, 99000, _reset_acceleration_rates);
1690
-  MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_Y, &planner.max_acceleration_units_per_sq_second[Y_AXIS], 100, 99000, _reset_acceleration_rates);
1691
-  MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_Z, &planner.max_acceleration_units_per_sq_second[Z_AXIS], 10, 99000, _reset_acceleration_rates);
1692
-  MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.max_acceleration_units_per_sq_second[E_AXIS], 100, 99000, _reset_acceleration_rates);
1689
+  MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_X, &planner.max_acceleration_mm_per_s2[X_AXIS], 100, 99000, _reset_acceleration_rates);
1690
+  MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_Y, &planner.max_acceleration_mm_per_s2[Y_AXIS], 100, 99000, _reset_acceleration_rates);
1691
+  MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_Z, &planner.max_acceleration_mm_per_s2[Z_AXIS], 10, 99000, _reset_acceleration_rates);
1692
+  MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_acceleration_rates);
1693
   MENU_ITEM_EDIT(float5, MSG_A_RETRACT, &planner.retract_acceleration, 100, 99000);
1693
   MENU_ITEM_EDIT(float5, MSG_A_RETRACT, &planner.retract_acceleration, 100, 99000);
1694
   MENU_ITEM_EDIT(float5, MSG_A_TRAVEL, &planner.travel_acceleration, 100, 99000);
1694
   MENU_ITEM_EDIT(float5, MSG_A_TRAVEL, &planner.travel_acceleration, 100, 99000);
1695
-  MENU_ITEM_EDIT(float52, MSG_XSTEPS, &planner.axis_steps_per_unit[X_AXIS], 5, 9999);
1696
-  MENU_ITEM_EDIT(float52, MSG_YSTEPS, &planner.axis_steps_per_unit[Y_AXIS], 5, 9999);
1695
+  MENU_ITEM_EDIT(float52, MSG_XSTEPS, &planner.axis_steps_per_mm[X_AXIS], 5, 9999);
1696
+  MENU_ITEM_EDIT(float52, MSG_YSTEPS, &planner.axis_steps_per_mm[Y_AXIS], 5, 9999);
1697
   #if ENABLED(DELTA)
1697
   #if ENABLED(DELTA)
1698
-    MENU_ITEM_EDIT(float52, MSG_ZSTEPS, &planner.axis_steps_per_unit[Z_AXIS], 5, 9999);
1698
+    MENU_ITEM_EDIT(float52, MSG_ZSTEPS, &planner.axis_steps_per_mm[Z_AXIS], 5, 9999);
1699
   #else
1699
   #else
1700
-    MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &planner.axis_steps_per_unit[Z_AXIS], 5, 9999);
1700
+    MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &planner.axis_steps_per_mm[Z_AXIS], 5, 9999);
1701
   #endif
1701
   #endif
1702
-  MENU_ITEM_EDIT(float51, MSG_ESTEPS, &planner.axis_steps_per_unit[E_AXIS], 5, 9999);
1702
+  MENU_ITEM_EDIT(float51, MSG_ESTEPS, &planner.axis_steps_per_mm[E_AXIS], 5, 9999);
1703
   #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
1703
   #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
1704
     MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &stepper.abort_on_endstop_hit);
1704
     MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &stepper.abort_on_endstop_hit);
1705
   #endif
1705
   #endif

Loading…
Cancel
Save