Browse Source

Revert "this is not working. Do you maybe know why?"

This reverts commit 8bcdb9f5f0.
Bernhard Kubicek 13 years ago
parent
commit
b9ea0651ec
8 changed files with 182 additions and 268 deletions
  1. 8
    8
      Marlin/EEPROMwrite.h
  2. 0
    1
      Marlin/Marlin.h
  3. 40
    40
      Marlin/Marlin.pde
  4. 1
    1
      Marlin/planner.cpp
  5. 1
    1
      Marlin/stepper.cpp
  6. 68
    60
      Marlin/temperature.cpp
  7. 21
    110
      Marlin/temperature.h
  8. 43
    47
      Marlin/ultralcd.pde

+ 8
- 8
Marlin/EEPROMwrite.h View File

48
   EEPROM_writeAnything(i,max_xy_jerk);
48
   EEPROM_writeAnything(i,max_xy_jerk);
49
   EEPROM_writeAnything(i,max_z_jerk);
49
   EEPROM_writeAnything(i,max_z_jerk);
50
   #ifdef PIDTEMP
50
   #ifdef PIDTEMP
51
-  EEPROM_writeAnything(i,Heater::Kp);
52
-  EEPROM_writeAnything(i,Heater::Ki);
53
-  EEPROM_writeAnything(i,Heater::Kd);
51
+  EEPROM_writeAnything(i,Kp);
52
+  EEPROM_writeAnything(i,Ki);
53
+  EEPROM_writeAnything(i,Kd);
54
 #else
54
 #else
55
   EEPROM_writeAnything(i,3000);
55
   EEPROM_writeAnything(i,3000);
56
   EEPROM_writeAnything(i,0);
56
   EEPROM_writeAnything(i,0);
81
       EEPROM_readAnything(i,max_xy_jerk);
81
       EEPROM_readAnything(i,max_xy_jerk);
82
       EEPROM_readAnything(i,max_z_jerk);
82
       EEPROM_readAnything(i,max_z_jerk);
83
 #ifndef PIDTEMP
83
 #ifndef PIDTEMP
84
-      float Kp,Ki,Kd; //read and ignore..
84
+      float Kp,Ki,Kd;
85
 #endif
85
 #endif
86
-      EEPROM_readAnything(i,Heater::Kp);
87
-      EEPROM_readAnything(i,Heater::Ki);
88
-      EEPROM_readAnything(i,Heater::Kd);
86
+      EEPROM_readAnything(i,Kp);
87
+      EEPROM_readAnything(i,Ki);
88
+      EEPROM_readAnything(i,Kd);
89
 
89
 
90
       ECHOLN("Stored settings retreived:");
90
       ECHOLN("Stored settings retreived:");
91
   }
91
   }
119
   ECHOLN("   M205 S"  <<_FLOAT(minimumfeedrate/60,2) << " T" << _FLOAT(mintravelfeedrate/60,2) << " B" << _FLOAT(minsegmenttime,2) << " X" << _FLOAT(max_xy_jerk/60,2) << " Z" << _FLOAT(max_z_jerk/60,2));
119
   ECHOLN("   M205 S"  <<_FLOAT(minimumfeedrate/60,2) << " T" << _FLOAT(mintravelfeedrate/60,2) << " B" << _FLOAT(minsegmenttime,2) << " X" << _FLOAT(max_xy_jerk/60,2) << " Z" << _FLOAT(max_z_jerk/60,2));
120
 #ifdef PIDTEMP
120
 #ifdef PIDTEMP
121
   ECHOLN("PID settings:");
121
   ECHOLN("PID settings:");
122
-  ECHOLN("   M301 P"  << _FLOAT(Heater::Kp,3) << " I" << _FLOAT(Heater::Ki,3) << " D" << _FLOAT(Heater::Kd,3));  
122
+  ECHOLN("   M301 P"  << _FLOAT(Kp,3) << " I" << _FLOAT(Ki,3) << " D" << _FLOAT(Kd,3));  
123
 #endif
123
 #endif
124
   
124
   
125
 }  
125
 }  

+ 0
- 1
Marlin/Marlin.h View File

10
 #define ECHO(x) Serial << "echo: " << x;
10
 #define ECHO(x) Serial << "echo: " << x;
11
 #define ECHOLN(x) Serial << "echo: "<<x<<endl;
11
 #define ECHOLN(x) Serial << "echo: "<<x<<endl;
12
 
12
 
13
-
14
 void get_command();
13
 void get_command();
15
 void process_commands();
14
 void process_commands();
16
 
15
 

+ 40
- 40
Marlin/Marlin.pde View File

40
   #include "Simplelcd.h"
40
   #include "Simplelcd.h"
41
 #endif
41
 #endif
42
 
42
 
43
-Heater htr;
44
 char version_string[] = "1.0.0 Alpha 1";
43
 char version_string[] = "1.0.0 Alpha 1";
45
 
44
 
46
 #ifdef SDSUPPORT
45
 #ifdef SDSUPPORT
264
 #endif //SDSUPPORT
263
 #endif //SDSUPPORT
265
   plan_init();  // Initialize planner;
264
   plan_init();  // Initialize planner;
266
   st_init();    // Initialize stepper;
265
   st_init();    // Initialize stepper;
267
-  //tp_init();    // Initialize temperature loop is now done by the constructor of the Heater class
266
+  tp_init();    // Initialize temperature loop
268
 	//checkautostart();
267
 	//checkautostart();
269
 }
268
 }
270
 
269
 
368
     bufindr = (bufindr + 1)%BUFSIZE;
367
     bufindr = (bufindr + 1)%BUFSIZE;
369
   }
368
   }
370
   //check heater every n milliseconds
369
   //check heater every n milliseconds
371
-  Heater::manage_heater();
370
+  manage_heater();
372
   manage_inactivity(1);
371
   manage_inactivity(1);
373
   LCD_STATUS;
372
   LCD_STATUS;
374
 }
373
 }
548
       if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
547
       if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
549
       codenum += millis();  // keep track of when we started waiting
548
       codenum += millis();  // keep track of when we started waiting
550
       while(millis()  < codenum ){
549
       while(millis()  < codenum ){
551
-        Heater::manage_heater();
550
+        manage_heater();
552
       }
551
       }
553
       break;
552
       break;
554
     case 28: //G28 Home all Axis one at a time
553
     case 28: //G28 Home all Axis one at a time
802
         }
801
         }
803
         break;
802
         break;
804
       case 104: // M104
803
       case 104: // M104
805
-        if (code_seen('S')) Heater::setCelsius(TEMPSENSOR_HOTEND,code_value());
804
+                if (code_seen('S')) target_raw[TEMPSENSOR_HOTEND] = temp2analog(code_value());
805
+#ifdef PIDTEMP
806
+                pid_setpoint = code_value();
807
+#endif //PIDTEM
806
         #ifdef WATCHPERIOD
808
         #ifdef WATCHPERIOD
807
-            if(Heater::isHeating(TEMPSENSOR_HOTEND)){
809
+            if(target_raw[TEMPSENSOR_HOTEND] > current_raw[TEMPSENSOR_HOTEND]){
808
                 watchmillis = max(1,millis());
810
                 watchmillis = max(1,millis());
809
                 watch_raw[TEMPSENSOR_HOTEND] = current_raw[TEMPSENSOR_HOTEND];
811
                 watch_raw[TEMPSENSOR_HOTEND] = current_raw[TEMPSENSOR_HOTEND];
810
             }else{
812
             }else{
813
         #endif
815
         #endif
814
         break;
816
         break;
815
       case 140: // M140 set bed temp
817
       case 140: // M140 set bed temp
816
-                if (code_seen('S')) Heater::setCelsius(TEMPSENSOR_BED,code_value());
818
+                if (code_seen('S')) target_raw[TEMPSENSOR_BED] = temp2analogBed(code_value());
817
         break;
819
         break;
818
       case 105: // M105
820
       case 105: // M105
819
         #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
821
         #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
820
-                tt = Heater::celsius(TEMPSENSOR_HOTEND);
822
+                tt = analog2temp(current_raw[TEMPSENSOR_HOTEND]);
821
         #endif
823
         #endif
822
         #if TEMP_1_PIN > -1
824
         #if TEMP_1_PIN > -1
823
-                bt = Heater::celsius(TEMPSENSOR_BED);
825
+                bt = analog2tempBed(current_raw[TEMPSENSOR_BED]);
824
         #endif
826
         #endif
825
         #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
827
         #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
826
             Serial.print("ok T:");
828
             Serial.print("ok T:");
831
 #ifdef PIDTEMP
833
 #ifdef PIDTEMP
832
             Serial.print(" B:");
834
             Serial.print(" B:");
833
             #if TEMP_1_PIN > -1
835
             #if TEMP_1_PIN > -1
834
-	      Serial.println(bt); 
836
+            Serial.println(bt); 
835
             #else
837
             #else
836
-	      Serial.println(Heater::HeaterPower); 
838
+            Serial.println(HeaterPower); 
837
             #endif
839
             #endif
838
 #else
840
 #else
839
             Serial.println();
841
             Serial.println();
840
 #endif
842
 #endif
841
-          #else<
843
+          #else
842
             Serial.println();
844
             Serial.println();
843
           #endif
845
           #endif
844
         #else
846
         #else
848
         //break;
850
         //break;
849
       case 109: {// M109 - Wait for extruder heater to reach target.
851
       case 109: {// M109 - Wait for extruder heater to reach target.
850
             LCD_MESSAGE("Heating...");
852
             LCD_MESSAGE("Heating...");
851
-               if (code_seen('S')) Heater::setCelsius(TEMPSENSOR_HOTEND,code_value());
852
-            
853
+               if (code_seen('S')) target_raw[TEMPSENSOR_HOTEND] = temp2analog(code_value());
854
+            #ifdef PIDTEMP
855
+            pid_setpoint = code_value();
856
+            #endif //PIDTEM
853
             #ifdef WATCHPERIOD
857
             #ifdef WATCHPERIOD
854
-          if(Heater::isHeating(TEMPSENSOR_HOTEND)){
858
+          if(target_raw[TEMPSENSOR_HOTEND]>current_raw[TEMPSENSOR_HOTEND]){
855
               watchmillis = max(1,millis());
859
               watchmillis = max(1,millis());
856
-              watch_raw[TEMPSENSOR_HOTEND] = Heater::current_raw[TEMPSENSOR_HOTEND];
860
+              watch_raw[TEMPSENSOR_HOTEND] = current_raw[TEMPSENSOR_HOTEND];
857
             } else {
861
             } else {
858
               watchmillis = 0;
862
               watchmillis = 0;
859
             }
863
             }
861
             codenum = millis(); 
865
             codenum = millis(); 
862
      
866
      
863
                /* See if we are heating up or cooling down */
867
                /* See if we are heating up or cooling down */
864
-              bool target_direction = Heater::isHeating(TEMPSENSOR_HOTEND); // true if heating, false if cooling
868
+              bool target_direction = (current_raw[0] < target_raw[0]); // true if heating, false if cooling
865
 
869
 
866
             #ifdef TEMP_RESIDENCY_TIME
870
             #ifdef TEMP_RESIDENCY_TIME
867
             long residencyStart;
871
             long residencyStart;
868
             residencyStart = -1;
872
             residencyStart = -1;
869
             /* continue to loop until we have reached the target temp   
873
             /* continue to loop until we have reached the target temp   
870
               _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
874
               _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
871
-            while((target_direction ? Heater::isHeating(TEMPSENSOR_HOTEND) : Heater::isCooling(TEMPSENSOR_HOTEND)) ||
875
+            while((target_direction ? (current_raw[0] < target_raw[0]) : (current_raw[0] > target_raw[0])) ||
872
                     (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
876
                     (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
873
             #else
877
             #else
874
-            while ( target_direction ? Heater::isHeating(TEMPSENSOR_HOTEND) : Heater::isCooling(TEMPSENSOR_HOTEND) ) {
878
+            while ( target_direction ? (current_raw[0] < target_raw[0]) : (current_raw[0] > target_raw[0]) ) {
875
             #endif //TEMP_RESIDENCY_TIME
879
             #endif //TEMP_RESIDENCY_TIME
876
               if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up/cooling down
880
               if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up/cooling down
877
                 Serial.print("T:");
881
                 Serial.print("T:");
878
-              Serial.println( Heater::celsius(TEMPSENSOR_HOTEND) ); 
882
+              Serial.println( analog2temp(current_raw[TEMPSENSOR_HOTEND]) ); 
879
                 codenum = millis();
883
                 codenum = millis();
880
               }
884
               }
881
-              Heater::manage_heater();
885
+              manage_heater();
882
               LCD_STATUS;
886
               LCD_STATUS;
883
               #ifdef TEMP_RESIDENCY_TIME
887
               #ifdef TEMP_RESIDENCY_TIME
884
                /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
888
                /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
885
                   or when current temp falls outside the hysteresis after target temp was reached */
889
                   or when current temp falls outside the hysteresis after target temp was reached */
886
-              if ((residencyStart == -1 &&  target_direction && !Heater::isHeating(TEMPSENSOR_HOTEND)) ||
887
-                  (residencyStart == -1 && !target_direction && !Heater::isCooling(TEMPSENSOR_HOTEND)) ||
888
-                  (residencyStart > -1 && labs(Heater::celsius(TEMPSENSOR_HOTEND) - Heater::celsiusTarget(TEMPSENSOR_HOTEND)) > TEMP_HYSTERESIS) ) {
890
+              if ((residencyStart == -1 &&  target_direction && current_raw[0] >= target_raw[0]) ||
891
+                  (residencyStart == -1 && !target_direction && current_raw[0] <= target_raw[0]) ||
892
+                  (residencyStart > -1 && labs(analog2temp(current_raw[0]) - analog2temp(target_raw[0])) > TEMP_HYSTERESIS) ) {
889
                 residencyStart = millis();
893
                 residencyStart = millis();
890
               }
894
               }
891
               #endif //TEMP_RESIDENCY_TIME
895
               #endif //TEMP_RESIDENCY_TIME
895
           break;
899
           break;
896
       case 190: // M190 - Wait bed for heater to reach target.
900
       case 190: // M190 - Wait bed for heater to reach target.
897
       #if TEMP_1_PIN > -1
901
       #if TEMP_1_PIN > -1
898
-          if (code_seen('S')) Heater::setCelsius(TEMPSENSOR_BED,code_value());
902
+          if (code_seen('S')) target_raw[TEMPSENSOR_BED] = temp2analog(code_value());
899
         codenum = millis(); 
903
         codenum = millis(); 
900
-          while(Heater::isHeating(TEMPSENSOR_BED)) 
901
-          {
904
+          while(current_raw[TEMPSENSOR_BED] < target_raw[TEMPSENSOR_BED]) 
905
+                                {
902
           if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
906
           if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
903
           {
907
           {
904
-            float tt=Heater::celsius(TEMPSENSOR_HOTEND);
908
+            float tt=analog2temp(current_raw[TEMPSENSOR_HOTEND]);
905
             Serial.print("T:");
909
             Serial.print("T:");
906
             Serial.println( tt );
910
             Serial.println( tt );
907
             Serial.print("ok T:");
911
             Serial.print("ok T:");
908
             Serial.print( tt ); 
912
             Serial.print( tt ); 
909
             Serial.print(" B:");
913
             Serial.print(" B:");
910
-            Serial.println( Heater::celsius(TEMPSENSOR_BED) ); 
914
+            Serial.println( analog2temp(current_raw[TEMPSENSOR_BED]) ); 
911
             codenum = millis(); 
915
             codenum = millis(); 
912
           }
916
           }
913
-            Heater::manage_heater();
917
+            manage_heater();
914
         }
918
         }
915
       #endif
919
       #endif
916
       break;
920
       break;
1062
       break;
1066
       break;
1063
 #ifdef PIDTEMP
1067
 #ifdef PIDTEMP
1064
     case 301: // M301
1068
     case 301: // M301
1065
-      if(code_seen('P')) Heater::Kp = code_value();
1066
-      if(code_seen('I')) Heater::Ki = code_value()*PID_dT;
1067
-      if(code_seen('D')) Heater::Kd = code_value()/PID_dT;
1068
-      #ifdef PID_ADD_EXTRUSION_RATE
1069
-	 if(code_seen('C')) Heater::Kc = code_value();
1070
-      #endif
1071
-
1069
+      if(code_seen('P')) Kp = code_value();
1070
+      if(code_seen('I')) Ki = code_value()*PID_dT;
1071
+      if(code_seen('D')) Kd = code_value()/PID_dT;
1072
 //      ECHOLN("Kp "<<_FLOAT(Kp,2));
1072
 //      ECHOLN("Kp "<<_FLOAT(Kp,2));
1073
 //      ECHOLN("Ki "<<_FLOAT(Ki/PID_dT,2));
1073
 //      ECHOLN("Ki "<<_FLOAT(Ki/PID_dT,2));
1074
 //      ECHOLN("Kd "<<_FLOAT(Kd*PID_dT,2));
1074
 //      ECHOLN("Kd "<<_FLOAT(Kd*PID_dT,2));
1194
 inline void kill()
1194
 inline void kill()
1195
 {
1195
 {
1196
   #if TEMP_0_PIN > -1
1196
   #if TEMP_0_PIN > -1
1197
-  Heater::setCelsius(TEMPSENSOR_HOTEND,0);
1197
+  target_raw[0]=0;
1198
    #if HEATER_0_PIN > -1  
1198
    #if HEATER_0_PIN > -1  
1199
      WRITE(HEATER_0_PIN,LOW);
1199
      WRITE(HEATER_0_PIN,LOW);
1200
    #endif
1200
    #endif
1201
   #endif
1201
   #endif
1202
   #if TEMP_1_PIN > -1
1202
   #if TEMP_1_PIN > -1
1203
-  Heater::setCelsius(TEMPSENSOR_BED,0);
1203
+  target_raw[1]=0;
1204
   #if HEATER_1_PIN > -1 
1204
   #if HEATER_1_PIN > -1 
1205
     WRITE(HEATER_1_PIN,LOW);
1205
     WRITE(HEATER_1_PIN,LOW);
1206
   #endif
1206
   #endif
1207
   #endif
1207
   #endif
1208
   #if TEMP_2_PIN > -1
1208
   #if TEMP_2_PIN > -1
1209
-  Heater::setCelsius(TEMPSENSOR_AUX,0);
1209
+  target_raw[2]=0;
1210
   #if HEATER_2_PIN > -1  
1210
   #if HEATER_2_PIN > -1  
1211
     WRITE(HEATER_2_PIN,LOW);
1211
     WRITE(HEATER_2_PIN,LOW);
1212
   #endif
1212
   #endif

+ 1
- 1
Marlin/planner.cpp View File

388
   // If the buffer is full: good! That means we are well ahead of the robot. 
388
   // If the buffer is full: good! That means we are well ahead of the robot. 
389
   // Rest here until there is room in the buffer.
389
   // Rest here until there is room in the buffer.
390
   while(block_buffer_tail == next_buffer_head) { 
390
   while(block_buffer_tail == next_buffer_head) { 
391
-    htr.manage_heater(); 
391
+    manage_heater(); 
392
     manage_inactivity(1); 
392
     manage_inactivity(1); 
393
     LCD_STATUS;
393
     LCD_STATUS;
394
   }
394
   }

+ 1
- 1
Marlin/stepper.cpp View File

585
 void st_synchronize()
585
 void st_synchronize()
586
 {
586
 {
587
   while(plan_get_current_block()) {
587
   while(plan_get_current_block()) {
588
-    htr.manage_heater();
588
+    manage_heater();
589
     manage_inactivity(1);
589
     manage_inactivity(1);
590
     LCD_STATUS;
590
     LCD_STATUS;
591
   }   
591
   }   

+ 68
- 60
Marlin/temperature.cpp View File

37
 #include "streaming.h"
37
 #include "streaming.h"
38
 #include "temperature.h"
38
 #include "temperature.h"
39
 
39
 
40
+int target_bed_raw = 0;
41
+int current_bed_raw = 0;
40
 
42
 
43
+int target_raw[3] = {0, 0, 0};
44
+int current_raw[3] = {0, 0, 0};
45
+unsigned char temp_meas_ready = false;
41
 
46
 
47
+unsigned long previous_millis_heater, previous_millis_bed_heater;
42
 
48
 
49
+#ifdef PIDTEMP
50
+  double temp_iState = 0;
51
+  double temp_dState = 0;
52
+  double pTerm;
53
+  double iTerm;
54
+  double dTerm;
55
+      //int output;
56
+  double pid_error;
57
+  double temp_iState_min;
58
+  double temp_iState_max;
59
+  double pid_setpoint = 0.0;
60
+  double pid_input;
61
+  double pid_output;
62
+  bool pid_reset;
63
+  float HeaterPower;
64
+  
65
+  float Kp=DEFAULT_Kp;
66
+  float Ki=DEFAULT_Ki;
67
+  float Kd=DEFAULT_Kd;
68
+  float Kc=DEFAULT_Kc;
69
+#endif //PIDTEMP
70
+
71
+#ifdef MINTEMP
72
+int minttemp = temp2analog(MINTEMP);
73
+#endif //MINTEMP
74
+#ifdef MAXTEMP
75
+int maxttemp = temp2analog(MAXTEMP);
76
+#endif //MAXTEMP
77
+
78
+#ifdef BED_MINTEMP
79
+int bed_minttemp = temp2analog(BED_MINTEMP);
80
+#endif //BED_MINTEMP
81
+#ifdef BED_MAXTEMP
82
+int bed_maxttemp = temp2analog(BED_MAXTEMP);
83
+#endif //BED_MAXTEMP
43
 
84
 
44
-void static Heater::manage_heater()
85
+void manage_heater()
45
 {
86
 {
46
 #ifdef USE_WATCHDOG
87
 #ifdef USE_WATCHDOG
47
   wd_reset();
88
   wd_reset();
49
   
90
   
50
   float pid_input;
91
   float pid_input;
51
   float pid_output;
92
   float pid_output;
52
-  if(htr.temp_meas_ready != true)   //better readability
93
+  if(temp_meas_ready != true)   //better readability
53
     return; 
94
     return; 
54
 
95
 
55
 CRITICAL_SECTION_START;
96
 CRITICAL_SECTION_START;
56
-    htr.temp_meas_ready = false;
97
+    temp_meas_ready = false;
57
 CRITICAL_SECTION_END;
98
 CRITICAL_SECTION_END;
58
 
99
 
59
 #ifdef PIDTEMP
100
 #ifdef PIDTEMP
135
 // For a thermistor, it uses the RepRap thermistor temp table.
176
 // For a thermistor, it uses the RepRap thermistor temp table.
136
 // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
177
 // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
137
 // This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
178
 // This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
138
-float const static temp2analog(const int celsius)
139
-{
179
+float temp2analog(int celsius) {
140
   #ifdef HEATER_USES_THERMISTOR_1
180
   #ifdef HEATER_USES_THERMISTOR_1
141
     int raw = 0;
181
     int raw = 0;
142
     byte i;
182
     byte i;
167
 // For a thermistor, it uses the RepRap thermistor temp table.
207
 // For a thermistor, it uses the RepRap thermistor temp table.
168
 // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
208
 // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
169
 // This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
209
 // This function is derived from inversing the logic from a portion of getTemperature() in FiveD RepRap firmware.
170
-float const static temp2analogBed(const int celsius)
171
-{
210
+float temp2analogBed(int celsius) {
172
   #ifdef BED_USES_THERMISTOR
211
   #ifdef BED_USES_THERMISTOR
173
 
212
 
174
     int raw = 0;
213
     int raw = 0;
198
 
237
 
199
 // Derived from RepRap FiveD extruder::getTemperature()
238
 // Derived from RepRap FiveD extruder::getTemperature()
200
 // For hot end temperature measurement.
239
 // For hot end temperature measurement.
201
-float const static Heater::analog2temp(const int raw) {
240
+float analog2temp(int raw) {
202
   #ifdef HEATER_1_USES_THERMISTOR
241
   #ifdef HEATER_1_USES_THERMISTOR
203
     int celsius = 0;
242
     int celsius = 0;
204
     byte i;  
243
     byte i;  
227
 
266
 
228
 // Derived from RepRap FiveD extruder::getTemperature()
267
 // Derived from RepRap FiveD extruder::getTemperature()
229
 // For bed temperature measurement.
268
 // For bed temperature measurement.
230
-float const static Heater::analog2tempBed(const int raw) {
269
+float analog2tempBed(int raw) {
231
   #ifdef BED_USES_THERMISTOR
270
   #ifdef BED_USES_THERMISTOR
232
     int celsius = 0;
271
     int celsius = 0;
233
     byte i;
272
     byte i;
257
   #endif
296
   #endif
258
 }
297
 }
259
 
298
 
260
-Heater::Heater()
299
+void tp_init()
261
 {
300
 {
262
-  for(short i=0;i<3;i++)
263
-  {
264
-    target_raw[i]=0;
265
-    current_raw[i] =0;
266
-  }
267
-  htr.temp_meas_ready = false;
268
-  #ifdef MINTEMP
269
-  minttemp = temp2analog(MINTEMP);
270
-  #endif //MINTEMP
271
-  #ifdef MAXTEMP
272
-  maxttemp = temp2analog(MAXTEMP);
273
-  #endif //MAXTEMP
274
-
275
-  #ifdef BED_MINTEMP
276
-  bed_minttemp = temp2analog(BED_MINTEMP);
277
-  #endif //BED_MINTEMP
278
-  #ifdef BED_MAXTEMP
279
-  bed_maxttemp = temp2analog(BED_MAXTEMP);
280
-  #endif //BED_MAXTEMP
281
-  
282
 #if (HEATER_0_PIN > -1) 
301
 #if (HEATER_0_PIN > -1) 
283
   SET_OUTPUT(HEATER_0_PIN);
302
   SET_OUTPUT(HEATER_0_PIN);
284
 #endif  
303
 #endif  
292
 #ifdef PIDTEMP
311
 #ifdef PIDTEMP
293
   temp_iState_min = 0.0;
312
   temp_iState_min = 0.0;
294
   temp_iState_max = PID_INTEGRAL_DRIVE_MAX / Ki;
313
   temp_iState_max = PID_INTEGRAL_DRIVE_MAX / Ki;
295
-  temp_iState = 0;
296
-  temp_dState = 0;
297
-  Kp=DEFAULT_Kp;
298
-  Ki=DEFAULT_Ki;
299
-  Kd=DEFAULT_Kd;
300
-  Kc=DEFAULT_Kc;
301
-  pid_setpoint = 0.0;
302
-
303
 #endif //PIDTEMP
314
 #endif //PIDTEMP
304
 
315
 
305
 // Set analog inputs
316
 // Set analog inputs
396
   if(temp_count >= 16) // 6 ms * 16 = 96ms.
407
   if(temp_count >= 16) // 6 ms * 16 = 96ms.
397
   {
408
   {
398
     #ifdef HEATER_1_USES_AD595
409
     #ifdef HEATER_1_USES_AD595
399
-      htr.current_raw[0] = raw_temp_0_value;
410
+      current_raw[0] = raw_temp_0_value;
400
     #else
411
     #else
401
-      htr.current_raw[0] = 16383 - raw_temp_0_value;
412
+      current_raw[0] = 16383 - raw_temp_0_value;
402
     #endif
413
     #endif
403
     
414
     
404
     #ifdef HEATER_2_USES_AD595
415
     #ifdef HEATER_2_USES_AD595
405
-      htr.current_raw[2] = raw_temp_2_value;
416
+      current_raw[2] = raw_temp_2_value;
406
     #else
417
     #else
407
-      htr.current_raw[2] = 16383 - raw_temp_2_value;
418
+      current_raw[2] = 16383 - raw_temp_2_value;
408
     #endif
419
     #endif
409
     
420
     
410
     #ifdef BED_USES_AD595
421
     #ifdef BED_USES_AD595
411
-      htr.current_raw[1] = raw_temp_1_value;
422
+      current_raw[1] = raw_temp_1_value;
412
     #else
423
     #else
413
-      htr.current_raw[1] = 16383 - raw_temp_1_value;
424
+      current_raw[1] = 16383 - raw_temp_1_value;
414
     #endif
425
     #endif
415
     
426
     
416
-   htr.temp_meas_ready = true;
427
+    temp_meas_ready = true;
417
     temp_count = 0;
428
     temp_count = 0;
418
     raw_temp_0_value = 0;
429
     raw_temp_0_value = 0;
419
     raw_temp_1_value = 0;
430
     raw_temp_1_value = 0;
420
     raw_temp_2_value = 0;
431
     raw_temp_2_value = 0;
421
 #ifdef MAXTEMP
432
 #ifdef MAXTEMP
422
   #if (HEATER_0_PIN > -1)
433
   #if (HEATER_0_PIN > -1)
423
-    if(htr.current_raw[TEMPSENSOR_HOTEND] >= htr.maxttemp) {
424
-      htr.target_raw[TEMPSENSOR_HOTEND] = 0;
434
+    if(current_raw[TEMPSENSOR_HOTEND] >= maxttemp) {
435
+      target_raw[TEMPSENSOR_HOTEND] = 0;
425
       analogWrite(HEATER_0_PIN, 0);
436
       analogWrite(HEATER_0_PIN, 0);
426
       Serial.println("!! Temperature extruder 0 switched off. MAXTEMP triggered !!");
437
       Serial.println("!! Temperature extruder 0 switched off. MAXTEMP triggered !!");
427
     }
438
     }
428
   #endif
439
   #endif
429
   #if (HEATER_2_PIN > -1)
440
   #if (HEATER_2_PIN > -1)
430
-    if(htr.current_raw[TEMPSENSOR_AUX] >= htr.maxttemp) {
431
-      htr.target_raw[TEMPSENSOR_AUX] = 0;
441
+    if(current_raw[TEMPSENSOR_AUX] >= maxttemp) {
442
+      target_raw[TEMPSENSOR_AUX] = 0;
432
       analogWrite(HEATER_2_PIN, 0);
443
       analogWrite(HEATER_2_PIN, 0);
433
       Serial.println("!! Temperature extruder 1 switched off. MAXTEMP triggered !!");
444
       Serial.println("!! Temperature extruder 1 switched off. MAXTEMP triggered !!");
434
     }
445
     }
436
 #endif //MAXTEMP
447
 #endif //MAXTEMP
437
 #ifdef MINTEMP
448
 #ifdef MINTEMP
438
   #if (HEATER_0_PIN > -1)
449
   #if (HEATER_0_PIN > -1)
439
-    if(htr.current_raw[TEMPSENSOR_HOTEND] <= htr.minttemp) {
440
-      htr.target_raw[TEMPSENSOR_HOTEND] = 0;
450
+    if(current_raw[TEMPSENSOR_HOTEND] <= minttemp) {
451
+      target_raw[TEMPSENSOR_HOTEND] = 0;
441
       analogWrite(HEATER_0_PIN, 0);
452
       analogWrite(HEATER_0_PIN, 0);
442
       Serial.println("!! Temperature extruder 0 switched off. MINTEMP triggered !!");
453
       Serial.println("!! Temperature extruder 0 switched off. MINTEMP triggered !!");
443
     }
454
     }
444
   #endif
455
   #endif
445
   #if (HEATER_2_PIN > -1)
456
   #if (HEATER_2_PIN > -1)
446
-    if(htr.current_raw[TEMPSENSOR_AUX] <= htr.minttemp) {
447
-      htr.target_raw[TEMPSENSOR_AUX] = 0;
457
+    if(current_raw[TEMPSENSOR_AUX] <= minttemp) {
458
+      target_raw[TEMPSENSOR_AUX] = 0;
448
       analogWrite(HEATER_2_PIN, 0);
459
       analogWrite(HEATER_2_PIN, 0);
449
       Serial.println("!! Temperature extruder 1 switched off. MINTEMP triggered !!");
460
       Serial.println("!! Temperature extruder 1 switched off. MINTEMP triggered !!");
450
     }
461
     }
452
 #endif //MAXTEMP
463
 #endif //MAXTEMP
453
 #ifdef BED_MINTEMP
464
 #ifdef BED_MINTEMP
454
   #if (HEATER_1_PIN > -1)
465
   #if (HEATER_1_PIN > -1)
455
-    if(htr.current_raw[1] <= htr.bed_minttemp) {
456
-      htr.target_raw[1] = 0;
466
+    if(current_raw[1] <= bed_minttemp) {
467
+      target_raw[1] = 0;
457
       WRITE(HEATER_1_PIN, 0);
468
       WRITE(HEATER_1_PIN, 0);
458
       Serial.println("!! Temperatur heated bed switched off. MINTEMP triggered !!");
469
       Serial.println("!! Temperatur heated bed switched off. MINTEMP triggered !!");
459
     }
470
     }
461
 #endif
472
 #endif
462
 #ifdef BED_MAXTEMP
473
 #ifdef BED_MAXTEMP
463
   #if (HEATER_1_PIN > -1)
474
   #if (HEATER_1_PIN > -1)
464
-    if(htr.current_raw[1] >= htr.bed_maxttemp) {
465
-      htr.target_raw[1] = 0;
475
+    if(current_raw[1] >= bed_maxttemp) {
476
+      target_raw[1] = 0;
466
       WRITE(HEATER_1_PIN, 0);
477
       WRITE(HEATER_1_PIN, 0);
467
       Serial.println("!! Temperature heated bed switched off. MAXTEMP triggered !!");
478
       Serial.println("!! Temperature heated bed switched off. MAXTEMP triggered !!");
468
     }
479
     }
470
 #endif
481
 #endif
471
   }
482
   }
472
 }
483
 }
473
-
474
-//Heater htr;
475
-

+ 21
- 110
Marlin/temperature.h View File

25
 #ifdef PID_ADD_EXTRUSION_RATE
25
 #ifdef PID_ADD_EXTRUSION_RATE
26
   #include "stepper.h"
26
   #include "stepper.h"
27
 #endif
27
 #endif
28
-
29
-enum TempSensor {TEMPSENSOR_HOTEND=0,TEMPSENSOR_BED=1, TEMPSENSOR_AUX=2};
30
-
31
-// ther must be only one instance of this class, and it is created in temperature.cpp by itself and is called "htr".
32
-// all the variables are static, so that of the compiler optimization is more easy.
33
-// I honestly hope that this increases readability and structure.
34
-// none of the variables or routines should be called from an secondary process/interrupt with the exceptino of current_raw[].
35
-
36
-class Heater
37
-{
38
-public:
39
-  Heater(); //treplaces tp_init();
40
-  ~Heater(); 
41
-  
42
-  void static manage_heater(); /// it is critical that this is called continously. 
43
-  
44
-  // conversion routines, const since they don't change any class variables.
45
-  float const static temp2analog(const int celsius);
46
-  float const static temp2analogBed(const int celsius);
47
-  float const static analog2temp(const int raw);
48
-  float const static analog2tempBed(const int raw);
49
-  
50
-  inline float const static celsius(const TempSensor s) 
51
-    {
52
-      if(s==TEMPSENSOR_BED) 
53
-	return analog2tempBed(Heater::current_raw[s]); 
54
-      else 
55
-	return analog2temp(Heater::current_raw[s]);
56
-    };
57
-  inline float const static celsiusTarget(const TempSensor s) 
58
-    {
59
-      if(s==TEMPSENSOR_BED) 
60
-	return analog2tempBed(Heater::target_raw[s]); 
61
-      else 
62
-	return analog2temp(Heater::target_raw[s]);
63
-    };
64
-  inline float static setCelsius(const TempSensor s, const int celsius) 
65
-    {
66
-      #ifdef PIDTEMP
67
-	if(s==TEMPSENSOR_HOTEND)
68
-            Heater::pid_setpoint = celsius;
69
-      #endif //PIDTEM
70
-      if(s==TEMPSENSOR_BED) 
71
-	Heater::target_raw[s] = temp2analog(celsius); 
72
-      else 
73
-	Heater::target_raw[s] = temp2analogBed(celsius); 
74
-    };
75
-
76
-   inline bool const static isHeating(TempSensor s)
77
-   { return (Heater::target_raw[s]>Heater::current_raw[s]);};
78
-   inline bool const static isCooling(TempSensor s)
79
-   { return (Heater::target_raw[s]<Heater::current_raw[s]);};
80
-
81
-public:
82
-  #ifdef PIDTEMP
83
-    static float Kp;
84
-    static float Ki;
85
-    static float Kd;
86
-    static float Kc;
87
-  #endif
88
-  
89
-  static int target_raw[3];
90
-  static float pid_setpoint;
91
-  
92
-  volatile static int current_raw[3]; //this are written by an ISR, so volatile.
93
-  volatile static bool temp_meas_ready ; //also this is set by the ISR
94
-  
95
-  
96
-private:
97
- 
98
-  
99
-
100
-  static unsigned long previous_millis_heater, previous_millis_bed_heater;
101
-
102
-  #ifdef PIDTEMP
103
-    static float temp_iState;
104
-    static float temp_dState;
105
-    static float pTerm;
106
-    static float iTerm;
107
-    static float dTerm;
108
-	//int output;
109
-    static float pid_error;
110
-    static float temp_iState_min;
111
-    static float temp_iState_max;
112
-    static float pid_input;
113
-    static float pid_output;
114
-    
115
-    static bool pid_reset;
116
-    static float HeaterPower;
117
-    
118
-  #endif //PIDTEMP
119
-
120
-public: //but only accesed from the ISR hence not volatile
121
-   #ifdef MINTEMP
122
-  static int minttemp;
123
-  #endif //MINTEMP
124
-  #ifdef MAXTEMP
125
-  static int maxttemp;
126
-  #endif //MAXTEMP
127
-
128
-  #ifdef BED_MINTEMP
129
-  static int bed_minttemp ;
130
-  #endif //BED_MINTEMP
131
-  #ifdef BED_MAXTEMP
132
-  static int bed_maxttemp;
133
-  #endif //BED_MAXTEMP
134
-  
135
-};
136
-
137
-extern Heater htr; //this creates the single, global instance 
28
+void tp_init();
29
+void manage_heater();
30
+//int temp2analogu(int celsius, const short table[][2], int numtemps);
31
+//float analog2tempu(int raw, const short table[][2], int numtemps);
32
+float temp2analog(int celsius);
33
+float temp2analogBed(int celsius);
34
+float analog2temp(int raw);
35
+float analog2tempBed(int raw);
138
 
36
 
139
 #ifdef HEATER_USES_THERMISTOR
37
 #ifdef HEATER_USES_THERMISTOR
140
     #define HEATERSOURCE 1
38
     #define HEATERSOURCE 1
143
     #define BEDSOURCE 1
41
     #define BEDSOURCE 1
144
 #endif
42
 #endif
145
 
43
 
44
+//#define temp2analogh( c ) temp2analogu((c),temptable,NUMTEMPS)
45
+//#define analog2temp( c ) analog2tempu((c),temptable,NUMTEMPS
46
+
47
+
48
+extern float Kp;
49
+extern float Ki;
50
+extern float Kd;
51
+extern float Kc;
52
+
53
+enum {TEMPSENSOR_HOTEND=0,TEMPSENSOR_BED=1, TEMPSENSOR_AUX=2};
54
+extern int target_raw[3];
55
+extern int current_raw[3];
56
+extern double pid_setpoint;
146
 
57
 
147
 #endif
58
 #endif

+ 43
- 47
Marlin/ultralcd.pde View File

1
 #include "ultralcd.h"
1
 #include "ultralcd.h"
2
-#include "temperature.h"
2
+
3
 
3
 
4
 #ifdef ULTRA_LCD
4
 #ifdef ULTRA_LCD
5
 extern volatile int feedmultiply;
5
 extern volatile int feedmultiply;
238
 void MainMenu::showStatus()
238
 void MainMenu::showStatus()
239
 { 
239
 { 
240
 #if LCD_HEIGHT==4
240
 #if LCD_HEIGHT==4
241
-  static int oldcurrent=-1;
242
-  static int oldtarget=-1;
241
+  static int oldcurrentraw=-1;
242
+  static int oldtargetraw=-1;
243
   //force_lcd_update=true;
243
   //force_lcd_update=true;
244
   if(force_lcd_update||feedmultiplychanged)  //initial display of content
244
   if(force_lcd_update||feedmultiplychanged)  //initial display of content
245
   {
245
   {
252
 #endif
252
 #endif
253
   }
253
   }
254
     
254
     
255
-  int tt=Heater::celsius(TEMPSENSOR_HOTEND);
256
-  if((abs(tt-oldcurrent)>1)||force_lcd_update)
255
+
256
+  if((abs(current_raw[TEMPSENSOR_HOTEND]-oldcurrentraw)>3)||force_lcd_update)
257
   {
257
   {
258
     lcd.setCursor(1,0);
258
     lcd.setCursor(1,0);
259
-    lcd.print(ftostr3(tt));
260
-    oldcurrent=tt;
259
+    lcd.print(ftostr3(analog2temp(current_raw[TEMPSENSOR_HOTEND])));
260
+    oldcurrentraw=current_raw[TEMPSENSOR_HOTEND];
261
   }
261
   }
262
-  int ttg=Heater::celsiusTarget(TEMPSENSOR_HOTEND);
263
-  if((ttg!=oldtarget)||force_lcd_update)
262
+  if((target_raw[TEMPSENSOR_HOTEND]!=oldtargetraw)||force_lcd_update)
264
   {
263
   {
265
     lcd.setCursor(5,0);
264
     lcd.setCursor(5,0);
266
-    lcd.print(ftostr3(ttg));
267
-    oldtarget=ttg;
265
+    lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND])));
266
+    oldtargetraw=target_raw[TEMPSENSOR_HOTEND];
268
   }
267
   }
269
   #if defined BED_USES_THERMISTOR || defined BED_USES_AD595 
268
   #if defined BED_USES_THERMISTOR || defined BED_USES_AD595 
270
-  static int oldcurrentbed=-1;
271
-  static int oldtargetbed=-1;
272
-  int tb=Heater::celsius(TEMPSENSOR_BED);
273
-  if((tb!=oldcurrentbed)||force_lcd_update)
269
+  static int oldcurrentbedraw=-1;
270
+  static int oldtargetbedraw=-1; 
271
+  if((current_bed_raw!=oldcurrentbedraw)||force_lcd_update)
274
   {
272
   {
275
     lcd.setCursor(1,0);
273
     lcd.setCursor(1,0);
276
-    lcd.print(ftostr3(tb));
277
-    oldcurrentbed=tb;
274
+    lcd.print(ftostr3(analog2temp(current_bed_raw)));
275
+    oldcurrentraw=current_raw[TEMPSENSOR_BED];
278
   }
276
   }
279
-  int tg=Heater::celsiusTarget(TEMPSENSOR_BED);
280
-  if((tg!=oldtargebed)||force_lcd_update)
277
+  if((target_bed_raw!=oldtargebedtraw)||force_lcd_update)
281
   {
278
   {
282
     lcd.setCursor(5,0);
279
     lcd.setCursor(5,0);
283
-    lcd.print(Heater::celsiusTarget(TEMPSENSOR_BED));
284
-    oldtargebed=tg;
280
+    lcd.print(ftostr3(analog2temp(target_bed_raw)));
281
+    oldtargetraw=target_bed_raw;
285
   }
282
   }
286
   #endif
283
   #endif
287
   //starttime=2;
284
   //starttime=2;
330
     messagetext[0]='\0';
327
     messagetext[0]='\0';
331
   }
328
   }
332
 #else //smaller LCDS----------------------------------
329
 #else //smaller LCDS----------------------------------
333
-  static int oldcurrent=-1;
334
-  static int oldtarget=-1;
330
+  static int oldcurrentraw=-1;
331
+  static int oldtargetraw=-1;
335
   if(force_lcd_update)  //initial display of content
332
   if(force_lcd_update)  //initial display of content
336
   {
333
   {
337
     encoderpos=feedmultiply;
334
     encoderpos=feedmultiply;
341
     #endif
338
     #endif
342
   }
339
   }
343
     
340
     
344
-  int tt=Heater::celsius(TEMPSENSOR_HOTEND);
345
-  if((abs(tt-oldcurrent)>1)||force_lcd_update)
341
+
342
+  if((abs(current_raw[TEMPSENSOR_HOTEND]-oldcurrentraw)>3)||force_lcd_update)
346
   {
343
   {
347
     lcd.setCursor(1,0);
344
     lcd.setCursor(1,0);
348
-    lcd.print(ftostr3(tt));
349
-    oldcurrent=tt;
345
+    lcd.print(ftostr3(analog2temp(current_raw[TEMPSENSOR_HOTEND])));
346
+    oldcurrentraw=current_raw[TEMPSENSOR_HOTEND];
350
   }
347
   }
351
-  int ttg=Heater::celsiusTarget(TEMPSENSOR_HOTEND);
352
-  if((ttg!=oldtarget)||force_lcd_update)
348
+  if((target_raw[TEMPSENSOR_HOTEND]!=oldtargetraw)||force_lcd_update)
353
   {
349
   {
354
     lcd.setCursor(5,0);
350
     lcd.setCursor(5,0);
355
-    lcd.print(ftostr3(ttg));
356
-    oldtarge=ttg;
351
+    lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND])));
352
+    oldtargetraw=target_raw[TEMPSENSOR_HOTEND];
357
   }
353
   }
358
 
354
 
359
   if(messagetext[0]!='\0')
355
   if(messagetext[0]!='\0')
430
         if((activeline==line) && CLICKED)
426
         if((activeline==line) && CLICKED)
431
         {
427
         {
432
           BLOCK
428
           BLOCK
433
-          Heater::setCelsius(TEMPSENSOR_HOTEND, 170);
429
+          target_raw[TEMPSENSOR_HOTEND] = temp2analog(170);
434
           beepshort();
430
           beepshort();
435
         }
431
         }
436
       }break;
432
       }break;
535
         if(force_lcd_update)
531
         if(force_lcd_update)
536
         {
532
         {
537
           lcd.setCursor(0,line);lcd.print(" \002Nozzle:");
533
           lcd.setCursor(0,line);lcd.print(" \002Nozzle:");
538
-          lcd.setCursor(13,line);lcd.print(ftostr3(Heater::celsiusTarget(TEMPSENSOR_HOTEND)));
534
+          lcd.setCursor(13,line);lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND])));
539
         }
535
         }
540
         
536
         
541
         if((activeline==line) )
537
         if((activeline==line) )
545
             linechanging=!linechanging;
541
             linechanging=!linechanging;
546
             if(linechanging)
542
             if(linechanging)
547
             {
543
             {
548
-               encoderpos=(int)Heater::celsiusTarget(TEMPSENSOR_HOTEND);
544
+               encoderpos=(int)analog2temp(target_raw[TEMPSENSOR_HOTEND]);
549
             }
545
             }
550
             else
546
             else
551
             {
547
             {
552
-              Heater::setCelsius(TEMPSENSOR_HOTEND,encoderpos);
548
+              target_raw[TEMPSENSOR_HOTEND] = temp2analog(encoderpos);
553
               encoderpos=activeline*lcdslow;
549
               encoderpos=activeline*lcdslow;
554
               beepshort();
550
               beepshort();
555
             }
551
             }
673
       if(force_lcd_update)
669
       if(force_lcd_update)
674
         {
670
         {
675
           lcd.setCursor(0,line);lcd.print(" PID-P: ");
671
           lcd.setCursor(0,line);lcd.print(" PID-P: ");
676
-          lcd.setCursor(13,line);lcd.print(itostr4(Heater::Kp));
672
+          lcd.setCursor(13,line);lcd.print(itostr4(Kp));
677
         }
673
         }
678
         
674
         
679
         if((activeline==line) )
675
         if((activeline==line) )
683
             linechanging=!linechanging;
679
             linechanging=!linechanging;
684
             if(linechanging)
680
             if(linechanging)
685
             {
681
             {
686
-               encoderpos=(int)Heater::Kp/5;
682
+               encoderpos=(int)Kp/5;
687
             }
683
             }
688
             else
684
             else
689
             {
685
             {
690
-              Heater::Kp= encoderpos*5;
686
+              Kp= encoderpos*5;
691
               encoderpos=activeline*lcdslow;
687
               encoderpos=activeline*lcdslow;
692
                 
688
                 
693
             }
689
             }
707
       if(force_lcd_update)
703
       if(force_lcd_update)
708
         {
704
         {
709
           lcd.setCursor(0,line);lcd.print(" PID-I: ");
705
           lcd.setCursor(0,line);lcd.print(" PID-I: ");
710
-          lcd.setCursor(13,line);lcd.print(ftostr51(Heater::Ki));
706
+          lcd.setCursor(13,line);lcd.print(ftostr51(Ki));
711
         }
707
         }
712
         
708
         
713
         if((activeline==line) )
709
         if((activeline==line) )
717
             linechanging=!linechanging;
713
             linechanging=!linechanging;
718
             if(linechanging)
714
             if(linechanging)
719
             {
715
             {
720
-               encoderpos=(int)(Heater::Ki*10);
716
+               encoderpos=(int)(Ki*10);
721
             }
717
             }
722
             else
718
             else
723
             {
719
             {
724
-              Heater::Ki= encoderpos/10.;
720
+              Ki= encoderpos/10.;
725
               encoderpos=activeline*lcdslow;
721
               encoderpos=activeline*lcdslow;
726
                 
722
                 
727
             }
723
             }
741
       if(force_lcd_update)
737
       if(force_lcd_update)
742
         {
738
         {
743
           lcd.setCursor(0,line);lcd.print(" PID-D: ");
739
           lcd.setCursor(0,line);lcd.print(" PID-D: ");
744
-          lcd.setCursor(13,line);lcd.print(itostr4(Heater::Kd));
740
+          lcd.setCursor(13,line);lcd.print(itostr4(Kd));
745
         }
741
         }
746
         
742
         
747
         if((activeline==line) )
743
         if((activeline==line) )
751
             linechanging=!linechanging;
747
             linechanging=!linechanging;
752
             if(linechanging)
748
             if(linechanging)
753
             {
749
             {
754
-               encoderpos=(int)(Heater::Kd/5.);
750
+               encoderpos=(int)Kd/5;
755
             }
751
             }
756
             else
752
             else
757
             {
753
             {
758
-              Heater::Kd= encoderpos*5;
754
+              Kd= encoderpos*5;
759
               encoderpos=activeline*lcdslow;
755
               encoderpos=activeline*lcdslow;
760
                 
756
                 
761
             }
757
             }
778
       if(force_lcd_update)
774
       if(force_lcd_update)
779
         {
775
         {
780
           lcd.setCursor(0,line);lcd.print(" PID-C: ");
776
           lcd.setCursor(0,line);lcd.print(" PID-C: ");
781
-          lcd.setCursor(13,line);lcd.print(itostr3(Heater::Kc));
777
+          lcd.setCursor(13,line);lcd.print(itostr3(Kc));
782
         }
778
         }
783
         
779
         
784
         if((activeline==line) )
780
         if((activeline==line) )
788
             linechanging=!linechanging;
784
             linechanging=!linechanging;
789
             if(linechanging)
785
             if(linechanging)
790
             {
786
             {
791
-               encoderpos=(int)Heater::Kc;
787
+               encoderpos=(int)Kc;
792
             }
788
             }
793
             else
789
             else
794
             {
790
             {
795
-              Heater::Kc= encoderpos;
791
+              Kc= encoderpos;
796
               encoderpos=activeline*lcdslow;
792
               encoderpos=activeline*lcdslow;
797
                 
793
                 
798
             }
794
             }

Loading…
Cancel
Save