Move dda->step_no into move_state as well.
This commit is contained in:
parent
bebb619054
commit
ed77abba31
16
dda.c
16
dda.c
|
|
@ -350,7 +350,6 @@ void dda_create(DDA *dda, TARGET *target) {
|
||||||
else
|
else
|
||||||
dda->accel = 0;
|
dda->accel = 0;
|
||||||
#elif defined ACCELERATION_RAMPING
|
#elif defined ACCELERATION_RAMPING
|
||||||
dda->step_no = 0;
|
|
||||||
// remove this when people have swallowed the new config item
|
// remove this when people have swallowed the new config item
|
||||||
#ifdef ACCELERATION_STEEPNESS
|
#ifdef ACCELERATION_STEEPNESS
|
||||||
#error ACCELERATION_STEEPNESS is gone, review your config.h and use ACCELERATION
|
#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);
|
heater_set(DC_EXTRUDER, DC_EXTRUDER_PWM);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// initialise state variable
|
||||||
|
#ifdef ACCELERATION_RAMPING
|
||||||
|
move_state.step_no = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
// ensure this dda starts
|
// ensure this dda starts
|
||||||
dda->live = 1;
|
dda->live = 1;
|
||||||
|
|
||||||
|
|
@ -531,17 +535,17 @@ void dda_step(DDA *dda) {
|
||||||
uint8_t recalc_speed;
|
uint8_t recalc_speed;
|
||||||
|
|
||||||
// debug ramping algorithm
|
// 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);
|
// 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;
|
||||||
if (dda->step_no < dda->rampup_steps) {
|
if (move_state.step_no < dda->rampup_steps) {
|
||||||
if (move_state.n < 0) // wrong ramp direction
|
if (move_state.n < 0) // wrong ramp direction
|
||||||
move_state.n = -((int32_t)2) - move_state.n;
|
move_state.n = -((int32_t)2) - move_state.n;
|
||||||
recalc_speed = 1;
|
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
|
if (move_state.n > 0) // wrong ramp direction
|
||||||
move_state.n = -((int32_t)2) - move_state.n;
|
move_state.n = -((int32_t)2) - move_state.n;
|
||||||
recalc_speed = 1;
|
recalc_speed = 1;
|
||||||
|
|
@ -551,11 +555,11 @@ void dda_step(DDA *dda) {
|
||||||
// be careful of signedness!
|
// be careful of signedness!
|
||||||
move_state.c = (int32_t)move_state.c - ((int32_t)(move_state.c * 2) / (int32_t)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++;
|
move_state.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 (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);
|
// sersendf_P(PSTR("\r\nc %lu c_min %lu n %d"), dda->c, dda->c_min, move_state.n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
6
dda.h
6
dda.h
|
|
@ -54,8 +54,8 @@ typedef struct {
|
||||||
// uint32_t e_steps; ///< number of steps on E axis
|
// uint32_t e_steps; ///< number of steps on E axis
|
||||||
|
|
||||||
#ifdef ACCELERATION_RAMPING
|
#ifdef ACCELERATION_RAMPING
|
||||||
// /// counts actual steps done
|
/// counts actual steps done
|
||||||
// uint32_t step_no;
|
uint32_t step_no;
|
||||||
/// time until next step
|
/// time until next step
|
||||||
uint32_t c;
|
uint32_t c;
|
||||||
/// tracking variable
|
/// tracking variable
|
||||||
|
|
@ -129,8 +129,6 @@ typedef struct {
|
||||||
uint32_t rampup_steps;
|
uint32_t rampup_steps;
|
||||||
/// number of last step before decelerating
|
/// number of last step before decelerating
|
||||||
uint32_t rampdown_steps;
|
uint32_t rampdown_steps;
|
||||||
/// counts actual steps done
|
|
||||||
uint32_t step_no;
|
|
||||||
/// 24.8 fixed point timer value, maximum speed
|
/// 24.8 fixed point timer value, maximum speed
|
||||||
uint32_t c_min;
|
uint32_t c_min;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue