dda.c: fix overflow for large steps/meter values.

The trick is to use doubles earlier. As these calculations are
optimised out anyways, binary size and performance is kept.

Verified to have an identical outcome on a few common steps/mm and
acceleration cases.
This commit is contained in:
Yiannis Mandravellos 2015-06-02 14:44:55 +03:00 committed by Markus Hitter
parent 6820e2cc0a
commit fb249214f0
1 changed files with 4 additions and 4 deletions

8
dda.c
View File

@ -74,10 +74,10 @@ static const axes_uint32_t PROGMEM maximum_feedrate_P = {
/// \brief Initialization constant for the ramping algorithm. Timer cycles for
/// first step interval.
static const axes_uint32_t PROGMEM c0_P = {
(uint32_t)((double)F_CPU / SQRT((double)(STEPS_PER_M_X * ACCELERATION / 2000.))),
(uint32_t)((double)F_CPU / SQRT((double)(STEPS_PER_M_Y * ACCELERATION / 2000.))),
(uint32_t)((double)F_CPU / SQRT((double)(STEPS_PER_M_Z * ACCELERATION / 2000.))),
(uint32_t)((double)F_CPU / SQRT((double)(STEPS_PER_M_E * ACCELERATION / 2000.)))
(uint32_t)((double)F_CPU / SQRT((double)STEPS_PER_M_X * ACCELERATION / 2000.)),
(uint32_t)((double)F_CPU / SQRT((double)STEPS_PER_M_Y * ACCELERATION / 2000.)),
(uint32_t)((double)F_CPU / SQRT((double)STEPS_PER_M_Z * ACCELERATION / 2000.)),
(uint32_t)((double)F_CPU / SQRT((double)STEPS_PER_M_E * ACCELERATION / 2000.))
};
/*! Set the direction of the 'n' axis