Browse Source

Corrected distance calculation. (thanks jv4779)

Erik van der Zalm 12 years ago
parent
commit
6ef8459494
1 changed files with 5 additions and 6 deletions
  1. 5
    6
      Marlin/planner.cpp

+ 5
- 6
Marlin/planner.cpp View File

517
   delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
517
   delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
518
   delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
518
   delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
519
   delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS];
519
   delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS];
520
-  block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) +
521
-                            square(delta_mm[Z_AXIS]) + square(delta_mm[E_AXIS]));
520
+  if ( block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0 ) {
521
+    block->millimeters = delta_mm[E_AXIS];
522
+  } else {
523
+    block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
524
+  }
522
   float inverse_millimeters = 1.0/block->millimeters;  // Inverse millimeters to remove multiple divides 
525
   float inverse_millimeters = 1.0/block->millimeters;  // Inverse millimeters to remove multiple divides 
523
   
526
   
524
   // Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
527
   // Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
527
   block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
530
   block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
528
   block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
531
   block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
529
 
532
 
530
-  
531
- 
532
-
533
   if (block->steps_e == 0) {
533
   if (block->steps_e == 0) {
534
         if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
534
         if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
535
   }
535
   }
537
     	if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
537
     	if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
538
   } 
538
   } 
539
 
539
 
540
-
541
   // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
540
   // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
542
   int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
541
   int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
543
 #ifdef SLOWDOWN
542
 #ifdef SLOWDOWN

Loading…
Cancel
Save