Rename preprocessor macro K1 to PID_K1 to avoid future conflict with MMU command.

This commit is contained in:
Marek Bel 2019-02-26 13:59:44 +01:00
parent 7a1b47c340
commit 5a5a482a59
2 changed files with 7 additions and 7 deletions

View File

@ -132,7 +132,7 @@
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
#define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term
#define K1 0.95 //smoothing factor within the PID
#define PID_K1 0.95 //smoothing factor within the PID
#define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it

View File

@ -662,9 +662,9 @@ void manage_heater()
iState_sum[e] += pid_error[e];
iState_sum[e] = constrain(iState_sum[e], iState_sum_min[e], iState_sum_max[e]);
iTerm[e] = cs.Ki * iState_sum[e];
// K1 defined in Configuration.h in the PID settings
#define K2 (1.0-K1)
dTerm[e] = (cs.Kd * (pid_input - dState_last[e]))*K2 + (K1 * dTerm[e]); // e.g. digital filtration of derivative term changes
// PID_K1 defined in Configuration.h in the PID settings
#define K2 (1.0-PID_K1)
dTerm[e] = (cs.Kd * (pid_input - dState_last[e]))*K2 + (PID_K1 * dTerm[e]); // e.g. digital filtration of derivative term changes
pid_output = pTerm[e] + iTerm[e] - dTerm[e]; // subtraction due to "Derivative on Measurement" method (i.e. derivative of input instead derivative of error is used)
if (pid_output > PID_MAX) {
if (pid_error[e] > 0 ) iState_sum[e] -= pid_error[e]; // conditional un-integration
@ -811,9 +811,9 @@ void manage_heater()
temp_iState_bed = constrain(temp_iState_bed, temp_iState_min_bed, temp_iState_max_bed);
iTerm_bed = cs.bedKi * temp_iState_bed;
//K1 defined in Configuration.h in the PID settings
#define K2 (1.0-K1)
dTerm_bed= (cs.bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
//PID_K1 defined in Configuration.h in the PID settings
#define K2 (1.0-PID_K1)
dTerm_bed= (cs.bedKd * (pid_input - temp_dState_bed))*K2 + (PID_K1 * dTerm_bed);
temp_dState_bed = pid_input;
pid_output = pTerm_bed + iTerm_bed - dTerm_bed;