Преглед изворни кода

[Bugfix-1.1.x] initial step correction (#8735)

* tested

* forgot one item
Bob-the-Kuhn пре 7 година
родитељ
комит
ec028bf747
2 измењених фајлова са 11 додато и 5 уклоњено
  1. 11
    2
      Marlin/stepper.cpp
  2. 0
    3
      Marlin/stepper.h

+ 11
- 2
Marlin/stepper.cpp Прегледај датотеку

@@ -447,10 +447,13 @@ void Stepper::isr() {
447 447
   }
448 448
 
449 449
   // If there is no current block, attempt to pop one from the buffer
450
+  bool first_step = false;
450 451
   if (!current_block) {
451 452
     // Anything in the buffer?
452 453
     if ((current_block = planner.get_current_block())) {
453 454
       trapezoid_generator_reset();
455
+      TCNT1 = 0;  // make sure first pulse is not truncated
456
+      first_step = true;
454 457
 
455 458
       // Initialize Bresenham counters to 1/2 the ceiling
456 459
       counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1);
@@ -705,8 +708,14 @@ void Stepper::isr() {
705 708
   // Calculate new timer value
706 709
   if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
707 710
 
708
-    MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
709
-    acc_step_rate += current_block->initial_rate;
711
+    if (first_step) {
712
+      acc_step_rate = current_block->initial_rate;
713
+      acceleration_time = 0;
714
+    }
715
+    else {
716
+      MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
717
+      acc_step_rate += current_block->initial_rate;
718
+    }
710 719
 
711 720
     // upper limit
712 721
     NOMORE(acc_step_rate, current_block->nominal_rate);

+ 0
- 3
Marlin/stepper.h Прегледај датотеку

@@ -359,9 +359,6 @@ class Stepper {
359 359
       OCR1A_nominal = calc_timer_interval(current_block->nominal_rate);
360 360
       // make a note of the number of step loops required at nominal speed
361 361
       step_loops_nominal = step_loops;
362
-      acc_step_rate = current_block->initial_rate;
363
-      acceleration_time = calc_timer_interval(acc_step_rate);
364
-      _NEXT_ISR(acceleration_time);
365 362
 
366 363
       #if ENABLED(LIN_ADVANCE)
367 364
         if (current_block->use_advance_lead) {

Loading…
Откажи
Сачувај