Browse Source

Fixed math

This is why I wanted to sleep on the code I wrote while falling asleep
rather than immediately submitting a pull request.
whosawhatsis 10 years ago
parent
commit
856edfcc0d
3 changed files with 5 additions and 5 deletions
  1. 1
    1
      Marlin/Marlin.h
  2. 2
    2
      Marlin/Marlin_main.cpp
  3. 2
    2
      Marlin/planner.cpp

+ 1
- 1
Marlin/Marlin.h View File

@@ -202,7 +202,7 @@ extern float homing_feedrate[];
202 202
 extern bool axis_relative_modes[];
203 203
 extern int feedmultiply;
204 204
 extern int extrudemultiply; // Sets extrude multiply factor (in percent)
205
-extern float filament_area[EXTRUDERS]; // cross-sectional area of filament (in cubic millimeters)
205
+extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
206 206
 extern float current_position[NUM_AXIS] ;
207 207
 extern float add_homeing[3];
208 208
 #ifdef DELTA

+ 2
- 2
Marlin/Marlin_main.cpp View File

@@ -188,7 +188,7 @@ bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
188 188
 int feedmultiply=100; //100->1 200->2
189 189
 int saved_feedmultiply;
190 190
 int extrudemultiply=100; //100->1 200->2
191
-float filament_area[EXTRUDERS] = {1.0
191
+float volumetric_multiplier[EXTRUDERS] = {1.0
192 192
   #if EXTRUDERS > 1
193 193
     , 1.0
194 194
     #if EXTRUDERS > 2
@@ -2222,7 +2222,7 @@ void process_commands()
2222 2222
           SERIAL_ECHOLN(tmp_extruder);
2223 2223
           break;
2224 2224
         }
2225
-        filament_area[tmp_extruder] = area;
2225
+        volumetric_multiplier[tmp_extruder] = 1 / area;
2226 2226
       }
2227 2227
       break;
2228 2228
     case 201: // M201

+ 2
- 2
Marlin/planner.cpp View File

@@ -593,7 +593,7 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
593 593
 #endif
594 594
   block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]);
595 595
   block->steps_e = labs(target[E_AXIS]-position[E_AXIS]);
596
-  block->steps_e *= filament_area[active_extruder];
596
+  block->steps_e *= volumetric_multiplier[active_extruder];
597 597
   block->steps_e *= extrudemultiply;
598 598
   block->steps_e /= 100;
599 599
   block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
@@ -683,7 +683,7 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
683 683
     delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/axis_steps_per_unit[Y_AXIS];
684 684
   #endif
685 685
   delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
686
-  delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*filament_area[active_extruder]*extrudemultiply/100.0;
686
+  delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*volumetric_multiplier[active_extruder]*extrudemultiply/100.0;
687 687
   if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments )
688 688
   {
689 689
     block->millimeters = fabs(delta_mm[E_AXIS]);

Loading…
Cancel
Save