Make acceleration, RepRap-style, disable-able. This is also

in preparation for introducing acceleration ramping.
This commit is contained in:
Markus Hitter 2010-09-08 22:33:20 +02:00
parent 8b5e21be51
commit 639f5237be
4 changed files with 19 additions and 0 deletions

6
dda.c
View File

@ -209,6 +209,7 @@ void dda_create(DDA *dda, TARGET *target) {
// distance * 2400 .. * F_CPU / 40000 so we can move a distance of up to 1800mm without overflowing
uint32_t move_duration = ((distance * 2400) / dda->total_steps) * (F_CPU / 40000);
#ifdef ACCELERATION_REPRAP
// c is initial step time in IOclk ticks
dda->c = (move_duration / startpoint.F) << 8;
@ -269,6 +270,9 @@ void dda_create(DDA *dda, TARGET *target) {
}
else
dda->accel = 0;
#else
dda->c = (move_duration / target->F) << 8;
#endif
}
if (debug_flags & DEBUG_DDA)
@ -389,6 +393,7 @@ void dda_step(DDA *dda) {
sei();
#endif
#ifdef ACCELERATION_REPRAP
// linear acceleration magic, courtesy of http://www.embedded.com/columns/technicalinsights/56800129?printable=true
if (dda->accel) {
if (
@ -405,6 +410,7 @@ void dda_step(DDA *dda) {
}
// else we are already at target speed
}
#endif
if (did_step) {
// we stepped, reset timeout

4
dda.h
View File

@ -29,7 +29,9 @@ typedef struct {
// status fields
uint8_t nullmove :1;
uint8_t live :1;
#ifdef ACCELERATION_REPRAP
uint8_t accel :1;
#endif
// wait for temperature to stabilise flag
uint8_t waitfor_temp :1;
@ -60,8 +62,10 @@ typedef struct {
// linear acceleration variables: c and end_c are 24.8 fixed point timer values, n is the tracking variable
uint32_t c;
#ifdef ACCELERATION_REPRAP
uint32_t end_c;
int32_t n;
#endif
} DDA;
/*

View File

@ -693,7 +693,11 @@ void process_gcode_command(GCODE_COMMAND *gcmd) {
serial_writestr_P(PSTR(",F:"));
serwrite_int32(movebuffer[mb_tail].endpoint.F);
serial_writestr_P(PSTR(",c:"));
#ifdef ACCELERATION_REPRAP
serwrite_uint32(movebuffer[mb_tail].end_c);
#else
serwrite_uint32(movebuffer[mb_tail].c);
#endif
serial_writestr_P(PSTR("}\n"));
print_queue();

View File

@ -36,6 +36,11 @@
#define TEMP_HYSTERESIS 20
#define TEMP_RESIDENCY_TIME 60
// acceleration, reprap style. Each movement starts at the speed of
// the previous command and accelerates or decelerates linearly
// to reach target speed at the end of the movement.
#define ACCELERATION_REPRAP
// --------------------------------------------------------------------------
// you shouldn't need to edit something below this line