From 856edfcc0d844800b887b3b2eaca78ac337656af Mon Sep 17 00:00:00 2001 From: whosawhatsis Date: Fri, 31 Jan 2014 08:43:11 -0800 Subject: [PATCH] Fixed math This is why I wanted to sleep on the code I wrote while falling asleep rather than immediately submitting a pull request. --- Marlin/Marlin.h | 2 +- Marlin/Marlin_main.cpp | 4 ++-- Marlin/planner.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 57d0c04b3..6b54aafb6 100644 --- a/Marlin/Marlin.h +++ b/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 diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 065abf103..b5e4e8519 100644 --- a/Marlin/Marlin_main.cpp +++ b/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 diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 00693d84a..bfc71323f 100644 --- a/Marlin/planner.cpp +++ b/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]);