Browse Source

Small nominal speed improvement.

Erik van der Zalm 13 years ago
parent
commit
ac8adabb2b
1 changed files with 8 additions and 7 deletions
  1. 8
    7
      Marlin/stepper.cpp

+ 8
- 7
Marlin/stepper.cpp View File

@@ -78,7 +78,8 @@ static bool old_z_min_endstop=false;
78 78
 static bool old_z_max_endstop=false;
79 79
 
80 80
 static bool bussy_error=false;
81
-unsigned char OCR1A_error=12345;
81
+unsigned short OCR1A_error=12345;
82
+unsigned short OCR1A_nominal;
82 83
 
83 84
 volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
84 85
 volatile char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
@@ -270,6 +271,7 @@ inline void trapezoid_generator_reset() {
270 271
   acc_step_rate = current_block->initial_rate;
271 272
   acceleration_time = calc_timer(acc_step_rate);
272 273
   OCR1A = acceleration_time;
274
+  OCR1A_nominal = calc_timer(current_block->nominal_rate);
273 275
 }
274 276
 
275 277
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.  
@@ -477,11 +479,11 @@ ISR(TIMER1_COMPA_vect)
477 479
 
478 480
       // step_rate to timer interval
479 481
       timer = calc_timer(acc_step_rate);
482
+      OCR1A = timer;
483
+      acceleration_time += timer;
480 484
       #ifdef ADVANCE
481 485
         advance += advance_rate;
482 486
       #endif
483
-      acceleration_time += timer;
484
-      OCR1A = timer;
485 487
     } 
486 488
     else if (step_events_completed > current_block->decelerate_after) {   
487 489
       MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
@@ -499,17 +501,16 @@ ISR(TIMER1_COMPA_vect)
499 501
 
500 502
       // step_rate to timer interval
501 503
       timer = calc_timer(step_rate);
504
+      OCR1A = timer;
505
+      deceleration_time += timer;
502 506
       #ifdef ADVANCE
503 507
         advance -= advance_rate;
504 508
         if(advance < final_advance)
505 509
           advance = final_advance;
506 510
       #endif //ADVANCE
507
-      deceleration_time += timer;
508
-      OCR1A = timer;
509 511
     }
510 512
     else {
511
-      timer = calc_timer(current_block->nominal_rate);
512
-      OCR1A = timer;
513
+      OCR1A = OCR1A_nominal;
513 514
     }
514 515
     
515 516
     // If current block is finished, reset pointer 

Loading…
Cancel
Save