Browse Source

Save some cycle inside the planner

planner.h:
fan speed is used to set integer variables, so no need for long.
Basicaly a byte should be enough for all the fan things, as it's 0-255?

planner.cpp:
Save some float multiplications.
We could squeeze out even more by defining feedrate_percentage,
saved_feedrate_percentage and flow_percentage as float instead of int.
Everytime they are used in the time-critical planner, they are casted to
float and multiplied by 0.01. Not done jet, as they are used in LCD menu
functions I don't know well enough.
Sebastianv650 8 years ago
parent
commit
e3ffb58fbd
2 changed files with 7 additions and 6 deletions
  1. 6
    5
      Marlin/planner.cpp
  2. 1
    1
      Marlin/planner.h

+ 6
- 5
Marlin/planner.cpp View File

662
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
662
         SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
663
       }
663
       }
664
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
664
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
665
-        if (labs(de) > axis_steps_per_mm[E_AXIS] * (EXTRUDE_MAXLENGTH)) {
665
+        if (labs(de) > (int32_t)axis_steps_per_mm[E_AXIS] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
666
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
666
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
667
           de = 0; // no difference
667
           de = 0; // no difference
668
           SERIAL_ECHO_START;
668
           SERIAL_ECHO_START;
699
   #endif
699
   #endif
700
   if (de < 0) SBI(dm, E_AXIS);
700
   if (de < 0) SBI(dm, E_AXIS);
701
 
701
 
702
-  int32_t esteps = labs(de) * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01 + 0.5;
702
+  float esteps_float = de * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01;
703
+  int32_t esteps = abs(esteps_float) + 0.5;
703
 
704
 
704
   // Calculate the buffer head after we push this byte
705
   // Calculate the buffer head after we push this byte
705
-  int next_buffer_head = next_block_index(block_buffer_head);
706
+  int8_t next_buffer_head = next_block_index(block_buffer_head);
706
 
707
 
707
   // If the buffer is full: good! That means we are well ahead of the robot.
708
   // If the buffer is full: good! That means we are well ahead of the robot.
708
   // Rest here until there is room in the buffer.
709
   // Rest here until there is room in the buffer.
798
 
799
 
799
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
800
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
800
 
801
 
801
-      for (int i = 0; i < EXTRUDERS; i++)
802
+      for (int8_t i = 0; i < EXTRUDERS; i++)
802
         if (g_uc_extruder_last_move[i] > 0) g_uc_extruder_last_move[i]--;
803
         if (g_uc_extruder_last_move[i] > 0) g_uc_extruder_last_move[i]--;
803
 
804
 
804
       switch(extruder) {
805
       switch(extruder) {
903
     delta_mm[Y_AXIS] = db * steps_to_mm[Y_AXIS];
904
     delta_mm[Y_AXIS] = db * steps_to_mm[Y_AXIS];
904
     delta_mm[Z_AXIS] = dc * steps_to_mm[Z_AXIS];
905
     delta_mm[Z_AXIS] = dc * steps_to_mm[Z_AXIS];
905
   #endif
906
   #endif
906
-  delta_mm[E_AXIS] = 0.01 * (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * flow_percentage[extruder];
907
+  delta_mm[E_AXIS] = esteps_float * steps_to_mm[E_AXIS];
907
 
908
 
908
   if (block->steps[X_AXIS] < MIN_STEPS_PER_SEGMENT && block->steps[Y_AXIS] < MIN_STEPS_PER_SEGMENT && block->steps[Z_AXIS] < MIN_STEPS_PER_SEGMENT) {
909
   if (block->steps[X_AXIS] < MIN_STEPS_PER_SEGMENT && block->steps[Y_AXIS] < MIN_STEPS_PER_SEGMENT && block->steps[Z_AXIS] < MIN_STEPS_PER_SEGMENT) {
909
     block->millimeters = fabs(delta_mm[E_AXIS]);
910
     block->millimeters = fabs(delta_mm[E_AXIS]);

+ 1
- 1
Marlin/planner.h View File

117
            acceleration_steps_per_s2;       // acceleration steps/sec^2
117
            acceleration_steps_per_s2;       // acceleration steps/sec^2
118
 
118
 
119
   #if FAN_COUNT > 0
119
   #if FAN_COUNT > 0
120
-    uint32_t fan_speed[FAN_COUNT];
120
+    uint16_t fan_speed[FAN_COUNT];
121
   #endif
121
   #endif
122
 
122
 
123
   #if ENABLED(BARICUDA)
123
   #if ENABLED(BARICUDA)

Loading…
Cancel
Save