cleanup for pull

This commit is contained in:
Mark Finn 2012-09-17 14:17:24 -05:00
parent 0a5ad3ab85
commit 04631d2250
3 changed files with 54 additions and 25 deletions

View File

@ -95,7 +95,6 @@
// PID settings: // PID settings:
// Comment the following line to disable PID and enable bang-bang. // Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP #define PIDTEMP
#define PIDTEMPBED
#define PID_MAX 255 // limits current to nozzle; 255=full current #define PID_MAX 255 // limits current to nozzle; 255=full current
#ifdef PIDTEMP #ifdef PIDTEMP
//#define PID_DEBUG // Sends debug data to the serial port. //#define PID_DEBUG // Sends debug data to the serial port.
@ -115,22 +114,50 @@
// #define DEFAULT_Ki 0.1 // #define DEFAULT_Ki 0.1
// #define DEFAULT_Kd 12 // #define DEFAULT_Kd 12
//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, argressive factor of .15 (vs .1, 1, 10)
#define DEFAULT_bedKp 10.00
#define DEFAULT_bedKi .023
#define DEFAULT_bedKd 305.4
//mark from pidautotune
// #define DEFAULT_bedKp 97.1
// #define DEFAULT_bedKi 1.41
// #define DEFAULT_bedKd 1675.16
// Mendel Parts V9 on 12V // Mendel Parts V9 on 12V
// #define DEFAULT_Kp 63.0 // #define DEFAULT_Kp 63.0
// #define DEFAULT_Ki 2.25 // #define DEFAULT_Ki 2.25
// #define DEFAULT_Kd 440 // #define DEFAULT_Kd 440
#endif // PIDTEMP #endif // PIDTEMP
// Bed Temperature Control
// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis
//
// uncomment this to enable PID on the bed. It uses the same ferquency PWM as the extruder.
// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz,
// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
// If your configuration is significantly different than this and you don't understand the issues involved, you proabaly
// shouldn't use bed PID until someone else verifies your hardware works.
// If this is enabled, find your own PID constants below.
//#define PIDTEMPBED
//
//#define BED_LIMIT_SWITCHING
// This sets the max power delived to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option.
// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did,
// so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPBED)
#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
#ifdef PIDTEMPBED
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, argressive factor of .15 (vs .1, 1, 10)
#define DEFAULT_bedKp 10.00
#define DEFAULT_bedKi .023
#define DEFAULT_bedKd 305.4
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from pidautotune
// #define DEFAULT_bedKp 97.1
// #define DEFAULT_bedKi 1.41
// #define DEFAULT_bedKd 1675.16
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#endif // PIDTEMPBED
//this prevents dangerous Extruder moves, i.e. if the temperature is under the limit //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
//can be software-disabled for whatever purposes by //can be software-disabled for whatever purposes by
#define PREVENT_DANGEROUS_EXTRUDE #define PREVENT_DANGEROUS_EXTRUDE

View File

@ -5,13 +5,10 @@
//=============================Thermal Settings ============================ //=============================Thermal Settings ============================
//=========================================================================== //===========================================================================
// Select one of these only to define how the bed temp is read.
//
//#define BED_LIMIT_SWITCHING
#ifdef 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 #define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
#endif #endif
#define BED_CHECK_INTERVAL 5000 //ms #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control
//// Heating sanity check: //// Heating sanity check:
// This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature // This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature

View File

@ -153,8 +153,7 @@ void PID_autotune(float temp, int extruder, int ncycles)
long t_high; long t_high;
long t_low; long t_low;
long bias=PID_MAX/2; long bias, d;
long d = PID_MAX/2;
float Ku, Tu; float Ku, Tu;
float Kp, Ki, Kd; float Kp, Ki, Kd;
float max, min; float max, min;
@ -173,9 +172,15 @@ void PID_autotune(float temp, int extruder, int ncycles)
disable_heater(); // switch off all heaters. disable_heater(); // switch off all heaters.
if (extruder<0) if (extruder<0)
soft_pwm_bed = PID_MAX/2; {
soft_pwm_bed = (PID_MAX_BED)/2;
bias = d = (PID_MAX_BED)/2;
}
else else
soft_pwm[extruder] = PID_MAX/2; {
soft_pwm[extruder] = (PID_MAX)/2;
bias = d = (PID_MAX)/2;
}
@ -209,8 +214,8 @@ void PID_autotune(float temp, int extruder, int ncycles)
t_low=t2 - t1; t_low=t2 - t1;
if(cycles > 0) { if(cycles > 0) {
bias += (d*(t_high - t_low))/(t_low + t_high); bias += (d*(t_high - t_low))/(t_low + t_high);
bias = constrain(bias, 20 ,PID_MAX-20); bias = constrain(bias, 20 ,(extruder<0?(PID_MAX_BED):(PID_MAX))-20);
if(bias > PID_MAX/2) d = PID_MAX - 1 - bias; if(bias > (extruder<0?(PID_MAX_BED):(PID_MAX))/2) d = (extruder<0?(PID_MAX_BED):(PID_MAX)) - 1 - bias;
else d = bias; else d = bias;
SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias); SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
@ -414,10 +419,10 @@ void manage_heater()
dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed); dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
temp_dState_bed = pid_input; temp_dState_bed = pid_input;
pid_output = constrain(pTerm_bed + iTerm_bed - dTerm_bed, 0, PID_MAX); pid_output = constrain(pTerm_bed + iTerm_bed - dTerm_bed, 0, PID_MAX_BED);
#else #else
pid_output = constrain(pid_setpoint_bed, 0, PID_MAX); pid_output = constrain(pid_setpoint_bed, 0, PID_MAX_BED);
#endif //PID_OPENLOOP #endif //PID_OPENLOOP
if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp))
@ -437,7 +442,7 @@ void manage_heater()
} }
else else
{ {
soft_pwm_bed = 100; soft_pwm_bed = PID_MAX_BED>>1;
} }
} }
else { else {
@ -454,7 +459,7 @@ void manage_heater()
else else
if(current_raw_bed <= target_bed_low_temp) if(current_raw_bed <= target_bed_low_temp)
{ {
soft_pwm_bed = 100; soft_pwm_bed = PID_MAX_BED>>1;
} }
} }
else { else {