attempt to fix precision underflow in UM_PER_STEP macros

This commit is contained in:
Michael Moon 2010-10-20 17:22:39 +11:00
parent a0543d3329
commit 18565b776f
1 changed files with 8 additions and 8 deletions

16
dda.c
View File

@ -70,10 +70,10 @@
/*
Used in distance calculation during DDA setup
*/
#define UM_PER_STEP_X ((uint32_t) ((1000.0 / STEPS_PER_MM_X) + 0.5))
#define UM_PER_STEP_Y ((uint32_t) ((1000.0 / STEPS_PER_MM_Y) + 0.5))
#define UM_PER_STEP_Z ((uint32_t) ((1000.0 / STEPS_PER_MM_Z) + 0.5))
#define UM_PER_STEP_E ((uint32_t) ((1000.0 / STEPS_PER_MM_E) + 0.5))
#define UM_PER_STEP_X 1000.0 / STEPS_PER_MM_X
#define UM_PER_STEP_Y 1000.0 / STEPS_PER_MM_Y
#define UM_PER_STEP_Z 1000.0 / STEPS_PER_MM_Z
#define UM_PER_STEP_E 1000.0 / STEPS_PER_MM_E
/*
Maths
@ -271,16 +271,16 @@ void dda_create(DDA *dda, TARGET *target) {
// similarly, find out how fast we can run our axes.
// do this for each axis individually, as the combined speed of two or more axes can be higher than the capabilities of a single one.
c_limit = 0;
c_limit_calc = ((dda->x_delta * UM_PER_STEP_X * 2400) / dda->total_steps * (F_CPU / 40000) / MAXIMUM_FEEDRATE_X) << 8;
c_limit_calc = ((uint32_t) ((dda->x_delta * UM_PER_STEP_X * 2400) / dda->total_steps * (F_CPU / 40000) / MAXIMUM_FEEDRATE_X)) << 8;
if (c_limit_calc > c_limit)
c_limit = c_limit_calc;
c_limit_calc = ((dda->y_delta * UM_PER_STEP_Y * 2400) / dda->total_steps * (F_CPU / 40000) / MAXIMUM_FEEDRATE_Y) << 8;
c_limit_calc = ((uint32_t) ((dda->y_delta * UM_PER_STEP_Y * 2400) / dda->total_steps * (F_CPU / 40000) / MAXIMUM_FEEDRATE_Y)) << 8;
if (c_limit_calc > c_limit)
c_limit = c_limit_calc;
c_limit_calc = ((dda->z_delta * UM_PER_STEP_Z * 2400) / dda->total_steps * (F_CPU / 40000) / MAXIMUM_FEEDRATE_Z) << 8;
c_limit_calc = ((uint32_t) ((dda->z_delta * UM_PER_STEP_Z * 2400) / dda->total_steps * (F_CPU / 40000) / MAXIMUM_FEEDRATE_Z)) << 8;
if (c_limit_calc > c_limit)
c_limit = c_limit_calc;
c_limit_calc = ((dda->e_delta * UM_PER_STEP_E * 2400) / dda->total_steps * (F_CPU / 40000) / MAXIMUM_FEEDRATE_E) << 8;
c_limit_calc = ((uint32_t) ((dda->e_delta * UM_PER_STEP_E * 2400) / dda->total_steps * (F_CPU / 40000) / MAXIMUM_FEEDRATE_E)) << 8;
if (c_limit_calc > c_limit)
c_limit = c_limit_calc;