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 11 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
 extern bool axis_relative_modes[];
202
 extern bool axis_relative_modes[];
203
 extern int feedmultiply;
203
 extern int feedmultiply;
204
 extern int extrudemultiply; // Sets extrude multiply factor (in percent)
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
 extern float current_position[NUM_AXIS] ;
206
 extern float current_position[NUM_AXIS] ;
207
 extern float add_homeing[3];
207
 extern float add_homeing[3];
208
 #ifdef DELTA
208
 #ifdef DELTA

+ 2
- 2
Marlin/Marlin_main.cpp View File

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

+ 2
- 2
Marlin/planner.cpp View File

593
 #endif
593
 #endif
594
   block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]);
594
   block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]);
595
   block->steps_e = labs(target[E_AXIS]-position[E_AXIS]);
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
   block->steps_e *= extrudemultiply;
597
   block->steps_e *= extrudemultiply;
598
   block->steps_e /= 100;
598
   block->steps_e /= 100;
599
   block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
599
   block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
683
     delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/axis_steps_per_unit[Y_AXIS];
683
     delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/axis_steps_per_unit[Y_AXIS];
684
   #endif
684
   #endif
685
   delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
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
   if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments )
687
   if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments )
688
   {
688
   {
689
     block->millimeters = fabs(delta_mm[E_AXIS]);
689
     block->millimeters = fabs(delta_mm[E_AXIS]);

Loading…
Cancel
Save