Move dda->c out of DDA into move_state as well.
This also required to get rid of the usage of this variable when waiting for temperature in dda_queue.*. Hope I got this later part right.
This commit is contained in:
parent
51be23177a
commit
2421b788b9
16
dda.c
16
dda.c
|
|
@ -173,6 +173,7 @@ void dda_init(void) {
|
||||||
|
|
||||||
#ifdef ACCELERATION_RAMPING
|
#ifdef ACCELERATION_RAMPING
|
||||||
move_state.n = 1;
|
move_state.n = 1;
|
||||||
|
move_state.c = ((uint32_t)((double)F_CPU / sqrt((double)(STEPS_PER_MM_X * ACCELERATION)))) << 8;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,8 +357,6 @@ void dda_create(DDA *dda, TARGET *target) {
|
||||||
#endif
|
#endif
|
||||||
// c is initial step time in IOclk ticks (currently, IOclk ticks = F_CPU)
|
// c is initial step time in IOclk ticks (currently, IOclk ticks = F_CPU)
|
||||||
// yes, this assumes always the x axis as the critical one regarding acceleration. If we want to implement per-axis acceleration, things get tricky ...
|
// yes, this assumes always the x axis as the critical one regarding acceleration. If we want to implement per-axis acceleration, things get tricky ...
|
||||||
// TODO: as this number ends exactly where it starts, move it out into a state variable
|
|
||||||
dda->c = ((uint32_t)((double)F_CPU / sqrt((double)(STEPS_PER_MM_X * ACCELERATION)))) << 8;
|
|
||||||
dda->c_min = (move_duration / target->F) << 8;
|
dda->c_min = (move_duration / target->F) << 8;
|
||||||
if (dda->c_min < c_limit)
|
if (dda->c_min < c_limit)
|
||||||
dda->c_min = c_limit;
|
dda->c_min = c_limit;
|
||||||
|
|
@ -431,7 +430,14 @@ void dda_start(DDA *dda) {
|
||||||
dda->live = 1;
|
dda->live = 1;
|
||||||
|
|
||||||
// set timeout for first step
|
// set timeout for first step
|
||||||
|
#ifdef ACCELERATION_RAMPING
|
||||||
|
if (dda->c_min > move_state.c) // can be true when look-ahead removed all deceleration steps
|
||||||
|
setTimer(dda->c_min >> 8);
|
||||||
|
else
|
||||||
|
setTimer(move_state.c >> 8);
|
||||||
|
#else
|
||||||
setTimer(dda->c >> 8);
|
setTimer(dda->c >> 8);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -553,7 +559,7 @@ 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!
|
||||||
dda->c = (int32_t)dda->c - ((int32_t)(dda->c * 2) / move_state.n);
|
move_state.c = (int32_t)move_state.c - ((int32_t)(move_state.c * 2) / move_state.n);
|
||||||
}
|
}
|
||||||
dda->step_no++;
|
dda->step_no++;
|
||||||
|
|
||||||
|
|
@ -593,10 +599,10 @@ void dda_step(DDA *dda) {
|
||||||
// we don't hit maximum speed exactly with acceleration calculation, so limit it here
|
// we don't hit maximum speed exactly with acceleration calculation, so limit it here
|
||||||
// the nice thing about _not_ setting dda->c to dda->c_min is, the move stops at the exact same c as it started, so we have to calculate c only once for the time being
|
// the nice thing about _not_ setting dda->c to dda->c_min is, the move stops at the exact same c as it started, so we have to calculate c only once for the time being
|
||||||
// TODO: set timer only if dda->c has changed
|
// TODO: set timer only if dda->c has changed
|
||||||
if (dda->c_min > dda->c)
|
if (dda->c_min > move_state.c)
|
||||||
setTimer(dda->c_min >> 8);
|
setTimer(dda->c_min >> 8);
|
||||||
else
|
else
|
||||||
setTimer(dda->c >> 8);
|
setTimer(move_state.c >> 8);
|
||||||
#else
|
#else
|
||||||
setTimer(dda->c >> 8);
|
setTimer(dda->c >> 8);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
6
dda.h
6
dda.h
|
|
@ -54,10 +54,10 @@ 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
|
||||||
// /// time until next step
|
|
||||||
// uint32_t c;
|
|
||||||
// /// counts actual steps done
|
// /// counts actual steps done
|
||||||
// uint32_t step_no;
|
// uint32_t step_no;
|
||||||
|
/// time until next step
|
||||||
|
uint32_t c;
|
||||||
/// tracking variable
|
/// tracking variable
|
||||||
int32_t n;
|
int32_t n;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -117,7 +117,9 @@ typedef struct {
|
||||||
uint32_t total_steps;
|
uint32_t total_steps;
|
||||||
|
|
||||||
// linear acceleration variables: c and end_c are 24.8 fixed point timer values, n is the tracking variable
|
// linear acceleration variables: c and end_c are 24.8 fixed point timer values, n is the tracking variable
|
||||||
|
#ifndef ACCELERATION_RAMPING
|
||||||
uint32_t c; ///< time until next step
|
uint32_t c; ///< time until next step
|
||||||
|
#endif
|
||||||
#ifdef ACCELERATION_REPRAP
|
#ifdef ACCELERATION_REPRAP
|
||||||
uint32_t end_c; ///< time between 2nd last step and last step
|
uint32_t end_c; ///< time between 2nd last step and last step
|
||||||
int32_t n; ///< precalculated step time offset variable. At every step we calculate \f$c = c - (2 c / n)\f$; \f$n+=4\f$. See http://www.embedded.com/columns/technicalinsights/56800129?printable=true for full description
|
int32_t n; ///< precalculated step time offset variable. At every step we calculate \f$c = c - (2 c / n)\f$; \f$n+=4\f$. See http://www.embedded.com/columns/technicalinsights/56800129?printable=true for full description
|
||||||
|
|
|
||||||
15
dda_queue.c
15
dda_queue.c
|
|
@ -64,7 +64,7 @@ void queue_step() {
|
||||||
DDA* current_movebuffer = &movebuffer[mb_tail];
|
DDA* current_movebuffer = &movebuffer[mb_tail];
|
||||||
if (current_movebuffer->live) {
|
if (current_movebuffer->live) {
|
||||||
if (current_movebuffer->waitfor_temp) {
|
if (current_movebuffer->waitfor_temp) {
|
||||||
setTimer(current_movebuffer->c >> 8);
|
setTimer(HEATER_WAIT_TIMEOUT);
|
||||||
if (temp_achieved()) {
|
if (temp_achieved()) {
|
||||||
current_movebuffer->live = current_movebuffer->waitfor_temp = 0;
|
current_movebuffer->live = current_movebuffer->waitfor_temp = 0;
|
||||||
serial_writestr_P(PSTR("Temp achieved\n"));
|
serial_writestr_P(PSTR("Temp achieved\n"));
|
||||||
|
|
@ -106,13 +106,6 @@ void enqueue(TARGET *t) {
|
||||||
// it's a wait for temp
|
// it's a wait for temp
|
||||||
new_movebuffer->waitfor_temp = 1;
|
new_movebuffer->waitfor_temp = 1;
|
||||||
new_movebuffer->nullmove = 0;
|
new_movebuffer->nullmove = 0;
|
||||||
#if (F_CPU & 0xFF000000) == 0
|
|
||||||
// set "step" timeout to 1 second
|
|
||||||
new_movebuffer->c = F_CPU << 8;
|
|
||||||
#else
|
|
||||||
// set "step" timeout to maximum
|
|
||||||
new_movebuffer->c = 0xFFFFFF00;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make certain all writes to global memory
|
// make certain all writes to global memory
|
||||||
|
|
@ -163,13 +156,13 @@ void next_move() {
|
||||||
// tail must be set before setTimer call as setTimer
|
// tail must be set before setTimer call as setTimer
|
||||||
// reenables the timer interrupt, potentially exposing
|
// reenables the timer interrupt, potentially exposing
|
||||||
// mb_tail to the timer interrupt routine.
|
// mb_tail to the timer interrupt routine.
|
||||||
mb_tail = t;
|
mb_tail = t;
|
||||||
if (current_movebuffer->waitfor_temp) {
|
if (current_movebuffer->waitfor_temp) {
|
||||||
#ifndef REPRAP_HOST_COMPATIBILITY
|
#ifndef REPRAP_HOST_COMPATIBILITY
|
||||||
serial_writestr_P(PSTR("Waiting for target temp\n"));
|
serial_writestr_P(PSTR("Waiting for target temp\n"));
|
||||||
#endif
|
#endif
|
||||||
current_movebuffer->live = 1;
|
current_movebuffer->live = 1;
|
||||||
setTimer(current_movebuffer->c >> 8);
|
setTimer(HEATER_WAIT_TIMEOUT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dda_start(current_movebuffer);
|
dda_start(current_movebuffer);
|
||||||
|
|
@ -177,7 +170,7 @@ void next_move() {
|
||||||
}
|
}
|
||||||
if (queue_empty())
|
if (queue_empty())
|
||||||
setTimer(0);
|
setTimer(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DEBUG - print queue.
|
/// DEBUG - print queue.
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,14 @@
|
||||||
|
|
||||||
#include "dda.h"
|
#include "dda.h"
|
||||||
|
|
||||||
|
#if (F_CPU & 0xFF000000) == 0
|
||||||
|
// set timeout to 1 second
|
||||||
|
#define HEATER_WAIT_TIMEOUT (F_CPU << 8)
|
||||||
|
#else
|
||||||
|
// set timeout to maximum
|
||||||
|
#define HEATER_WAIT_TIMEOUT 0xFFFFFF00
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
variables
|
variables
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue