Move dda->step_no into move_state as well.

This commit is contained in:
Markus Hitter 2011-05-15 20:59:28 +02:00
parent bebb619054
commit ed77abba31
2 changed files with 12 additions and 10 deletions

16
dda.c
View File

@ -350,7 +350,6 @@ void dda_create(DDA *dda, TARGET *target) {
else
dda->accel = 0;
#elif defined ACCELERATION_RAMPING
dda->step_no = 0;
// remove this when people have swallowed the new config item
#ifdef ACCELERATION_STEEPNESS
#error ACCELERATION_STEEPNESS is gone, review your config.h and use ACCELERATION
@ -417,6 +416,11 @@ void dda_start(DDA *dda) {
heater_set(DC_EXTRUDER, DC_EXTRUDER_PWM);
#endif
// initialise state variable
#ifdef ACCELERATION_RAMPING
move_state.step_no = 0;
#endif
// ensure this dda starts
dda->live = 1;
@ -531,17 +535,17 @@ void dda_step(DDA *dda) {
uint8_t recalc_speed;
// debug ramping algorithm
//if (dda->step_no == 0) {
//if (move_state.step_no == 0) {
// sersendf_P(PSTR("\r\nc %lu c_min %lu n %d"), dda->c, dda->c_min, move_state.n);
//}
recalc_speed = 0;
if (dda->step_no < dda->rampup_steps) {
if (move_state.step_no < dda->rampup_steps) {
if (move_state.n < 0) // wrong ramp direction
move_state.n = -((int32_t)2) - move_state.n;
recalc_speed = 1;
}
else if (dda->step_no > dda->rampdown_steps) {
else if (move_state.step_no > dda->rampdown_steps) {
if (move_state.n > 0) // wrong ramp direction
move_state.n = -((int32_t)2) - move_state.n;
recalc_speed = 1;
@ -551,11 +555,11 @@ void dda_step(DDA *dda) {
// be careful of signedness!
move_state.c = (int32_t)move_state.c - ((int32_t)(move_state.c * 2) / (int32_t)move_state.n);
}
dda->step_no++;
move_state.step_no++;
// debug ramping algorithm
// for very low speeds like 10 mm/min, only
//if (dda->step_no % 10 /* 10, 100, ...*/ == 0)
//if (move_state.step_no % 10 /* 10, 100, ...*/ == 0)
// sersendf_P(PSTR("\r\nc %lu c_min %lu n %d"), dda->c, dda->c_min, move_state.n);
#endif

6
dda.h
View File

@ -54,8 +54,8 @@ typedef struct {
// uint32_t e_steps; ///< number of steps on E axis
#ifdef ACCELERATION_RAMPING
// /// counts actual steps done
// uint32_t step_no;
/// counts actual steps done
uint32_t step_no;
/// time until next step
uint32_t c;
/// tracking variable
@ -129,8 +129,6 @@ typedef struct {
uint32_t rampup_steps;
/// number of last step before decelerating
uint32_t rampdown_steps;
/// counts actual steps done
uint32_t step_no;
/// 24.8 fixed point timer value, maximum speed
uint32_t c_min;
#endif