소스 검색

First parts 2nd extruder

Erik van der Zalm 13 년 전
부모
커밋
aad4b75b94
5개의 변경된 파일106개의 추가작업 그리고 45개의 파일을 삭제
  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 파일 보기

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

+ 81
- 45
Marlin/Marlin.pde 파일 보기

174
 static unsigned long starttime=0;
174
 static unsigned long starttime=0;
175
 static unsigned long stoptime=0;
175
 static unsigned long stoptime=0;
176
 
176
 
177
-
177
+static uint8_t tmp_extruder;
178
 
178
 
179
 //===========================================================================
179
 //===========================================================================
180
 //=============================ROUTINES=============================
180
 //=============================ROUTINES=============================
641
       //processed in write to file routine above
641
       //processed in write to file routine above
642
       //card,saving = false;
642
       //card,saving = false;
643
       break;
643
       break;
644
-      
645
     #endif //SDSUPPORT
644
     #endif //SDSUPPORT
646
 
645
 
647
     case 30: //M30 take time since the start of the SD print or an M109 command
646
     case 30: //M30 take time since the start of the SD print or an M109 command
684
       }
683
       }
685
      break;
684
      break;
686
     case 104: // M104
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
       setWatch();
697
       setWatch();
689
       break;
698
       break;
690
     case 140: // M140 set bed temp
699
     case 140: // M140 set bed temp
691
       if (code_seen('S')) setTargetBed(code_value());
700
       if (code_seen('S')) setTargetBed(code_value());
692
       break;
701
       break;
693
     case 105 : // M105
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
         SERIAL_PROTOCOLPGM("ok T:");
714
         SERIAL_PROTOCOLPGM("ok T:");
699
-        SERIAL_PROTOCOL( degHotend0()); 
715
+        SERIAL_PROTOCOL( degHotend(tmp_extruder)); 
700
         #if TEMP_1_PIN > -1 
716
         #if TEMP_1_PIN > -1 
701
           SERIAL_PROTOCOLPGM(" B:");  
717
           SERIAL_PROTOCOLPGM(" B:");  
702
           SERIAL_PROTOCOL(degBed());
718
           SERIAL_PROTOCOL(degBed());
715
       break;
731
       break;
716
     case 109: 
732
     case 109: 
717
     {// M109 - Wait for extruder heater to reach target.
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
         if( (millis() - codenum) > 1000 ) 
775
         if( (millis() - codenum) > 1000 ) 
750
         { //Print Temp Reading every 1 second while heating up/cooling down
776
         { //Print Temp Reading every 1 second while heating up/cooling down
751
           SERIAL_PROTOCOLPGM("T:");
777
           SERIAL_PROTOCOLPGM("T:");
752
-          SERIAL_PROTOCOLLN( degHotend0() ); 
778
+          SERIAL_PROTOCOLLN( degHotend(tmp_extruder) ); 
753
           codenum = millis();
779
           codenum = millis();
754
         }
780
         }
755
         manage_heater();
781
         manage_heater();
757
         #ifdef TEMP_RESIDENCY_TIME
783
         #ifdef TEMP_RESIDENCY_TIME
758
             /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
784
             /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
759
               or when current temp falls outside the hysteresis after target temp was reached */
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
             residencyStart = millis();
790
             residencyStart = millis();
765
           }
791
           }
943
     #ifdef PIDTEMP
969
     #ifdef PIDTEMP
944
     case 301: // M301
970
     case 301: // M301
945
       {
971
       {
946
-        
947
-       
948
         if(code_seen('P')) Kp = code_value();
972
         if(code_seen('P')) Kp = code_value();
949
         if(code_seen('I')) Ki = code_value()*PID_dT;
973
         if(code_seen('I')) Ki = code_value()*PID_dT;
950
         if(code_seen('D')) Kd = code_value()/PID_dT;
974
         if(code_seen('D')) Kd = code_value()/PID_dT;
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
   else
1028
   else
993
   {
1029
   {
994
     SERIAL_ECHO_START;
1030
     SERIAL_ECHO_START;

+ 2
- 0
Marlin/planner.cpp 파일 보기

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

+ 1
- 0
Marlin/planner.h 파일 보기

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

+ 21
- 0
Marlin/temperature.h 파일 보기

62
 inline float degHotend0(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
62
 inline float degHotend0(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
63
 inline float degHotend1(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
63
 inline float degHotend1(){  return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
64
 inline float degBed() {  return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
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
 inline float degTargetHotend0() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
70
 inline float degTargetHotend0() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
67
 inline float degTargetHotend1() {  return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
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
 inline float degTargetBed() {   return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
77
 inline float degTargetBed() {   return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
69
 
78
 
70
 inline void setTargetHotend0(const float &celsius) 
79
 inline void setTargetHotend0(const float &celsius) 
75
   #endif //PIDTEMP
84
   #endif //PIDTEMP
76
 };
85
 };
77
 inline void setTargetHotend1(const float &celsius) {  target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
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
 inline void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSOR_BED     ]=temp2analogBed(celsius);};
91
 inline void setTargetBed(const float &celsius)     {  target_raw[TEMPSENSOR_BED     ]=temp2analogBed(celsius);};
79
 
92
 
80
 inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
93
 inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
81
 inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
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
 inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
99
 inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
83
 
100
 
84
 inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
101
 inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
85
 inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
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
 inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
107
 inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
87
 
108
 
88
 void disable_heater();
109
 void disable_heater();

Loading…
취소
저장