瀏覽代碼

Some advance modifications

Erik van der Zalm 12 年之前
父節點
當前提交
af22e9cd38
共有 3 個文件被更改,包括 41 次插入18 次删除
  1. 2
    2
      Marlin/Configuration.h
  2. 9
    3
      Marlin/planner.cpp
  3. 30
    13
      Marlin/stepper.cpp

+ 2
- 2
Marlin/Configuration.h 查看文件

@@ -278,8 +278,8 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
278 278
 #ifdef ADVANCE
279 279
   #define EXTRUDER_ADVANCE_K .3
280 280
 
281
-  #define D_FILAMENT 1.7
282
-  #define STEPS_MM_E 65
281
+  #define D_FILAMENT 2.85
282
+  #define STEPS_MM_E 836
283 283
   #define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
284 284
   #define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
285 285
 

+ 9
- 3
Marlin/planner.cpp 查看文件

@@ -198,7 +198,6 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
198 198
   
199 199
  // block->accelerate_until = accelerate_steps;
200 200
  // block->decelerate_after = accelerate_steps+plateau_steps;
201
-  
202 201
   CRITICAL_SECTION_START;  // Fill variables used by the stepper in a critical section
203 202
   if(block->busy == false) { // Don't update variables if block is busy.
204 203
     block->accelerate_until = accelerate_steps;
@@ -482,7 +481,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
482 481
   // Bail if this is a zero-length block
483 482
   if (block->step_event_count <=dropsegments) { return; };
484 483
 
485
-  // Compute direction bits for this block
484
+  // Compute direction bits for this block 
486 485
   block->direction_bits = 0;
487 486
   if (target[X_AXIS] < position[X_AXIS]) { block->direction_bits |= (1<<X_AXIS); }
488 487
   if (target[Y_AXIS] < position[Y_AXIS]) { block->direction_bits |= (1<<Y_AXIS); }
@@ -722,7 +721,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
722 721
     else {
723 722
       long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
724 723
       float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * 
725
-        (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUTION_AREA * EXTRUTION_AREA / 3600.0)*65536;
724
+        (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUTION_AREA * EXTRUTION_AREA)*256;
726 725
       block->advance = advance;
727 726
       if(acc_dist == 0) {
728 727
         block->advance_rate = 0;
@@ -731,6 +730,13 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
731 730
         block->advance_rate = advance / (float)acc_dist;
732 731
       }
733 732
     }
733
+    /*
734
+    SERIAL_ECHO_START;
735
+    SERIAL_ECHOPGM("advance :");
736
+    SERIAL_ECHO(block->advance/256.0);
737
+    SERIAL_ECHOPGM("advance rate :");
738
+    SERIAL_ECHOLN(block->advance_rate/256.0);
739
+    */
734 740
   #endif // ADVANCE
735 741
 
736 742
 

+ 30
- 13
Marlin/stepper.cpp 查看文件

@@ -55,9 +55,9 @@ static long counter_x,       // Counter variables for the bresenham line tracer
55 55
 volatile static unsigned long step_events_completed; // The number of step events executed in the current block
56 56
 #ifdef ADVANCE
57 57
   static long advance_rate, advance, final_advance = 0;
58
-  static short old_advance = 0;
58
+  static long old_advance = 0;
59 59
 #endif
60
-static short e_steps;
60
+static long e_steps;
61 61
 static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
62 62
 static long acceleration_time, deceleration_time;
63 63
 //static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
@@ -253,6 +253,9 @@ FORCE_INLINE void trapezoid_generator_reset() {
253 253
   #ifdef ADVANCE
254 254
     advance = current_block->initial_advance;
255 255
     final_advance = current_block->final_advance;
256
+    // Do E steps + advance steps
257
+    e_steps += ((advance >>8) - old_advance);
258
+    old_advance = advance >>8;  
256 259
   #endif
257 260
   deceleration_time = 0;
258 261
   // step_rate to timer interval
@@ -260,6 +263,17 @@ FORCE_INLINE void trapezoid_generator_reset() {
260 263
   acceleration_time = calc_timer(acc_step_rate);
261 264
   OCR1A = acceleration_time;
262 265
   OCR1A_nominal = calc_timer(current_block->nominal_rate);
266
+  
267
+//    SERIAL_ECHO_START;
268
+//    SERIAL_ECHOPGM("advance :");
269
+//    SERIAL_ECHO(current_block->advance/256.0);
270
+//    SERIAL_ECHOPGM("advance rate :");
271
+//    SERIAL_ECHO(current_block->advance_rate/256.0);
272
+//    SERIAL_ECHOPGM("initial advance :");
273
+//  SERIAL_ECHO(current_block->initial_advance/256.0);
274
+//    SERIAL_ECHOPGM("final advance :");
275
+//    SERIAL_ECHOLN(current_block->final_advance/256.0);
276
+    
263 277
 }
264 278
 
265 279
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.  
@@ -382,6 +396,9 @@ ISR(TIMER1_COMPA_vect)
382 396
         count_direction[E_AXIS]=-1;
383 397
       }
384 398
     #endif //!ADVANCE
399
+    
400
+
401
+    
385 402
     for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) 
386 403
       MSerial.checkRx(); // Check for serial chars. 
387 404
       
@@ -390,19 +407,12 @@ ISR(TIMER1_COMPA_vect)
390 407
       if (counter_e > 0) {
391 408
         counter_e -= current_block->step_event_count;
392 409
         if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
393
-          CRITICAL_SECTION_START;
394 410
           e_steps--;
395
-          CRITICAL_SECTION_END;
396 411
         }
397 412
         else {
398
-          CRITICAL_SECTION_START;
399 413
           e_steps++;
400
-          CRITICAL_SECTION_END;
401 414
         }
402 415
       }    
403
-      // Do E steps + advance steps
404
-      e_steps += ((advance >> 16) - old_advance);
405
-      old_advance = advance >> 16;  
406 416
       #endif //ADVANCE
407 417
       
408 418
       counter_x += current_block->steps_x;
@@ -461,6 +471,11 @@ ISR(TIMER1_COMPA_vect)
461 471
         for(int8_t i=0; i < step_loops; i++) {
462 472
           advance += advance_rate;
463 473
         }
474
+        //if(advance > current_block->advance) advance = current_block->advance;
475
+        // Do E steps + advance steps
476
+        e_steps += ((advance >>8) - old_advance);
477
+        old_advance = advance >>8;  
478
+        
464 479
       #endif
465 480
     } 
466 481
     else if (step_events_completed > current_block->decelerate_after) {   
@@ -485,8 +500,10 @@ ISR(TIMER1_COMPA_vect)
485 500
         for(int8_t i=0; i < step_loops; i++) {
486 501
           advance -= advance_rate;
487 502
         }
488
-        if(advance < final_advance)
489
-          advance = final_advance;
503
+        if(advance < final_advance) advance = final_advance;
504
+        // Do E steps + advance steps
505
+        e_steps += ((advance >>8) - old_advance);
506
+        old_advance = advance >>8;  
490 507
       #endif //ADVANCE
491 508
     }
492 509
     else {
@@ -507,7 +524,7 @@ ISR(TIMER1_COMPA_vect)
507 524
   // Timer 0 is shared with millies
508 525
   ISR(TIMER0_COMPA_vect)
509 526
   {
510
-    old_OCR0A += 25; // ~10kHz interrupt
527
+    old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
511 528
     OCR0A = old_OCR0A;
512 529
     // Set E direction (Depends on E direction + advance)
513 530
     for(unsigned char i=0; i<4;) {
@@ -519,7 +536,7 @@ ISR(TIMER1_COMPA_vect)
519 536
         e_steps++;
520 537
         WRITE(E_STEP_PIN, HIGH);
521 538
       } 
522
-      if (e_steps > 0) {
539
+      else if (e_steps > 0) {
523 540
         WRITE(E_DIR_PIN,!INVERT_E_DIR);
524 541
         e_steps--;
525 542
         WRITE(E_STEP_PIN, HIGH);

Loading…
取消
儲存