diff options
author | midopple <mdoppler@gmx.at> | 2012-08-27 17:35:54 +0200 |
---|---|---|
committer | midopple <mdoppler@gmx.at> | 2012-08-27 17:35:54 +0200 |
commit | e206720abfb5d14ae7d5d3505e458cbdc6c87ae8 (patch) | |
tree | dc90a557ba44f91c33b88d5b50842fdd6d0c3b52 /Sprinter | |
parent | 3e6cce46ae7d1f3d79fd486761ccd6f28e6d7f3e (diff) |
M303 Autotune use HEATER_CURRENT for Maximum PWM Value
Diffstat (limited to 'Sprinter')
-rw-r--r-- | Sprinter/Configuration.h | 2 | ||||
-rw-r--r-- | Sprinter/heater.cpp | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Sprinter/Configuration.h b/Sprinter/Configuration.h index aca24e1..3d7a399 100644 --- a/Sprinter/Configuration.h +++ b/Sprinter/Configuration.h @@ -308,7 +308,7 @@ const int dropsegments=5; //everything with less than this number of steps will #define LED_PWM_FOR_BRIGHTNESS(brightness) ((64*brightness-1384)/(300-brightness)) #endif -// Change this value (range 1-255) to limit the current to the nozzle +// Change this value (range 30-255) to limit the current to the nozzle #define HEATER_CURRENT 255 // How often should the heater check for new temp readings, in milliseconds diff --git a/Sprinter/heater.cpp b/Sprinter/heater.cpp index 8283373..119e547 100644 --- a/Sprinter/heater.cpp +++ b/Sprinter/heater.cpp @@ -314,7 +314,7 @@ void PID_autotune(int PIDAT_test_temp) float PIDAT_max, PIDAT_min; - unsigned char PIDAT_PWM_val = 255; + unsigned char PIDAT_PWM_val = HEATER_CURRENT; unsigned char PIDAT_cycles=0; bool PIDAT_heating = true; @@ -329,8 +329,8 @@ void PID_autotune(int PIDAT_test_temp) long PIDAT_t_high; long PIDAT_t_low; - long PIDAT_bias= 127; - long PIDAT_d = 127; + long PIDAT_bias= HEATER_CURRENT/2; + long PIDAT_d = HEATER_CURRENT/2; float PIDAT_Ku, PIDAT_Tu; float PIDAT_Kp, PIDAT_Ki, PIDAT_Kd; @@ -404,8 +404,8 @@ void PID_autotune(int PIDAT_test_temp) if(PIDAT_cycles > 0) { PIDAT_bias += (PIDAT_d*(PIDAT_t_high - PIDAT_t_low))/(PIDAT_t_low + PIDAT_t_high); - PIDAT_bias = constrain(PIDAT_bias, 20 ,235); - if(PIDAT_bias > 127) PIDAT_d = 254 - PIDAT_bias; + PIDAT_bias = constrain(PIDAT_bias, 20 ,HEATER_CURRENT - 20); + if(PIDAT_bias > (HEATER_CURRENT/2)) PIDAT_d = (HEATER_CURRENT - 1) - PIDAT_bias; else PIDAT_d = PIDAT_bias; showString(PSTR(" bias: ")); Serial.print(PIDAT_bias); @@ -466,7 +466,7 @@ void PID_autotune(int PIDAT_test_temp) #endif } - if(PIDAT_input > (PIDAT_test_temp + 20)) + if(PIDAT_input > (PIDAT_test_temp + 25)) { showString(PSTR("PID Autotune failed! Temperature to high\r\n")); return; |