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

Loading…
Cancel
Save