dda.c, RAMPING: 16 bits for move_state.n are sufficient.

This commit is contained in:
Markus Hitter 2011-05-16 00:16:00 +02:00
parent 826f534fff
commit bebb619054
2 changed files with 4 additions and 4 deletions

6
dda.c
View File

@ -532,7 +532,7 @@ void dda_step(DDA *dda) {
// debug ramping algorithm // debug ramping algorithm
//if (dda->step_no == 0) { //if (dda->step_no == 0) {
// sersendf_P(PSTR("\r\nc %lu c_min %lu n %ld"), dda->c, dda->c_min, move_state.n); // sersendf_P(PSTR("\r\nc %lu c_min %lu n %d"), dda->c, dda->c_min, move_state.n);
//} //}
recalc_speed = 0; recalc_speed = 0;
@ -549,14 +549,14 @@ void dda_step(DDA *dda) {
if (recalc_speed) { if (recalc_speed) {
move_state.n += 4; move_state.n += 4;
// be careful of signedness! // be careful of signedness!
move_state.c = (int32_t)move_state.c - ((int32_t)(move_state.c * 2) / move_state.n); move_state.c = (int32_t)move_state.c - ((int32_t)(move_state.c * 2) / (int32_t)move_state.n);
} }
dda->step_no++; dda->step_no++;
// debug ramping algorithm // debug ramping algorithm
// for very low speeds like 10 mm/min, only // for very low speeds like 10 mm/min, only
//if (dda->step_no % 10 /* 10, 100, ...*/ == 0) //if (dda->step_no % 10 /* 10, 100, ...*/ == 0)
// sersendf_P(PSTR("\r\nc %lu c_min %lu n %ld"), dda->c, dda->c_min, move_state.n); // sersendf_P(PSTR("\r\nc %lu c_min %lu n %d"), dda->c, dda->c_min, move_state.n);
#endif #endif
// TODO: did_step is obsolete ... // TODO: did_step is obsolete ...

2
dda.h
View File

@ -59,7 +59,7 @@ typedef struct {
/// time until next step /// time until next step
uint32_t c; uint32_t c;
/// tracking variable /// tracking variable
int32_t n; int16_t n;
#endif #endif
} MOVE_STATE; } MOVE_STATE;