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.
pull/1/head
whosawhatsis 11 years ago
parent
commit
856edfcc0d
  1. 2
      Marlin/Marlin.h
  2. 4
      Marlin/Marlin_main.cpp
  3. 4
      Marlin/planner.cpp

2
Marlin/Marlin.h

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

4
Marlin/Marlin_main.cpp

@ -188,7 +188,7 @@ bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
int feedmultiply=100; //100->1 200->2
int saved_feedmultiply;
int extrudemultiply=100; //100->1 200->2
float filament_area[EXTRUDERS] = {1.0
float volumetric_multiplier[EXTRUDERS] = {1.0
#if EXTRUDERS > 1
, 1.0
#if EXTRUDERS > 2
@ -2222,7 +2222,7 @@ void process_commands()
SERIAL_ECHOLN(tmp_extruder);
break;
}
filament_area[tmp_extruder] = area;
volumetric_multiplier[tmp_extruder] = 1 / area;
}
break;
case 201: // M201

4
Marlin/planner.cpp

@ -593,7 +593,7 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
#endif
block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]);
block->steps_e = labs(target[E_AXIS]-position[E_AXIS]);
block->steps_e *= filament_area[active_extruder];
block->steps_e *= volumetric_multiplier[active_extruder];
block->steps_e *= extrudemultiply;
block->steps_e /= 100;
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
delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/axis_steps_per_unit[Y_AXIS];
#endif
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*filament_area[active_extruder]*extrudemultiply/100.0;
delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*volumetric_multiplier[active_extruder]*extrudemultiply/100.0;
if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments )
{
block->millimeters = fabs(delta_mm[E_AXIS]);

Loading…
Cancel
Save