|
|
|
|
@ -52,12 +52,12 @@ void PID_Init()
|
|
|
|
|
pid.hd_h = 0.5;
|
|
|
|
|
pid.h_base_h = 0;
|
|
|
|
|
|
|
|
|
|
pid.hp_l = 19.2;
|
|
|
|
|
pid.hp_l = 14.4;
|
|
|
|
|
pid.hi_l = 0.08;
|
|
|
|
|
pid.hd_l = 0;
|
|
|
|
|
pid.h_base_l = 53;
|
|
|
|
|
|
|
|
|
|
pid.cp = 9.6;
|
|
|
|
|
pid.cp = 3;
|
|
|
|
|
pid.ci = 0;
|
|
|
|
|
pid.cd = 0;
|
|
|
|
|
pid.c_base = 37;
|
|
|
|
|
@ -127,8 +127,8 @@ int calc_hp(float delta_t, float Error_calc, float DelEk, int p_hb, float pid_hp
|
|
|
|
|
/**
|
|
|
|
|
* compressor power percent calc
|
|
|
|
|
*/
|
|
|
|
|
int calc_cp(float delta_t, int p_cb, float pid_cp) {
|
|
|
|
|
int percent = p_cb - pid_cp * delta_t;
|
|
|
|
|
int calc_cp(float delta_t, float Error_calc, float DelEk, int cb, float cp, float ci, float cd) {
|
|
|
|
|
int percent = cb - cp * delta_t + ci * Error_calc + cd * DelEk;
|
|
|
|
|
if (percent > 100) {
|
|
|
|
|
return 100;
|
|
|
|
|
}
|
|
|
|
|
@ -166,13 +166,6 @@ void PID_Calc() // pid calc
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
float delta_t = pid.set_tem - pid.now_tem;
|
|
|
|
|
// When the target tem is greater then max compressor tem, the compressor will stop
|
|
|
|
|
if (pid.set_tem > pid.max_compressor_tem) {
|
|
|
|
|
pid.c_speed = 0;
|
|
|
|
|
} else {
|
|
|
|
|
int p_c = calc_cp(delta_t, pid.c_base, pid.cp);
|
|
|
|
|
pid.c_speed = calc_compressor_speed(p_c, min_speed_count, max_speed_count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float hp = pid.hp_h;
|
|
|
|
|
float hi = pid.hi_h;
|
|
|
|
|
@ -204,9 +197,11 @@ void PID_Calc() // pid calc
|
|
|
|
|
pid.SEk = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SEk limit, updated func, remain a little heater power when the compressor is running in full state
|
|
|
|
|
if (pid.SEk < - (h_base - 10) / hi) {
|
|
|
|
|
pid.SEk = - (h_base - 10) / hi;
|
|
|
|
|
if (pid.SEk < - (h_base / 2) / hi) {
|
|
|
|
|
pid.SEk = - (h_base / 2) / hi;
|
|
|
|
|
}
|
|
|
|
|
if (pid.c_speed == max_speed_count) {
|
|
|
|
|
pid.SEk = 0;
|
|
|
|
|
@ -250,6 +245,14 @@ void PID_Calc() // pid calc
|
|
|
|
|
pid.OUT = out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// When the target tem is greater then max compressor tem, the compressor will stop
|
|
|
|
|
if (pid.set_tem > pid.max_compressor_tem) {
|
|
|
|
|
pid.c_speed = 0;
|
|
|
|
|
} else {
|
|
|
|
|
int p_c = calc_cp(delta_t, Error_calc, DelEk, pid.c_base, pid.cp, pid.ci, pid.cd);
|
|
|
|
|
pid.c_speed = calc_compressor_speed(p_c, min_speed_count, max_speed_count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// heater percent
|
|
|
|
|
pid.h_percent = calc_hp(delta_t, Error_calc, DelEk, h_base, hp, hi, hd);
|
|
|
|
|
// close heater when compressor is running in full state
|
|
|
|
|
|