From bde8ab776dc73e39ca05cec8858f4b7e8a1c5c49 Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Sun, 24 Jan 2010 10:26:10 +1100 Subject: [PATCH] fixed a few bugs, such as two consecutive moves to a point and back to the start wouldnt be run at all --- mendel/dda.c | 22 +++++++++++----------- mendel/mendel.c | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mendel/dda.c b/mendel/dda.c index 3e4a4f8..72a7221 100644 --- a/mendel/dda.c +++ b/mendel/dda.c @@ -151,7 +151,7 @@ void dda_create(TARGET *target, DDA *dda) { uint32_t distance; // we end at the passed target - memcpy(&dda->endpoint, target, sizeof(TARGET)); + memcpy(&(dda->endpoint), target, sizeof(TARGET)); dda->x_delta = abs32(dda->endpoint.X - startpoint.X); dda->y_delta = abs32(dda->endpoint.Y - startpoint.Y); @@ -202,14 +202,14 @@ void dda_create(TARGET *target, DDA *dda) { dda->f_scale = 1; } - dda->x_direction = (dda->endpoint.X > startpoint.X)?1:0; - dda->y_direction = (dda->endpoint.Y > startpoint.Y)?1:0; - dda->z_direction = (dda->endpoint.Z > startpoint.Z)?1:0; - dda->e_direction = (dda->endpoint.E > startpoint.E)?1:0; - dda->f_direction = (dda->endpoint.F > startpoint.F)?1:0; + dda->x_direction = (dda->endpoint.X >= startpoint.X)?1:0; + dda->y_direction = (dda->endpoint.Y >= startpoint.Y)?1:0; + dda->z_direction = (dda->endpoint.Z >= startpoint.Z)?1:0; + dda->e_direction = (dda->endpoint.E >= startpoint.E)?1:0; + dda->f_direction = (dda->endpoint.F >= startpoint.F)?1:0; - dda->x_counter = dda->y_counter = dda->z_counter = dda->e_counter = dda->f_counter - = -(dda->total_steps >> 1); + dda->x_counter = dda->y_counter = dda->z_counter = dda->e_counter = dda->f_counter = + -(dda->total_steps >> 1); // pre-calculate move speed in millimeter microseconds per step minute for less math in interrupt context // mm (distance) * 60000000 us/min / step (total_steps) = mm.us per step.min @@ -218,10 +218,10 @@ void dda_create(TARGET *target, DDA *dda) { dda->move_duration = distance * 60000000 / dda->total_steps; // next dda starts where we finish - memcpy(&startpoint, &dda->endpoint, sizeof(TARGET)); + memcpy(&startpoint, target, sizeof(TARGET)); - // make sure we're not running - dda->live = 0; + // make sure we can run + dda->live = 1; // fire up enableTimerInterrupt(); diff --git a/mendel/mendel.c b/mendel/mendel.c index 5945e25..f7e339f 100644 --- a/mendel/mendel.c +++ b/mendel/mendel.c @@ -107,15 +107,15 @@ int main (void) // target position serial_writestr_P(PSTR("Tar: ")); - serwrite_int32(movebuffer[mb_head].endpoint.X); + serwrite_int32(movebuffer[mb_tail].endpoint.X); serial_writechar(','); - serwrite_int32(movebuffer[mb_head].endpoint.Y); + serwrite_int32(movebuffer[mb_tail].endpoint.Y); serial_writechar(','); - serwrite_int32(movebuffer[mb_head].endpoint.Z); + serwrite_int32(movebuffer[mb_tail].endpoint.Z); serial_writechar(','); - serwrite_uint32(movebuffer[mb_head].endpoint.E); + serwrite_uint32(movebuffer[mb_tail].endpoint.E); serial_writechar(','); - serwrite_uint32(movebuffer[mb_head].endpoint.F); + serwrite_uint32(movebuffer[mb_tail].endpoint.F); serial_writechar('\n'); // Queue