Skip to content
Snippets Groups Projects
Commit c57906b6 authored by Bernhard Kubicek's avatar Bernhard Kubicek
Browse files

fixed bug with adjusting ki in realtime.

parent 9980ceb4
No related branches found
No related tags found
No related merge requests found
...@@ -95,11 +95,11 @@ ...@@ -95,11 +95,11 @@
// PID_SWING_AT_CRITIAL is the time for a full period of the oscillations at the critical Gain // PID_SWING_AT_CRITIAL is the time for a full period of the oscillations at the critical Gain
// usually further manual tunine is necessary. // usually further manual tunine is necessary.
#define PID_CRITIAL_GAIN 3000 #define PID_CRITIAL_GAIN 50
#define PID_SWING_AT_CRITIAL 45 //seconds #define PID_SWING_AT_CRITIAL 47 //seconds
#define PID_PI //no differentail term //#define PID_PI //no differentail term
//#define PID_PID //normal PID #define PID_PID //normal PID
#ifdef PID_PID #ifdef PID_PID
//PID according to Ziegler-Nichols method //PID according to Ziegler-Nichols method
... ...
......
...@@ -898,12 +898,16 @@ inline void process_commands() ...@@ -898,12 +898,16 @@ inline void process_commands()
#ifdef PIDTEMP #ifdef PIDTEMP
case 301: // M301 case 301: // M301
{
if(code_seen('P')) Kp = code_value(); if(code_seen('P')) Kp = code_value();
if(code_seen('I')) Ki = code_value()*PID_dT; if(code_seen('I')) Ki = code_value()*PID_dT;
if(code_seen('D')) Kd = code_value()/PID_dT; if(code_seen('D')) Kd = code_value()/PID_dT;
#ifdef PID_ADD_EXTRUSION_RATE #ifdef PID_ADD_EXTRUSION_RATE
if(code_seen('C')) Kc = code_value(); if(code_seen('C')) Kc = code_value();
#endif #endif
updatePID();
SERIAL_PROTOCOL("ok p:"); SERIAL_PROTOCOL("ok p:");
SERIAL_PROTOCOL(Kp); SERIAL_PROTOCOL(Kp);
SERIAL_PROTOCOL(" i:"); SERIAL_PROTOCOL(" i:");
...@@ -915,7 +919,7 @@ inline void process_commands() ...@@ -915,7 +919,7 @@ inline void process_commands()
SERIAL_PROTOCOL(Kc*PID_dT); SERIAL_PROTOCOL(Kc*PID_dT);
#endif #endif
SERIAL_PROTOCOLLN(""); SERIAL_PROTOCOLLN("");
}
break; break;
#endif //PIDTEMP #endif //PIDTEMP
case 400: // finish all moves case 400: // finish all moves
... ...
......
...@@ -111,6 +111,13 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater; ...@@ -111,6 +111,13 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
//=============================functions ============================ //=============================functions ============================
//=========================================================================== //===========================================================================
void updatePID()
{
#ifdef PIDTEMP
temp_iState_max = PID_INTEGRAL_DRIVE_MAX / Ki;
#endif
}
void manage_heater() void manage_heater()
{ {
#ifdef USE_WATCHDOG #ifdef USE_WATCHDOG
... ...
......
...@@ -87,6 +87,7 @@ inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMP ...@@ -87,6 +87,7 @@ inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMP
void disable_heater(); void disable_heater();
void setWatch(); void setWatch();
void updatePID();
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment