chiark / gitweb /
minor changes and first not-well working version of autotemp
authorBernhard Kubicek <kubicek@gmx.at>
Wed, 9 Nov 2011 21:09:16 +0000 (22:09 +0100)
committerBernhard Kubicek <kubicek@gmx.at>
Wed, 9 Nov 2011 21:09:16 +0000 (22:09 +0100)
Marlin/Configuration.h
Marlin/EEPROMwrite.h
Marlin/Marlin.h
Marlin/Marlin.pde
Marlin/planner.cpp
Marlin/planner.h
Marlin/ultralcd.pde

index f44c858b9a81e3e6f191e150a761355ba6948680..8661ae438e78afd285434d87752b0b730f3fb0a5 100644 (file)
   // if Kc is choosen well, the additional required power due to increased melting should be compensated.
   #define PID_ADD_EXTRUSION_RATE  
   #ifdef PID_ADD_EXTRUSION_RATE
-    #define  DEFAULT_Kc (5) //heatingpower=Kc*(e_speed)
+    #define  DEFAULT_Kc (3) //heatingpower=Kc*(e_speed)
   #endif
 #endif // PIDTEMP
 
@@ -275,6 +275,16 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
 #define N_ARC_CORRECTION 25
 
 
+//automatic temperature: just for testing, this is very dangerous, keep disabled!
+// not working yet.
+//Erik: the settings currently depend dramatically on skeinforge39 or 41.
+//#define AUTOTEMP
+#define AUTOTEMP_MIN 190
+#define AUTOTEMP_MAX 260
+#define AUTOTEMP_FACTOR 1000.  //current target temperature= min+largest buffered espeeds)*FACTOR
+
+
+
 const int dropsegments=0; //everything with less than this number of steps  will be ignored as move and joined with the next movement
 
 //===========================================================================
index fcb3d8d3914cc3fa41cb31ac4ba9b9bc27173062..3d8a0b2b9eb2a9e4ef0712f460ac0ee59d5d7ee4 100644 (file)
@@ -25,7 +25,6 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
 }
 //======================================================================================
 
-#define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
 
 
 
index 1e36b61e88d1e8c7b027d628e0523aaafd9110b2..e14471264f24a01b3845089301d8030158e12e8c 100644 (file)
@@ -35,6 +35,9 @@ const char echomagic[] PROGMEM ="echo:";
 #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
 #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
 
+#define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
+
+
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
 #define SerialprintPGM(x) serialprintPGM(PSTR(x))
 inline void serialprintPGM(const char *str)
index dee095d84fd9dbbf5553d00d7e079f7b1460457d..672591a72d1aa0ea81b982eb7363f117663f50d5 100644 (file)
@@ -211,7 +211,6 @@ void setup()
 { 
   Serial.begin(BAUDRATE);
   SERIAL_ECHO_START;
-  SERIAL_ECHOPGM("Marlin ");
   SERIAL_ECHOLN(version_string);
   SERIAL_PROTOCOLLNPGM("start");
   SERIAL_ECHO_START;
@@ -785,8 +784,8 @@ inline void process_commands()
       }
       else
       { 
-        LCD_MESSAGEPGM("Free move.");
         st_synchronize(); 
+        LCD_MESSAGEPGM("Free move.");
         disable_x(); 
         disable_y(); 
         disable_z(); 
index 34e29ff53561c41ff4fbb0477fb7378ec8e93f68..863b116a5bc5fbf5e4d742663486dc5791702260 100644 (file)
@@ -84,6 +84,10 @@ unsigned long axis_steps_per_sqr_second[NUM_AXIS];
 // The current position of the tool in absolute steps\r
 long position[4];   //rescaled from extern when axis_steps_per_unit are changed by gcode\r
 \r
+#ifdef AUTOTEMP\r
+float high_e_speed=0;\r
+#endif\r
+\r
 \r
 //===========================================================================\r
 //=============================private variables ============================\r
@@ -363,6 +367,34 @@ block_t *plan_get_current_block() {
   return(block);\r
 }\r
 \r
+#ifdef AUTOTEMP\r
+void getHighESpeed()\r
+{\r
+  if(degTargetHotend0()+2<AUTOTEMP_MIN)  //probably temperature set to zero.\r
+    return; //do nothing\r
+  float high=0;\r
+  char block_index = block_buffer_tail;\r
+  \r
+  while(block_index != block_buffer_head) {\r
+    float se=block_buffer[block_index].speed_e;\r
+    if(se>high)\r
+    {\r
+      high=se;\r
+    }\r
+    block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);\r
+  }\r
+  high_e_speed=high*axis_steps_per_unit[E_AXIS]/(1000000.0);  //so it is independent of the esteps/mm. before \r
+   \r
+  float g=AUTOTEMP_MIN+high_e_speed*AUTOTEMP_FACTOR;\r
+  float t=constrain(AUTOTEMP_MIN,g,AUTOTEMP_MAX);\r
+  setTargetHotend0(t);\r
+  SERIAL_ECHO_START;\r
+  SERIAL_ECHOPAIR("highe",high_e_speed);\r
+  SERIAL_ECHOPAIR(" t",t);\r
+  SERIAL_ECHOLN("");\r
+}\r
+#endif\r
+\r
 void check_axes_activity() {\r
   unsigned char x_active = 0;\r
   unsigned char y_active = 0;  \r
@@ -581,6 +613,9 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
   memcpy(position, target, sizeof(target)); // position[] = target[]\r
 \r
   planner_recalculate();\r
+  #ifdef AUTOTEMP\r
+    getHighESpeed();\r
+  #endif\r
   st_wake_up();\r
 }\r
 \r
index 79f54d879f8d2b874dfa315be5ffbd77c52cda9d..c5bc5b8aaf456d8f7bc90ad6d2e01bc33037a19c 100644 (file)
@@ -89,5 +89,7 @@ extern float max_xy_jerk; //speed than can be stopped at once, if i understand c
 extern float max_z_jerk;\r
 extern float mintravelfeedrate;\r
 extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];\r
-\r
+#ifdef AUTOTEMP\r
+extern float high_e_speed;\r
+#endif\r
 #endif\r
index 59edb34702cd0c0cb739d90f133c07e4075aa470..d95167166d43c1f902ad9c14291f29c7138b1a09 100644 (file)
@@ -71,10 +71,12 @@ void lcd_statuspgm(const char* message)
 {\r
   char ch=pgm_read_byte(message);\r
   char *target=messagetext;\r
-  while(ch)\r
+  uint8_t cnt=0;\r
+  while(ch &&cnt<LCD_WIDTH)\r
   {\r
     *target=ch;\r
     target++;\r
+    cnt++;\r
     ch=pgm_read_byte(++message);\r
   }\r
 }\r