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
 
223
 
224
 #define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200*8/3,760*1.1}                    // default steps per unit for ultimaker 
224
 #define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200*8/3,760*1.1}                    // default steps per unit for ultimaker 
225
 //#define DEFAULT_AXIS_STEPS_PER_UNIT   {40, 40, 3333.92, 67} //sells mendel with v9 extruder
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
 #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.
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
 #define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves 
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
 #define DEFAULT_MINIMUMFEEDRATE       0.0     // minimum feedrate
232
 #define DEFAULT_MINIMUMFEEDRATE       0.0     // minimum feedrate
233
 #define DEFAULT_MINTRAVELFEEDRATE     0.0
233
 #define DEFAULT_MINTRAVELFEEDRATE     0.0

+ 12
- 3
Marlin/planner.cpp View File

489
   if (target[Z_AXIS] < position[Z_AXIS]) { block->direction_bits |= (1<<Z_AXIS); }
489
   if (target[Z_AXIS] < position[Z_AXIS]) { block->direction_bits |= (1<<Z_AXIS); }
490
   if (target[E_AXIS] < position[E_AXIS]) { block->direction_bits |= (1<<E_AXIS); }
490
   if (target[E_AXIS] < position[E_AXIS]) { block->direction_bits |= (1<<E_AXIS); }
491
   
491
   
492
+  block->active_extruder = extruder;
493
+  
492
   //enable active axes
494
   //enable active axes
493
   if(block->steps_x != 0) enable_x();
495
   if(block->steps_x != 0) enable_x();
494
   if(block->steps_y != 0) enable_y();
496
   if(block->steps_y != 0) enable_y();
495
   if(block->steps_z != 0) enable_z();
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
   float delta_mm[4];
507
   float delta_mm[4];
499
   delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
508
   delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
500
   delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
509
   delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
713
     else {
722
     else {
714
       long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
723
       long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
715
       float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * 
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
       block->advance = advance;
726
       block->advance = advance;
718
       if(acc_dist == 0) {
727
       if(acc_dist == 0) {
719
         block->advance_rate = 0;
728
         block->advance_rate = 0;

+ 5
- 4
Marlin/planner.h View File

37
   long decelerate_after;                    // The index of the step event on which to start decelerating
37
   long decelerate_after;                    // The index of the step event on which to start decelerating
38
   long acceleration_rate;                   // The acceleration rate used for acceleration calculation
38
   long acceleration_rate;                   // The acceleration rate used for acceleration calculation
39
   unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
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
   #ifdef ADVANCE
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
   #endif
46
   #endif
46
 
47
 
47
   // Fields used by the motion planner to manage acceleration
48
   // Fields used by the motion planner to manage acceleration

+ 32
- 25
Marlin/stepper.cpp View File

383
       }
383
       }
384
     #endif //!ADVANCE
384
     #endif //!ADVANCE
385
     for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) 
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
       counter_e += current_block->steps_e;
389
       counter_e += current_block->steps_e;
389
       if (counter_e > 0) {
390
       if (counter_e > 0) {
390
         counter_e -= current_block->step_event_count;
391
         counter_e -= current_block->step_event_count;
399
           CRITICAL_SECTION_END;
400
           CRITICAL_SECTION_END;
400
         }
401
         }
401
       }    
402
       }    
402
-      */
403
-      /*
404
       // Do E steps + advance steps
403
       // Do E steps + advance steps
405
-      CRITICAL_SECTION_START;
406
       e_steps += ((advance >> 16) - old_advance);
404
       e_steps += ((advance >> 16) - old_advance);
407
-      CRITICAL_SECTION_END;
408
       old_advance = advance >> 16;  
405
       old_advance = advance >> 16;  
409
-      */
410
-        
406
+      #endif //ADVANCE
407
+      
411
       counter_x += current_block->steps_x;
408
       counter_x += current_block->steps_x;
412
       if (counter_x > 0) {
409
       if (counter_x > 0) {
413
         WRITE(X_STEP_PIN, HIGH);
410
         WRITE(X_STEP_PIN, HIGH);
461
       OCR1A = timer;
458
       OCR1A = timer;
462
       acceleration_time += timer;
459
       acceleration_time += timer;
463
       #ifdef ADVANCE
460
       #ifdef ADVANCE
464
-        advance += advance_rate;
461
+        for(int8_t i=0; i < step_loops; i++) {
462
+          advance += advance_rate;
463
+        }
465
       #endif
464
       #endif
466
     } 
465
     } 
467
     else if (step_events_completed > current_block->decelerate_after) {   
466
     else if (step_events_completed > current_block->decelerate_after) {   
483
       OCR1A = timer;
482
       OCR1A = timer;
484
       deceleration_time += timer;
483
       deceleration_time += timer;
485
       #ifdef ADVANCE
484
       #ifdef ADVANCE
486
-        advance -= advance_rate;
485
+        for(int8_t i=0; i < step_loops; i++) {
486
+          advance -= advance_rate;
487
+        }
487
         if(advance < final_advance)
488
         if(advance < final_advance)
488
           advance = final_advance;
489
           advance = final_advance;
489
       #endif //ADVANCE
490
       #endif //ADVANCE
491
     else {
492
     else {
492
       OCR1A = OCR1A_nominal;
493
       OCR1A = OCR1A_nominal;
493
     }
494
     }
494
-    
495
+
495
     // If current block is finished, reset pointer 
496
     // If current block is finished, reset pointer 
496
     if (step_events_completed >= current_block->step_event_count) {
497
     if (step_events_completed >= current_block->step_event_count) {
497
       current_block = NULL;
498
       current_block = NULL;
506
   // Timer 0 is shared with millies
507
   // Timer 0 is shared with millies
507
   ISR(TIMER0_COMPA_vect)
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
     // Set E direction (Depends on E direction + advance)
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
 #endif // ADVANCE
529
 #endif // ADVANCE
527
 
530
 
638
   ENABLE_STEPPER_DRIVER_INTERRUPT();  
641
   ENABLE_STEPPER_DRIVER_INTERRUPT();  
639
 
642
 
640
   #ifdef ADVANCE
643
   #ifdef ADVANCE
644
+  #if defined(TCCR0A) && defined(WGM01)
645
+    TCCR0A &= ~(1<<WGM01);
646
+    TCCR0A &= ~(1<<WGM00);
647
+  #endif  
641
     e_steps = 0;
648
     e_steps = 0;
642
     TIMSK0 |= (1<<OCIE0A);
649
     TIMSK0 |= (1<<OCIE0A);
643
   #endif //ADVANCE
650
   #endif //ADVANCE

Loading…
Cancel
Save