Przeglądaj źródła

First parts 2nd extruder

Erik van der Zalm 12 lat temu
rodzic
commit
aad4b75b94
5 zmienionych plików z 106 dodań i 45 usunięć
  1. 1
    0
      Marlin/Configuration.h
  2. 81
    45
      Marlin/Marlin.pde
  3. 2
    0
      Marlin/planner.cpp
  4. 1
    0
      Marlin/planner.h
  5. 21
    0
      Marlin/temperature.h

+ 1
- 0
Marlin/Configuration.h Wyświetl plik

@@ -8,6 +8,7 @@
8 8
 //#define BAUDRATE 115200
9 9
 //#define BAUDRATE 230400
10 10
 
11
+#define EXTRUDERS 1
11 12
 
12 13
 // Frequency limit
13 14
 // See nophead's blog for more info

+ 81
- 45
Marlin/Marlin.pde Wyświetl plik

@@ -174,7 +174,7 @@ static unsigned long stepper_inactive_time = 0;
174 174
 static unsigned long starttime=0;
175 175
 static unsigned long stoptime=0;
176 176
 
177
-
177
+static uint8_t tmp_extruder;
178 178
 
179 179
 //===========================================================================
180 180
 //=============================ROUTINES=============================
@@ -641,7 +641,6 @@ inline void process_commands()
641 641
       //processed in write to file routine above
642 642
       //card,saving = false;
643 643
       break;
644
-      
645 644
     #endif //SDSUPPORT
646 645
 
647 646
     case 30: //M30 take time since the start of the SD print or an M109 command
@@ -684,19 +683,36 @@ inline void process_commands()
684 683
       }
685 684
      break;
686 685
     case 104: // M104
687
-      if (code_seen('S')) setTargetHotend0(code_value());
686
+      tmp_extruder = active_extruder;
687
+      if(code_seen('T')) {
688
+        tmp_extruder = code_value();
689
+        if(tmp_extruder >= EXTRUDERS) {
690
+          SERIAL_ECHO_START;
691
+          SERIAL_ECHO("M104 Invalid extruder ");
692
+          SERIAL_ECHOLN(tmp_extruder);
693
+          break;
694
+        }
695
+      }
696
+      if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
688 697
       setWatch();
689 698
       break;
690 699
     case 140: // M140 set bed temp
691 700
       if (code_seen('S')) setTargetBed(code_value());
692 701
       break;
693 702
     case 105 : // M105
694
-      //SERIAL_ECHOLN(freeMemory());
695
-       //test watchdog:
696
-       //delay(20000);
697
-      #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
703
+      tmp_extruder = active_extruder;
704
+      if(code_seen('T')) {
705
+        tmp_extruder = code_value();
706
+        if(tmp_extruder >= EXTRUDERS) {
707
+          SERIAL_ECHO_START;
708
+          SERIAL_ECHO("M105 Invalid extruder ");
709
+          SERIAL_ECHOLN(tmp_extruder);
710
+          break;
711
+        }
712
+      }
713
+      #if (TEMP_0_PIN > -1) || (TEMP_2_PIN > -1)
698 714
         SERIAL_PROTOCOLPGM("ok T:");
699
-        SERIAL_PROTOCOL( degHotend0()); 
715
+        SERIAL_PROTOCOL( degHotend(tmp_extruder)); 
700 716
         #if TEMP_1_PIN > -1 
701 717
           SERIAL_PROTOCOLPGM(" B:");  
702 718
           SERIAL_PROTOCOL(degBed());
@@ -715,41 +731,51 @@ inline void process_commands()
715 731
       break;
716 732
     case 109: 
717 733
     {// M109 - Wait for extruder heater to reach target.
718
-        LCD_MESSAGEPGM("Heating...");   
719
-        #ifdef AUTOTEMP
720
-          autotemp_enabled=false;
721
-        #endif
722
-        if (code_seen('S')) setTargetHotend0(code_value());
723
-        #ifdef AUTOTEMP
724
-          if (code_seen('S')) autotemp_min=code_value();
725
-          if (code_seen('T')) autotemp_max=code_value();
726
-          if (code_seen('F')) 
727
-          {
728
-            autotemp_factor=code_value();
729
-            autotemp_enabled=true;
730
-          }
731
-        #endif
732
-        
733
-        setWatch();
734
-        codenum = millis(); 
735
-
736
-        /* See if we are heating up or cooling down */
737
-        bool target_direction = isHeatingHotend0(); // true if heating, false if cooling
738
-
739
-        #ifdef TEMP_RESIDENCY_TIME
740
-          long residencyStart;
741
-          residencyStart = -1;
742
-          /* continue to loop until we have reached the target temp   
743
-            _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
744
-          while((target_direction ? (isHeatingHotend0()) : (isCoolingHotend0())) ||
745
-                  (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
746
-        #else
747
-          while ( target_direction ? (isHeatingHotend0()) : (isCoolingHotend0()&&(CooldownNoWait==false)) ) {
748
-        #endif //TEMP_RESIDENCY_TIME
734
+      tmp_extruder = active_extruder;
735
+      if(code_seen('T')) {
736
+        tmp_extruder = code_value();
737
+        if(tmp_extruder >= EXTRUDERS) {
738
+          SERIAL_ECHO_START;
739
+          SERIAL_ECHO("M109 Invalid extruder ");
740
+          SERIAL_ECHOLN(tmp_extruder);
741
+          break;
742
+        }
743
+      }
744
+      LCD_MESSAGEPGM("Heating...");   
745
+      #ifdef AUTOTEMP
746
+        autotemp_enabled=false;
747
+      #endif
748
+      if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
749
+      #ifdef AUTOTEMP
750
+        if (code_seen('S')) autotemp_min=code_value();
751
+        if (code_seen('G')) autotemp_max=code_value();
752
+        if (code_seen('F')) 
753
+        {
754
+          autotemp_factor=code_value();
755
+          autotemp_enabled=true;
756
+        }
757
+      #endif
758
+      
759
+      setWatch();
760
+      codenum = millis(); 
761
+
762
+      /* See if we are heating up or cooling down */
763
+      bool target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
764
+
765
+      #ifdef TEMP_RESIDENCY_TIME
766
+        long residencyStart;
767
+        residencyStart = -1;
768
+        /* continue to loop until we have reached the target temp   
769
+          _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
770
+        while((target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder))) ||
771
+                (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
772
+      #else
773
+        while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
774
+      #endif //TEMP_RESIDENCY_TIME
749 775
         if( (millis() - codenum) > 1000 ) 
750 776
         { //Print Temp Reading every 1 second while heating up/cooling down
751 777
           SERIAL_PROTOCOLPGM("T:");
752
-          SERIAL_PROTOCOLLN( degHotend0() ); 
778
+          SERIAL_PROTOCOLLN( degHotend(tmp_extruder) ); 
753 779
           codenum = millis();
754 780
         }
755 781
         manage_heater();
@@ -757,9 +783,9 @@ inline void process_commands()
757 783
         #ifdef TEMP_RESIDENCY_TIME
758 784
             /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
759 785
               or when current temp falls outside the hysteresis after target temp was reached */
760
-          if ((residencyStart == -1 &&  target_direction && !isHeatingHotend0()) ||
761
-              (residencyStart == -1 && !target_direction && !isCoolingHotend0()) ||
762
-              (residencyStart > -1 && labs(degHotend0() - degTargetHotend0()) > TEMP_HYSTERESIS) ) 
786
+          if ((residencyStart == -1 &&  target_direction && !isHeatingHotend(tmp_extruder)) ||
787
+              (residencyStart == -1 && !target_direction && !isCoolingHotend(tmp_extruder)) ||
788
+              (residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) ) 
763 789
           {
764 790
             residencyStart = millis();
765 791
           }
@@ -943,8 +969,6 @@ inline void process_commands()
943 969
     #ifdef PIDTEMP
944 970
     case 301: // M301
945 971
       {
946
-        
947
-       
948 972
         if(code_seen('P')) Kp = code_value();
949 973
         if(code_seen('I')) Ki = code_value()*PID_dT;
950 974
         if(code_seen('D')) Kd = code_value()/PID_dT;
@@ -989,6 +1013,18 @@ inline void process_commands()
989 1013
 
990 1014
     }
991 1015
   }
1016
+  else if(code_seen('T')) {
1017
+    tmp_extruder = code_value();
1018
+    if(tmp_extruder >= EXTRUDERS) {
1019
+      SERIAL_ECHO_START;
1020
+      SERIAL_ECHO("T");
1021
+      SERIAL_ECHO(tmp_extruder);
1022
+      SERIAL_ECHOLN("Invalid extruder");
1023
+    }
1024
+    else {
1025
+      active_extruder = tmp_extruder;
1026
+    }
1027
+  }
992 1028
   else
993 1029
   {
994 1030
     SERIAL_ECHO_START;

+ 2
- 0
Marlin/planner.cpp Wyświetl plik

@@ -81,6 +81,8 @@ float max_z_jerk;
81 81
 float mintravelfeedrate;
82 82
 unsigned long axis_steps_per_sqr_second[NUM_AXIS];
83 83
 
84
+uint8_t active_extruder = 0;
85
+
84 86
 // The current position of the tool in absolute steps
85 87
 long position[4];   //rescaled from extern when axis_steps_per_unit are changed by gcode
86 88
 static float previous_speed[4]; // Speed of previous path line segment

+ 1
- 0
Marlin/planner.h Wyświetl plik

@@ -94,6 +94,7 @@ extern float max_z_jerk;
94 94
 extern float mintravelfeedrate;
95 95
 extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
96 96
 
97
+extern uint8_t active_extruder;
97 98
 
98 99
 #ifdef AUTOTEMP
99 100
     extern bool autotemp_enabled;

+ 21
- 0
Marlin/temperature.h Wyświetl plik

@@ -62,9 +62,18 @@ extern float Kp,Ki,Kd,Kc;
62 62
 inline float degHotend0(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
63 63
 inline float degHotend1(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
64 64
 inline float degBed() {  return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
65
+inline float degHotend(uint8_t extruder){  
66
+  if(extruder == 0) return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
67
+  if(extruder == 1) return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);
68
+};
65 69
 
66 70
 inline float degTargetHotend0() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
67 71
 inline float degTargetHotend1() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
72
+inline float degTargetHotend(uint8_t extruder){  
73
+  if(extruder == 0) return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);
74
+  if(extruder == 1) return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);
75
+};
76
+
68 77
 inline float degTargetBed() {   return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
69 78
 
70 79
 inline void setTargetHotend0(const float &celsius) 
@@ -75,14 +84,26 @@ inline void setTargetHotend0(const float &celsius)
75 84
   #endif //PIDTEMP
76 85
 };
77 86
 inline void setTargetHotend1(const float &celsius) {  target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
87
+inline float setTargetHotend(const float &celcius, uint8_t extruder){  
88
+  if(extruder == 0) setTargetHotend0(celcius);
89
+  if(extruder == 1) setTargetHotend1(celcius);
90
+};
78 91
 inline void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSOR_BED     ]=temp2analogBed(celsius);};
79 92
 
80 93
 inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
81 94
 inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
95
+inline float isHeatingHotend(uint8_t extruder){  
96
+  if(extruder == 0) return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];
97
+  if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];
98
+};
82 99
 inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
83 100
 
84 101
 inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
85 102
 inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
103
+inline float isCoolingHotend(uint8_t extruder){  
104
+  if(extruder == 0) return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];
105
+  if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];
106
+};
86 107
 inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
87 108
 
88 109
 void disable_heater();

Ładowanie…
Anuluj
Zapisz