Browse Source

Merge pull request #4389 from thinkyhead/rc_optimize_planner

Optimize planner with precalculation, etc.
Scott Lahteine 8 years ago
parent
commit
b7b7c90477

+ 22
- 21
Marlin/Marlin_main.cpp View File

@@ -610,6 +610,20 @@ static void report_current_position();
610 610
     print_xyz(PSTR(STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0)
611 611
 #endif
612 612
 
613
+/**
614
+ * sync_plan_position
615
+ * Set planner / stepper positions to the cartesian current_position.
616
+ * The stepper code translates these coordinates into step units.
617
+ * Allows translation between steps and millimeters for cartesian & core robots
618
+ */
619
+inline void sync_plan_position() {
620
+  #if ENABLED(DEBUG_LEVELING_FEATURE)
621
+    if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
622
+  #endif
623
+  planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
624
+}
625
+inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); }
626
+
613 627
 #if ENABLED(DELTA) || ENABLED(SCARA)
614 628
   inline void sync_plan_position_delta() {
615 629
     #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -897,16 +911,15 @@ void setup() {
897 911
   // Send "ok" after commands by default
898 912
   for (int8_t i = 0; i < BUFSIZE; i++) send_ok[i] = true;
899 913
 
900
-  // loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
914
+  // Load data from EEPROM if available (or use defaults)
915
+  // This also updates variables in the planner, elsewhere
901 916
   Config_RetrieveSettings();
902 917
 
903 918
   // Initialize current position based on home_offset
904 919
   memcpy(current_position, home_offset, sizeof(home_offset));
905 920
 
906
-  #if ENABLED(DELTA) || ENABLED(SCARA)
907
-    // Vital to init kinematic equivalent for X0 Y0 Z0
908
-    SYNC_PLAN_POSITION_KINEMATIC();
909
-  #endif
921
+  // Vital to init stepper/planner equivalent for current_position
922
+  SYNC_PLAN_POSITION_KINEMATIC();
910 923
 
911 924
   thermalManager.init();    // Initialize temperature loop
912 925
 
@@ -1319,7 +1332,7 @@ inline bool code_value_bool() { return code_value_byte() > 0; }
1319 1332
       case TEMPUNIT_C:
1320 1333
         return code_value_float();
1321 1334
       case TEMPUNIT_F:
1322
-        return (code_value_float() - 32) / 1.8;
1335
+        return (code_value_float() - 32) * 0.5555555556;
1323 1336
       case TEMPUNIT_K:
1324 1337
         return code_value_float() - 272.15;
1325 1338
       default:
@@ -1333,7 +1346,7 @@ inline bool code_value_bool() { return code_value_byte() > 0; }
1333 1346
       case TEMPUNIT_K:
1334 1347
         return code_value_float();
1335 1348
       case TEMPUNIT_F:
1336
-        return code_value_float() / 1.8;
1349
+        return code_value_float() * 0.5555555556;
1337 1350
       default:
1338 1351
         return code_value_float();
1339 1352
     }
@@ -1627,19 +1640,6 @@ inline void line_to_destination(float fr_mm_m) {
1627 1640
 }
1628 1641
 inline void line_to_destination() { line_to_destination(feedrate_mm_m); }
1629 1642
 
1630
-/**
1631
- * sync_plan_position
1632
- * Set planner / stepper positions to the cartesian current_position.
1633
- * The stepper code translates these coordinates into step units.
1634
- * Allows translation between steps and millimeters for cartesian & core robots
1635
- */
1636
-inline void sync_plan_position() {
1637
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1638
-    if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
1639
-  #endif
1640
-  planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1641
-}
1642
-inline void sync_plan_position_e() { planner.set_e_position_mm(current_position[E_AXIS]); }
1643 1643
 inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
1644 1644
 inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
1645 1645
 
@@ -5147,6 +5147,7 @@ inline void gcode_M92() {
5147 5147
       }
5148 5148
     }
5149 5149
   }
5150
+  planner.refresh_positioning();
5150 5151
 }
5151 5152
 
5152 5153
 /**
@@ -6140,7 +6141,7 @@ inline void gcode_M428() {
6140 6141
   bool err = false;
6141 6142
   LOOP_XYZ(i) {
6142 6143
     if (axis_homed[i]) {
6143
-      float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) / 2) ? base_home_pos(i) : 0,
6144
+      float base = (current_position[i] > (sw_endstop_min[i] + sw_endstop_max[i]) * 0.5) ? base_home_pos(i) : 0,
6144 6145
             diff = current_position[i] - LOGICAL_POSITION(base, i);
6145 6146
       if (diff > -20 && diff < 20) {
6146 6147
         set_home_offset((AxisEnum)i, home_offset[i] - diff);

+ 6
- 0
Marlin/configuration_store.cpp View File

@@ -171,10 +171,16 @@ void Config_Postprocess() {
171 171
   // steps per s2 needs to be updated to agree with units per s2
172 172
   planner.reset_acceleration_rates();
173 173
 
174
+  // Make sure delta kinematics are updated before refreshing the
175
+  // planner position so the stepper counts will be set correctly.
174 176
   #if ENABLED(DELTA)
175 177
     recalc_delta_settings(delta_radius, delta_diagonal_rod);
176 178
   #endif
177 179
 
180
+  // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
181
+  // and init stepper.count[], planner.position[] with current_position
182
+  planner.refresh_positioning();
183
+
178 184
   #if ENABLED(PIDTEMP)
179 185
     thermalManager.updatePID();
180 186
   #endif

+ 67
- 44
Marlin/planner.cpp View File

@@ -80,29 +80,31 @@ block_t Planner::block_buffer[BLOCK_BUFFER_SIZE];
80 80
 volatile uint8_t Planner::block_buffer_head = 0;           // Index of the next block to be pushed
81 81
 volatile uint8_t Planner::block_buffer_tail = 0;
82 82
 
83
-float Planner::max_feedrate_mm_s[NUM_AXIS]; // Max speeds in mm per second
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
83
+float Planner::max_feedrate_mm_s[NUM_AXIS], // Max speeds in mm per second
84
+      Planner::axis_steps_per_mm[NUM_AXIS],
85
+      Planner::steps_to_mm[NUM_AXIS];
86
+
87
+unsigned long Planner::max_acceleration_steps_per_s2[NUM_AXIS],
88
+              Planner::max_acceleration_mm_per_s2[NUM_AXIS]; // Use M201 to override by software
87 89
 
88 90
 millis_t Planner::min_segment_time;
89
-float Planner::min_feedrate_mm_s;
90
-float Planner::acceleration;         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
91
-float Planner::retract_acceleration; // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
92
-float Planner::travel_acceleration;  // Travel acceleration mm/s^2  DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
93
-float Planner::max_xy_jerk;          // The largest speed change requiring no acceleration
94
-float Planner::max_z_jerk;
95
-float Planner::max_e_jerk;
96
-float Planner::min_travel_feedrate_mm_s;
91
+float Planner::min_feedrate_mm_s,
92
+      Planner::acceleration,         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
93
+      Planner::retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
94
+      Planner::travel_acceleration,  // Travel acceleration mm/s^2  DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
95
+      Planner::max_xy_jerk,          // The largest speed change requiring no acceleration
96
+      Planner::max_z_jerk,
97
+      Planner::max_e_jerk,
98
+      Planner::min_travel_feedrate_mm_s;
97 99
 
98 100
 #if ENABLED(AUTO_BED_LEVELING_FEATURE)
99 101
   matrix_3x3 Planner::bed_level_matrix; // Transform to compensate for bed level
100 102
 #endif
101 103
 
102 104
 #if ENABLED(AUTOTEMP)
103
-  float Planner::autotemp_max = 250;
104
-  float Planner::autotemp_min = 210;
105
-  float Planner::autotemp_factor = 0.1;
105
+  float Planner::autotemp_max = 250,
106
+        Planner::autotemp_min = 210,
107
+        Planner::autotemp_factor = 0.1;
106 108
   bool Planner::autotemp_enabled = false;
107 109
 #endif
108 110
 
@@ -110,9 +112,8 @@ float Planner::min_travel_feedrate_mm_s;
110 112
 
111 113
 long Planner::position[NUM_AXIS] = { 0 };
112 114
 
113
-float Planner::previous_speed[NUM_AXIS];
114
-
115
-float Planner::previous_nominal_speed;
115
+float Planner::previous_speed[NUM_AXIS],
116
+      Planner::previous_nominal_speed;
116 117
 
117 118
 #if ENABLED(DISABLE_INACTIVE_EXTRUDER)
118 119
   uint8_t Planner::g_uc_extruder_last_move[EXTRUDERS] = { 0 };
@@ -783,31 +784,37 @@ void Planner::check_axes_activity() {
783 784
   #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
784 785
     float delta_mm[6];
785 786
     #if ENABLED(COREXY)
786
-      delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
787
-      delta_mm[Y_HEAD] = dy / axis_steps_per_mm[B_AXIS];
788
-      delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
789
-      delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_mm[A_AXIS];
790
-      delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_mm[B_AXIS];
787
+      delta_mm[X_HEAD] = dx * steps_to_mm[A_AXIS];
788
+      delta_mm[Y_HEAD] = dy * steps_to_mm[B_AXIS];
789
+      delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
790
+      delta_mm[A_AXIS] = (dx + dy) * steps_to_mm[A_AXIS];
791
+      delta_mm[B_AXIS] = (dx - dy) * steps_to_mm[B_AXIS];
791 792
     #elif ENABLED(COREXZ)
792
-      delta_mm[X_HEAD] = dx / axis_steps_per_mm[A_AXIS];
793
-      delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
794
-      delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
795
-      delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_mm[A_AXIS];
796
-      delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_mm[C_AXIS];
793
+      delta_mm[X_HEAD] = dx * steps_to_mm[A_AXIS];
794
+      delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
795
+      delta_mm[Z_HEAD] = dz * steps_to_mm[C_AXIS];
796
+      delta_mm[A_AXIS] = (dx + dz) * steps_to_mm[A_AXIS];
797
+      delta_mm[C_AXIS] = (dx - dz) * steps_to_mm[C_AXIS];
797 798
     #elif ENABLED(COREYZ)
798
-      delta_mm[X_AXIS] = dx / axis_steps_per_mm[A_AXIS];
799
-      delta_mm[Y_HEAD] = dy / axis_steps_per_mm[Y_AXIS];
800
-      delta_mm[Z_HEAD] = dz / axis_steps_per_mm[C_AXIS];
801
-      delta_mm[B_AXIS] = (dy + dz) / axis_steps_per_mm[B_AXIS];
802
-      delta_mm[C_AXIS] = (dy - dz) / axis_steps_per_mm[C_AXIS];
799
+      delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
800
+      delta_mm[Y_HEAD] = dy * steps_to_mm[B_AXIS];
801
+      delta_mm[Z_HEAD] = dz * steps_to_mm[C_AXIS];
802
+      delta_mm[B_AXIS] = (dy + dz) * steps_to_mm[B_AXIS];
803
+      delta_mm[C_AXIS] = (dy - dz) * steps_to_mm[C_AXIS];
803 804
     #endif
804 805
   #else
805 806
     float delta_mm[4];
806
-    delta_mm[X_AXIS] = dx / axis_steps_per_mm[X_AXIS];
807
-    delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
808
-    delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
807
+    #if ENABLED(DELTA)
808
+      // On delta all axes (should!) have the same steps-per-mm
809
+      // so calculate distance in steps first, then do one division
810
+      // at the end to get millimeters
811
+    #else
812
+      delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
813
+      delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
814
+      delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
815
+    #endif
809 816
   #endif
810
-  delta_mm[E_AXIS] = (de / axis_steps_per_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
817
+  delta_mm[E_AXIS] = 0.01 * (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder];
811 818
 
812 819
   if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
813 820
     block->millimeters = fabs(delta_mm[E_AXIS]);
@@ -820,10 +827,16 @@ void Planner::check_axes_activity() {
820 827
         sq(delta_mm[X_HEAD]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_HEAD])
821 828
       #elif ENABLED(COREYZ)
822 829
         sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_HEAD]) + sq(delta_mm[Z_HEAD])
830
+      #elif ENABLED(DELTA)
831
+        sq(dx) + sq(dy) + sq(dz)
823 832
       #else
824 833
         sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_AXIS])
825 834
       #endif
826
-    );
835
+    )
836
+      #if ENABLED(DELTA)
837
+        * steps_to_mm[X_AXIS]
838
+      #endif
839
+    ;
827 840
   }
828 841
   float inverse_millimeters = 1.0 / block->millimeters;  // Inverse millimeters to remove multiple divides
829 842
 
@@ -875,7 +888,7 @@ void Planner::check_axes_activity() {
875 888
         while (filwidth_delay_dist >= MMD_MM) filwidth_delay_dist -= MMD_MM;
876 889
 
877 890
         // Convert into an index into the measurement array
878
-        filwidth_delay_index1 = (int)(filwidth_delay_dist / 10.0 + 0.0001);
891
+        filwidth_delay_index1 = (int)(filwidth_delay_dist * 0.1 + 0.0001);
879 892
 
880 893
         // If the index has changed (must have gone forward)...
881 894
         if (filwidth_delay_index1 != filwidth_delay_index2) {
@@ -962,7 +975,7 @@ void Planner::check_axes_activity() {
962 975
       block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[E_AXIS] * block->step_event_count) / block->steps[E_AXIS];
963 976
   }
964 977
   block->acceleration = block->acceleration_steps_per_s2 / steps_per_mm;
965
-  block->acceleration_rate = (long)(block->acceleration_steps_per_s2 * 16777216.0 / ((F_CPU) / 8.0));
978
+  block->acceleration_rate = (long)(block->acceleration_steps_per_s2 * 16777216.0 / ((F_CPU) * 0.125));
966 979
 
967 980
   #if 0  // Use old jerk for now
968 981
 
@@ -1008,10 +1021,12 @@ void Planner::check_axes_activity() {
1008 1021
   #endif
1009 1022
 
1010 1023
   // Start with a safe speed
1011
-  float vmax_junction = max_xy_jerk / 2;
1012
-  float vmax_junction_factor = 1.0;
1013
-  float mz2 = max_z_jerk / 2, me2 = max_e_jerk / 2;
1014
-  float csz = current_speed[Z_AXIS], cse = current_speed[E_AXIS];
1024
+  float vmax_junction = max_xy_jerk * 0.5,
1025
+        vmax_junction_factor = 1.0,
1026
+        mz2 = max_z_jerk * 0.5,
1027
+        me2 = max_e_jerk * 0.5,
1028
+        csz = current_speed[Z_AXIS],
1029
+        cse = current_speed[E_AXIS];
1015 1030
   if (fabs(csz) > mz2) vmax_junction = min(vmax_junction, mz2);
1016 1031
   if (fabs(cse) > me2) vmax_junction = min(vmax_junction, me2);
1017 1032
   vmax_junction = min(vmax_junction, block->nominal_speed);
@@ -1164,6 +1179,7 @@ void Planner::check_axes_activity() {
1164 1179
 void Planner::set_e_position_mm(const float& e) {
1165 1180
   position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
1166 1181
   stepper.set_e_position(position[E_AXIS]);
1182
+  previous_speed[E_AXIS] = 0.0;
1167 1183
 }
1168 1184
 
1169 1185
 // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2
@@ -1172,6 +1188,13 @@ void Planner::reset_acceleration_rates() {
1172 1188
     max_acceleration_steps_per_s2[i] = max_acceleration_mm_per_s2[i] * axis_steps_per_mm[i];
1173 1189
 }
1174 1190
 
1191
+// Recalculate position, steps_to_mm if axis_steps_per_mm changes!
1192
+void Planner::refresh_positioning() {
1193
+  LOOP_XYZE(i) planner.steps_to_mm[i] = 1.0 / planner.axis_steps_per_mm[i];
1194
+  set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1195
+  reset_acceleration_rates();
1196
+}
1197
+
1175 1198
 #if ENABLED(AUTOTEMP)
1176 1199
 
1177 1200
   void Planner::autotemp_M109() {

+ 3
- 1
Marlin/planner.h View File

@@ -121,6 +121,7 @@ class Planner {
121 121
 
122 122
     static float max_feedrate_mm_s[NUM_AXIS]; // Max speeds in mm per second
123 123
     static float axis_steps_per_mm[NUM_AXIS];
124
+    static float steps_to_mm[NUM_AXIS];
124 125
     static unsigned long max_acceleration_steps_per_s2[NUM_AXIS];
125 126
     static unsigned long max_acceleration_mm_per_s2[NUM_AXIS]; // Use M201 to override by software
126 127
 
@@ -142,7 +143,7 @@ class Planner {
142 143
 
143 144
     /**
144 145
      * The current position of the tool in absolute steps
145
-     * Reclculated if any axis_steps_per_mm are changed by gcode
146
+     * Recalculated if any axis_steps_per_mm are changed by gcode
146 147
      */
147 148
     static long position[NUM_AXIS];
148 149
 
@@ -187,6 +188,7 @@ class Planner {
187 188
      */
188 189
 
189 190
     static void reset_acceleration_rates();
191
+    static void refresh_positioning();
190 192
 
191 193
     // Manage fans, paste pressure, etc.
192 194
     static void check_axes_activity();

+ 4
- 4
Marlin/stepper.cpp View File

@@ -944,14 +944,14 @@ float Stepper::get_axis_position_mm(AxisEnum axis) {
944 944
       CRITICAL_SECTION_END;
945 945
       // ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
946 946
       // ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2
947
-      axis_steps = (pos1 + ((axis == CORE_AXIS_1) ? pos2 : -pos2)) / 2.0f;
947
+      axis_steps = (pos1 + ((axis == CORE_AXIS_1) ? pos2 : -pos2)) * 0.5f;
948 948
     }
949 949
     else
950 950
       axis_steps = position(axis);
951 951
   #else
952 952
     axis_steps = position(axis);
953 953
   #endif
954
-  return axis_steps / planner.axis_steps_per_mm[axis];
954
+  return axis_steps * planner.steps_to_mm[axis];
955 955
 }
956 956
 
957 957
 void Stepper::finish_and_disable() {
@@ -973,9 +973,9 @@ void Stepper::endstop_triggered(AxisEnum axis) {
973 973
 
974 974
     float axis_pos = count_position[axis];
975 975
     if (axis == CORE_AXIS_1)
976
-      axis_pos = (axis_pos + count_position[CORE_AXIS_2]) / 2;
976
+      axis_pos = (axis_pos + count_position[CORE_AXIS_2]) * 0.5;
977 977
     else if (axis == CORE_AXIS_2)
978
-      axis_pos = (count_position[CORE_AXIS_1] - axis_pos) / 2;
978
+      axis_pos = (count_position[CORE_AXIS_1] - axis_pos) * 0.5;
979 979
     endstops_trigsteps[axis] = axis_pos;
980 980
 
981 981
   #else // !COREXY && !COREXZ && !COREYZ

+ 1
- 1
Marlin/stepper.h View File

@@ -262,7 +262,7 @@ class Stepper {
262 262
     // Triggered position of an axis in mm (not core-savvy)
263 263
     //
264 264
     static FORCE_INLINE float triggered_position_mm(AxisEnum axis) {
265
-      return endstops_trigsteps[axis] / planner.axis_steps_per_mm[axis];
265
+      return endstops_trigsteps[axis] * planner.steps_to_mm[axis];
266 266
     }
267 267
 
268 268
     #if ENABLED(LIN_ADVANCE)

+ 5
- 5
Marlin/temperature.cpp View File

@@ -319,13 +319,13 @@ unsigned char Temperature::soft_pwm[HOTENDS];
319 319
               SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
320 320
               SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
321 321
               if (cycles > 2) {
322
-                Ku = (4.0 * d) / (3.14159265 * (max - min) / 2.0);
323
-                Tu = ((float)(t_low + t_high) / 1000.0);
322
+                Ku = (4.0 * d) / (3.14159265 * (max - min) * 0.5);
323
+                Tu = ((float)(t_low + t_high) * 0.001);
324 324
                 SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
325 325
                 SERIAL_PROTOCOLPAIR(MSG_TU, Tu);
326 326
                 workKp = 0.6 * Ku;
327 327
                 workKi = 2 * workKp / Tu;
328
-                workKd = workKp * Tu / 8;
328
+                workKd = workKp * Tu * 0.125;
329 329
                 SERIAL_PROTOCOLLNPGM(MSG_CLASSIC_PID);
330 330
                 SERIAL_PROTOCOLPAIR(MSG_KP, workKp);
331 331
                 SERIAL_PROTOCOLPAIR(MSG_KI, workKi);
@@ -572,7 +572,7 @@ float Temperature::get_pid_output(int e) {
572 572
               lpq[lpq_ptr] = 0;
573 573
             }
574 574
             if (++lpq_ptr >= lpq_len) lpq_ptr = 0;
575
-            cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
575
+            cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] * planner.steps_to_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
576 576
             pid_output += cTerm[HOTEND_INDEX];
577 577
           }
578 578
         #endif //PID_ADD_EXTRUSION_RATE
@@ -753,7 +753,7 @@ void Temperature::manage_heater() {
753 753
       // Get the delayed info and add 100 to reconstitute to a percent of
754 754
       // the nominal filament diameter then square it to get an area
755 755
       meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
756
-      float vm = pow((measurement_delay[meas_shift_index] + 100.0) / 100.0, 2);
756
+      float vm = pow((measurement_delay[meas_shift_index] + 100.0) * 0.01, 2);
757 757
       NOLESS(vm, 0.01);
758 758
       volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vm;
759 759
     }

+ 7
- 6
Marlin/ultralcd.cpp View File

@@ -678,7 +678,7 @@ void kill_screen(const char* lcd_msg) {
678 678
       }
679 679
       if (lcdDrawUpdate)
680 680
         lcd_implementation_drawedit(msg, ftostr43sign(
681
-          ((1000 * babysteps_done) / planner.axis_steps_per_mm[axis]) * 0.001f
681
+          ((1000 * babysteps_done) * planner.steps_to_mm[axis]) * 0.001f
682 682
         ));
683 683
     }
684 684
 
@@ -1769,6 +1769,7 @@ void kill_screen(const char* lcd_msg) {
1769 1769
   }
1770 1770
 
1771 1771
   static void _reset_acceleration_rates() { planner.reset_acceleration_rates(); }
1772
+  static void _planner_refresh_positioning() { planner.refresh_positioning(); }
1772 1773
 
1773 1774
   /**
1774 1775
    *
@@ -1805,14 +1806,14 @@ void kill_screen(const char* lcd_msg) {
1805 1806
     MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_acceleration_rates);
1806 1807
     MENU_ITEM_EDIT(float5, MSG_A_RETRACT, &planner.retract_acceleration, 100, 99000);
1807 1808
     MENU_ITEM_EDIT(float5, MSG_A_TRAVEL, &planner.travel_acceleration, 100, 99000);
1808
-    MENU_ITEM_EDIT(float52, MSG_XSTEPS, &planner.axis_steps_per_mm[X_AXIS], 5, 9999);
1809
-    MENU_ITEM_EDIT(float52, MSG_YSTEPS, &planner.axis_steps_per_mm[Y_AXIS], 5, 9999);
1809
+    MENU_ITEM_EDIT_CALLBACK(float52, MSG_XSTEPS, &planner.axis_steps_per_mm[X_AXIS], 5, 9999, _planner_refresh_positioning);
1810
+    MENU_ITEM_EDIT_CALLBACK(float52, MSG_YSTEPS, &planner.axis_steps_per_mm[Y_AXIS], 5, 9999, _planner_refresh_positioning);
1810 1811
     #if ENABLED(DELTA)
1811
-      MENU_ITEM_EDIT(float52, MSG_ZSTEPS, &planner.axis_steps_per_mm[Z_AXIS], 5, 9999);
1812
+      MENU_ITEM_EDIT_CALLBACK(float52, MSG_ZSTEPS, &planner.axis_steps_per_mm[Z_AXIS], 5, 9999, _planner_refresh_positioning);
1812 1813
     #else
1813
-      MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &planner.axis_steps_per_mm[Z_AXIS], 5, 9999);
1814
+      MENU_ITEM_EDIT_CALLBACK(float51, MSG_ZSTEPS, &planner.axis_steps_per_mm[Z_AXIS], 5, 9999, _planner_refresh_positioning);
1814 1815
     #endif
1815
-    MENU_ITEM_EDIT(float51, MSG_ESTEPS, &planner.axis_steps_per_mm[E_AXIS], 5, 9999);
1816
+    MENU_ITEM_EDIT_CALLBACK(float51, MSG_ESTEPS, &planner.axis_steps_per_mm[E_AXIS], 5, 9999, _planner_refresh_positioning);
1816 1817
     #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
1817 1818
       MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &stepper.abort_on_endstop_hit);
1818 1819
     #endif

+ 1
- 1
Marlin/ultralcd_impl_DOGM.h View File

@@ -385,7 +385,7 @@ static void lcd_implementation_status_screen() {
385 385
     // SD Card Progress bar and clock
386 386
     if (IS_SD_PRINTING) {
387 387
       // Progress bar solid part
388
-      u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - (TALL_FONT_CORRECTION));
388
+      u8g.drawBox(55, 50, (unsigned int)(71 * card.percentDone() * 0.01), 2 - (TALL_FONT_CORRECTION));
389 389
     }
390 390
 
391 391
     u8g.setPrintPos(80,48);

Loading…
Cancel
Save