Browse Source

More 2nd extruder implementation. (Not usable)

Advance (not tested)
Erik van der Zalm 13 years ago
parent
commit
6b86f15686
4 changed files with 51 additions and 34 deletions
  1. 2
    2
      Marlin/Configuration.h
  2. 12
    3
      Marlin/planner.cpp
  3. 5
    4
      Marlin/planner.h
  4. 32
    25
      Marlin/stepper.cpp

+ 2
- 2
Marlin/Configuration.h View File

@@ -223,11 +223,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
223 223
 
224 224
 #define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200*8/3,760*1.1}                    // default steps per unit for ultimaker 
225 225
 //#define DEFAULT_AXIS_STEPS_PER_UNIT   {40, 40, 3333.92, 67} //sells mendel with v9 extruder
226
-#define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 200000}    // (mm/sec)    
226
+#define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 45}    // (mm/sec)    
227 227
 #define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
228 228
 
229 229
 #define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves 
230
-#define DEFAULT_RETRACT_ACCELERATION  7000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts
230
+#define DEFAULT_RETRACT_ACCELERATION  3000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts
231 231
 
232 232
 #define DEFAULT_MINIMUMFEEDRATE       0.0     // minimum feedrate
233 233
 #define DEFAULT_MINTRAVELFEEDRATE     0.0

+ 12
- 3
Marlin/planner.cpp View File

@@ -489,12 +489,21 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
489 489
   if (target[Z_AXIS] < position[Z_AXIS]) { block->direction_bits |= (1<<Z_AXIS); }
490 490
   if (target[E_AXIS] < position[E_AXIS]) { block->direction_bits |= (1<<E_AXIS); }
491 491
   
492
+  block->active_extruder = extruder;
493
+  
492 494
   //enable active axes
493 495
   if(block->steps_x != 0) enable_x();
494 496
   if(block->steps_y != 0) enable_y();
495 497
   if(block->steps_z != 0) enable_z();
496
-  if(block->steps_e != 0) enable_e();
497
-
498
+  if(extruder == 0) {
499
+    if(block->steps_e != 0) enable_e();
500
+  }
501
+  #if (EXTRUDERS > 1)
502
+  if(extruder == 1) {
503
+    if(block->steps_e != 0) enable_e1();
504
+  }
505
+  #endif
506
+  
498 507
   float delta_mm[4];
499 508
   delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
500 509
   delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
@@ -713,7 +722,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
713 722
     else {
714 723
       long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
715 724
       float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * 
716
-        (block->speed_e * block->speed_e * EXTRUTION_AREA * EXTRUTION_AREA / 3600.0)*65536;
725
+        (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUTION_AREA * EXTRUTION_AREA / 3600.0)*65536;
717 726
       block->advance = advance;
718 727
       if(acc_dist == 0) {
719 728
         block->advance_rate = 0;

+ 5
- 4
Marlin/planner.h View File

@@ -37,11 +37,12 @@ typedef struct {
37 37
   long decelerate_after;                    // The index of the step event on which to start decelerating
38 38
   long acceleration_rate;                   // The acceleration rate used for acceleration calculation
39 39
   unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
40
+  unsigned char active_extruder;            // Selects the active extruder
40 41
   #ifdef ADVANCE
41
-//    long advance_rate;
42
-//    volatile long initial_advance;
43
-//    volatile long final_advance;
44
-//    float advance;
42
+    long advance_rate;
43
+    volatile long initial_advance;
44
+    volatile long final_advance;
45
+    float advance;
45 46
   #endif
46 47
 
47 48
   // Fields used by the motion planner to manage acceleration

+ 32
- 25
Marlin/stepper.cpp View File

@@ -383,8 +383,9 @@ ISR(TIMER1_COMPA_vect)
383 383
       }
384 384
     #endif //!ADVANCE
385 385
     for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) 
386
-    MSerial.checkRx();
387
-    /*
386
+      MSerial.checkRx(); // Check for serial chars. 
387
+      
388
+      #ifdef ADVANCE
388 389
       counter_e += current_block->steps_e;
389 390
       if (counter_e > 0) {
390 391
         counter_e -= current_block->step_event_count;
@@ -399,15 +400,11 @@ ISR(TIMER1_COMPA_vect)
399 400
           CRITICAL_SECTION_END;
400 401
         }
401 402
       }    
402
-      */
403
-      /*
404 403
       // Do E steps + advance steps
405
-      CRITICAL_SECTION_START;
406 404
       e_steps += ((advance >> 16) - old_advance);
407
-      CRITICAL_SECTION_END;
408 405
       old_advance = advance >> 16;  
409
-      */
410
-        
406
+      #endif //ADVANCE
407
+      
411 408
       counter_x += current_block->steps_x;
412 409
       if (counter_x > 0) {
413 410
         WRITE(X_STEP_PIN, HIGH);
@@ -461,7 +458,9 @@ ISR(TIMER1_COMPA_vect)
461 458
       OCR1A = timer;
462 459
       acceleration_time += timer;
463 460
       #ifdef ADVANCE
464
-        advance += advance_rate;
461
+        for(int8_t i=0; i < step_loops; i++) {
462
+          advance += advance_rate;
463
+        }
465 464
       #endif
466 465
     } 
467 466
     else if (step_events_completed > current_block->decelerate_after) {   
@@ -483,7 +482,9 @@ ISR(TIMER1_COMPA_vect)
483 482
       OCR1A = timer;
484 483
       deceleration_time += timer;
485 484
       #ifdef ADVANCE
486
-        advance -= advance_rate;
485
+        for(int8_t i=0; i < step_loops; i++) {
486
+          advance -= advance_rate;
487
+        }
487 488
         if(advance < final_advance)
488 489
           advance = final_advance;
489 490
       #endif //ADVANCE
@@ -491,7 +492,7 @@ ISR(TIMER1_COMPA_vect)
491 492
     else {
492 493
       OCR1A = OCR1A_nominal;
493 494
     }
494
-    
495
+
495 496
     // If current block is finished, reset pointer 
496 497
     if (step_events_completed >= current_block->step_event_count) {
497 498
       current_block = NULL;
@@ -506,22 +507,24 @@ ISR(TIMER1_COMPA_vect)
506 507
   // Timer 0 is shared with millies
507 508
   ISR(TIMER0_COMPA_vect)
508 509
   {
509
-    // Critical section needed because Timer 1 interrupt has higher priority. 
510
-    // The pin set functions are placed on trategic position to comply with the stepper driver timing.
511
-    WRITE(E_STEP_PIN, LOW);
510
+    old_OCR0A += 25; // ~10kHz interrupt
511
+    OCR0A = old_OCR0A;
512 512
     // Set E direction (Depends on E direction + advance)
513
-    if (e_steps < 0) {
514
-      WRITE(E_DIR_PIN,INVERT_E_DIR);    
515
-      e_steps++;
516
-      WRITE(E_STEP_PIN, HIGH);
517
-    } 
518
-    if (e_steps > 0) {
519
-      WRITE(E_DIR_PIN,!INVERT_E_DIR);
520
-      e_steps--;
521
-      WRITE(E_STEP_PIN, HIGH);
513
+    for(unsigned char i=0; i<4;) {
514
+      WRITE(E_STEP_PIN, LOW);
515
+      if (e_steps == 0) break;
516
+      i++;
517
+      if (e_steps < 0) {
518
+        WRITE(E_DIR_PIN,INVERT_E_DIR);    
519
+        e_steps++;
520
+        WRITE(E_STEP_PIN, HIGH);
521
+      } 
522
+      if (e_steps > 0) {
523
+        WRITE(E_DIR_PIN,!INVERT_E_DIR);
524
+        e_steps--;
525
+        WRITE(E_STEP_PIN, HIGH);
526
+      }
522 527
     }
523
-    old_OCR0A += 25; // 10kHz interrupt
524
-    OCR0A = old_OCR0A;
525 528
   }
526 529
 #endif // ADVANCE
527 530
 
@@ -638,6 +641,10 @@ void st_init()
638 641
   ENABLE_STEPPER_DRIVER_INTERRUPT();  
639 642
 
640 643
   #ifdef ADVANCE
644
+  #if defined(TCCR0A) && defined(WGM01)
645
+    TCCR0A &= ~(1<<WGM01);
646
+    TCCR0A &= ~(1<<WGM00);
647
+  #endif  
641 648
     e_steps = 0;
642 649
     TIMSK0 |= (1<<OCIE0A);
643 650
   #endif //ADVANCE

Loading…
Cancel
Save