浏览代码

[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
   }
447
   }
448
 
448
 
449
   // If there is no current block, attempt to pop one from the buffer
449
   // If there is no current block, attempt to pop one from the buffer
450
+  bool first_step = false;
450
   if (!current_block) {
451
   if (!current_block) {
451
     // Anything in the buffer?
452
     // Anything in the buffer?
452
     if ((current_block = planner.get_current_block())) {
453
     if ((current_block = planner.get_current_block())) {
453
       trapezoid_generator_reset();
454
       trapezoid_generator_reset();
455
+      TCNT1 = 0;  // make sure first pulse is not truncated
456
+      first_step = true;
454
 
457
 
455
       // Initialize Bresenham counters to 1/2 the ceiling
458
       // Initialize Bresenham counters to 1/2 the ceiling
456
       counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1);
459
       counter_X = counter_Y = counter_Z = counter_E = -(current_block->step_event_count >> 1);
705
   // Calculate new timer value
708
   // Calculate new timer value
706
   if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
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
     // upper limit
720
     // upper limit
712
     NOMORE(acc_step_rate, current_block->nominal_rate);
721
     NOMORE(acc_step_rate, current_block->nominal_rate);

+ 0
- 3
Marlin/stepper.h 查看文件

359
       OCR1A_nominal = calc_timer_interval(current_block->nominal_rate);
359
       OCR1A_nominal = calc_timer_interval(current_block->nominal_rate);
360
       // make a note of the number of step loops required at nominal speed
360
       // make a note of the number of step loops required at nominal speed
361
       step_loops_nominal = step_loops;
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
       #if ENABLED(LIN_ADVANCE)
363
       #if ENABLED(LIN_ADVANCE)
367
         if (current_block->use_advance_lead) {
364
         if (current_block->use_advance_lead) {

正在加载...
取消
保存