chiark / gitweb /
lcd panel bed support
authorBernhard <bkubicek@x201.(none)>
Thu, 22 Dec 2011 10:45:52 +0000 (11:45 +0100)
committerBernhard <bkubicek@x201.(none)>
Thu, 22 Dec 2011 10:45:52 +0000 (11:45 +0100)
advance and ultipanel not any more in default config

Marlin/Configuration.h
Marlin/cardreader.pde
Marlin/pins.h
Marlin/temperature.cpp
Marlin/temperature.h
Marlin/ultralcd.pde

index 58f5bcaeaf8d61b8e1b22697b7bb99aab6560973..3215a09c9713d91ff7a9bccc8c21b7fed69ae0e5 100644 (file)
 // Select one of these only to define how the bed temp is read.
 //#define THERMISTORBED 1
 //#define BED_USES_THERMISTOR
+//#define BED_LIMIT_SWITCHING
+#ifdef BED_LIMIT_SWITCHING
+  #define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
+#endif
 //#define BED_USES_AD595
 
 #define BED_CHECK_INTERVAL 5000 //ms
 #define EXTRUDER_RUNOUT_SECONDS 30.
 #define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament
 #define EXTRUDER_RUNOUT_SPEED 1500.  //extrusion speed
+#define EXTRUDER_RUNOUT_EXTRUDE 100
 
 
 //===========================================================================
@@ -296,7 +301,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
 // hooke's law says:           force = k * distance
 // bernoulli's priniciple says:        v ^ 2 / 2 + g . h + pressure / density = constant
 // so: v ^ 2 is proportional to number of steps we advance the extruder
-#define ADVANCE
+//#define ADVANCE
 
 #ifdef ADVANCE
   #define EXTRUDER_ADVANCE_K .0
@@ -315,7 +320,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y E" // no z because of layer shift.
 
-#define ULTIPANEL
+//#define ULTIPANEL
 #ifdef ULTIPANEL
   //#define NEWPANEL  //enable this if you have a click-encoder panel
   #define SDSUPPORT
index 0c346e1ead8b7d99a4b6348cb7d3177e251fb976..a5044f8d33444cbde5f50c2169bd1bf893628c7a 100644 (file)
@@ -432,6 +432,7 @@ void CardReader::updir()
 
 void CardReader::printingHasFinished()
 {
+ st_synchronize();
  quickStop();
  sdprinting = false;
  stop_heating_wait=true;
index 4ec22793ecd2c5c4f045bcfc848de20dd136ed44..6451d7425006e95db969092cccd45df6277f897b 100644 (file)
 #define Z_ENABLE_PIN 35
 
 #define HEATER_BED_PIN 4 
-#define TEMP_BED_PIN 11  
+#define TEMP_BED_PIN 10  
 
 #define HEATER_0_PIN  2
 #define TEMP_0_PIN 8   
                         HEATER_BED_PIN, FAN_PIN,                  \
                         _E0_PINS, _E1_PINS, _E2_PINS,             \
                         TEMP_0_PIN, TEMP_1_PIN, TEMP_2_PIN, TEMP_BED_PIN }
-#endif\r
+#endif
index ba116c7aa3ca07f1cbab496158f8a6de63a1cdfa..e6c352fdff7585eab6a9240abd6c5ca70500be09 100644 (file)
 //===========================================================================
 int target_raw[EXTRUDERS] = { 0 };
 int target_raw_bed = 0;
+#ifdef BED_LIMIT_SWITCHING
+int target_bed_low_temp =0;  
+int target_bed_high_temp =0;
+#endif
 int current_raw[EXTRUDERS] = { 0 };
 int current_raw_bed = 0;
 
@@ -233,20 +237,39 @@ void manage_heater()
   previous_millis_bed_heater = millis();
   
   #if TEMP_BED_PIN > -1
-    // Check if temperature is within the correct range
-    if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) {
-      if(current_raw_bed >= target_raw_bed)
-      {
+  
+    #ifndef BED_LIMIT_SWITCHING
+      // Check if temperature is within the correct range
+      if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) {
+        if(current_raw_bed >= target_raw_bed)
+        {
+          WRITE(HEATER_BED_PIN,LOW);
+        }
+        else 
+        {
+          WRITE(HEATER_BED_PIN,HIGH);
+        }
+      }
+      else {
         WRITE(HEATER_BED_PIN,LOW);
       }
-      else 
-      {
-        WRITE(HEATER_BED_PIN,HIGH);
+    #else //#ifdef BED_LIMIT_SWITCHING
+      // Check if temperature is within the correct band
+      if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) {
+        if(current_raw_bed > target_bed_high_temp)
+        {
+          WRITE(HEATER_BED_PIN,LOW);
+        }
+        else 
+          if(current_raw_bed <= target_bed_low_temp)
+        {
+          WRITE(HEATER_BED_PIN,HIGH);
+        }
       }
-    }
-    else {
-      WRITE(HEATER_BED_PIN,LOW);
-    }  
+      else {
+        WRITE(HEATER_BED_PIN,LOW);
+      }
+    #endif
   #endif
 }
 
@@ -520,6 +543,9 @@ void setWatch()
 
 void disable_heater()
 {
+  for(int i=0;i<EXTRUDERS;i++)
+    setTargetHotend(0,i);
+  setTargetBed(0);
   #if TEMP_0_PIN > -1
   target_raw[0]=0;
   soft_pwm[0]=0;
index f8b09649f572e7dfed9993f55e7d65dcf06ea7d7..8e1deac8fe3e0c3b5292b7d3c70d422878bd09b7 100644 (file)
@@ -43,6 +43,10 @@ extern int heatingtarget_raw[EXTRUDERS];
 extern int current_raw[EXTRUDERS];\r
 extern int target_raw_bed;\r
 extern int current_raw_bed;\r
+#ifdef BED_LIMIT_SWITCHING\r
+  extern int target_bed_low_temp ;  \r
+  extern int target_bed_high_temp ;\r
+#endif\r
 extern float Kp,Ki,Kd,Kc;\r
 \r
 #ifdef PIDTEMP\r
@@ -83,7 +87,20 @@ FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {
 };\r
 \r
 FORCE_INLINE void setTargetBed(const float &celsius) {  \r
+  \r
   target_raw_bed = temp2analogBed(celsius);\r
+  #ifdef BED_LIMIT_SWITCHING\r
+    if(celsius>BED_HYSTERESIS)\r
+    {\r
+    target_bed_low_temp= temp2analogBed(celsius-BED_HYSTERESIS);\r
+    target_bed_high_temp= temp2analogBed(celsius+BED_HYSTERESIS);\r
+    }\r
+    else\r
+    { \r
+      target_bed_low_temp=0;\r
+      target_bed_high_temp=0;\r
+    }\r
+  #endif\r
 };\r
 \r
 FORCE_INLINE bool isHeatingHotend(uint8_t extruder){  \r
@@ -125,6 +142,13 @@ FORCE_INLINE bool isCoolingBed() {
 #error Invalid number of extruders\r
 #endif\r
 \r
+\r
+\r
+int getHeaterPower(int heater);\r
+void disable_heater();\r
+void setWatch();\r
+void updatePID();\r
+\r
 FORCE_INLINE void autotempShutdown(){\r
  #ifdef AUTOTEMP\r
  if(autotemp_enabled)\r
@@ -135,11 +159,5 @@ FORCE_INLINE void autotempShutdown(){
  }\r
  #endif\r
 }\r
-\r
-int getHeaterPower(int heater);\r
-void disable_heater();\r
-void setWatch();\r
-void updatePID();\r
-\r
 #endif\r
 \r
index 3b7663beb9674345623310b1588f09013d30eb4c..947ec3dac9677c3032d54229c358522a41c21eed 100644 (file)
@@ -165,8 +165,13 @@ void lcd_status()
     //previous_millis_buttons=millis();
     long ms=millis();
     for(int8_t i=0; i<8; i++) {
+      #ifndef NEWPANEL
       if((blocking[i]>ms))
         buttons &= ~(1<<i);
+      #else
+      if((blocking>ms))
+        buttons &= ~(1<<i);        
+      #endif
     }
     if((buttons==oldbuttons) &&  ((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL)   )
       return;
@@ -326,14 +331,14 @@ void MainMenu::showStatus()
     int tBed=intround(degBed());
     if((tBed!=oldtBed)||force_lcd_update)
     {
-      lcd.setCursor(1,0);
+      lcd.setCursor(11,0);
       lcd.print(ftostr3(tBed));
       oldtBed=tBed;
     }
     int targetBed=intround(degTargetBed());
     if((targetBed!=oldtargetBed)||force_lcd_update)
     {
-      lcd.setCursor(5,0);
+      lcd.setCursor(15,0);
       lcd.print(ftostr3(targetBed));
       oldtargetBed=targetBed;
     }
@@ -352,11 +357,11 @@ void MainMenu::showStatus()
     }
   }
   static int oldzpos=0;
-  int currentz=current_position[2]*10;
+  int currentz=current_position[2]*100;
   if((currentz!=oldzpos)||force_lcd_update)
   {
     lcd.setCursor(10,1);
-    lcdprintPGM("Z:");lcd.print(itostr31(currentz));
+    lcdprintPGM("Z:");lcd.print(ftostr32(current_position[2]));
     oldzpos=currentz;
   }
   static int oldfeedmultiply=0;
@@ -490,7 +495,11 @@ void MainMenu::showPrepare()
  updateActiveLines(ItemP_extrude,encoderpos);
 }
 
-enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,ItemT_fan};
+enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,
+#if (HEATER_BED_PIN > -1)
+ItemT_bed,
+#endif
+ItemT_fan};
 
 void MainMenu::showTune()
 { 
@@ -572,6 +581,42 @@ void MainMenu::showTune()
           lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
         }
       }break;
+      #if (HEATER_BED_PIN > -1)
+      case ItemT_bed:
+      {
+        if(force_lcd_update)
+        {
+          lcd.setCursor(0,line);lcdprintPGM(" \002Bed:");
+          lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
+        }
+        
+        if((activeline!=line) )
+          break;
+        
+        if(CLICKED)
+        {
+          linechanging=!linechanging;
+          if(linechanging)
+          {
+              encoderpos=intround(degTargetBed());
+          }
+          else
+          {
+            setTargetBed(encoderpos);
+            encoderpos=activeline*lcdslow;
+            beepshort();
+          }
+          BLOCK;
+        }
+        if(linechanging)
+        {
+          if(encoderpos<0) encoderpos=0;
+          if(encoderpos>260) encoderpos=260;
+          lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
+        }
+      }break;
+      #endif
+
       
       case ItemT_fan:
       {
@@ -677,6 +722,9 @@ enum {
   ItemCT_autotempactive,
   ItemCT_autotempmin,ItemCT_autotempmax,ItemCT_autotempfact,
 #endif
+#if (HEATER_BED_PIN > -1)
+ItemCT_bed,
+#endif  
   ItemCT_fan,
   ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C
 };
@@ -857,6 +905,41 @@ void MainMenu::showControlTemp()
         
       }break;  
       #endif //autotemp
+      #if (HEATER_BED_PIN > -1)
+      case ItemCT_bed:
+      {
+        if(force_lcd_update)
+        {
+          lcd.setCursor(0,line);lcdprintPGM(" \002Bed:");
+          lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
+        }
+        
+        if((activeline!=line) )
+          break;
+        
+        if(CLICKED)
+        {
+          linechanging=!linechanging;
+          if(linechanging)
+          {
+              encoderpos=intround(degTargetBed());
+          }
+          else
+          {
+            setTargetBed(encoderpos);
+            encoderpos=activeline*lcdslow;
+            beepshort();
+          }
+          BLOCK;
+        }
+        if(linechanging)
+        {
+          if(encoderpos<0) encoderpos=0;
+          if(encoderpos>260) encoderpos=260;
+          lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
+        }
+      }break;
+      #endif
       case ItemCT_fan:
       {
         if(force_lcd_update)