Fixed target calculation
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 11 Sep 2016 15:22:11 +0000 (08:22 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 11 Sep 2016 15:22:11 +0000 (08:22 -0700)
src/machine.c
src/plan/arc.c
src/plan/exec.c

index ef71fab459eb67600e9cea9cd7a73b93ca0fb789..b72b60fae2328cb58eeb034e1554ea3529dd7dc9 100644 (file)
@@ -410,7 +410,7 @@ void mach_calc_model_target(float target[], const float values[],
       if (mach.gm.distance_mode == ABSOLUTE_MODE)
         target[axis] =
           mach_get_active_coord_offset(axis) + TO_MILLIMETERS(values[axis]);
-      else target[axis] += TO_MILLIMETERS(values[axis]);
+      else target[axis] = mach.position[axis] + TO_MILLIMETERS(values[axis]);
     }
   }
 
@@ -432,7 +432,7 @@ void mach_calc_model_target(float target[], const float values[],
     if (mach.gm.distance_mode == ABSOLUTE_MODE)
       // sacidu93's fix to Issue #22
       target[axis] = tmp + mach_get_active_coord_offset(axis);
-    else target[axis] += tmp;
+    else target[axis] = mach.position[axis] + tmp;
   }
 }
 
@@ -673,6 +673,7 @@ void mach_resume_origin_offsets() {
 // Free Space Motion (4.3.4)
 static stat_t _feed(float values[], bool flags[]) {
   float target[AXES];
+  copy_vector(target, mach.position);
   mach_calc_model_target(target, values, flags);
 
   // test soft limits
index 8d8666b7d4542ebb14d7d7b637396bf89715df5b..d7eaf39f6ca9f7ea1ee2e8ec8bf3e202505f1973 100644 (file)
@@ -433,8 +433,9 @@ stat_t mach_arc_feed(float values[], bool values_f[],   // arc endpoints
   } else if (full_circle) rotations = 1; // default to 1 for full circles
 
   // Set model target
-  mach_calc_model_target(arc.target, values, values_f);
   const float *position = mach_get_position();
+  copy_vector(arc.target, position);
+  mach_calc_model_target(arc.target, values, values_f);
 
   // in radius mode it's an error for start == end
   if (radius_f && fp_EQ(position[AXIS_X], arc.target[AXIS_X]) &&
index 612eb4d5d10487b805a89194dab7beb7c1ca6fde..e55a708576b68464d96c96422ccc92dc0e8030d6 100644 (file)
@@ -247,7 +247,7 @@ static stat_t _exec_aline_section(float length, float vin, float vout) {
 
     // len / avg. velocity
     float move_time = 2 * length / (vin + vout);
-    ex.segments = ceil(usec(move_time) / NOM_SEGMENT_USEC);
+    ex.segments = ceil(move_time * MICROSECONDS_PER_MINUTE / NOM_SEGMENT_USEC);
     ex.segment_time = move_time / ex.segments;
     ex.segment_count = (uint32_t)ex.segments;