Update PID.c

check
Zeng wei (曾威) 2 years ago
parent 3cd51d9261
commit 5c4b0f60e4

@ -63,7 +63,7 @@ void PID_Init()
pid.h_base_h = 0; pid.h_base_h = 0;
pid.hp_l = 9; pid.hp_l = 9;
pid.hi_l = 0.025; pid.hi_l = 0.015;
pid.hd_l = 0; pid.hd_l = 0;
pid.h_base_l = 30; pid.h_base_l = 30;
@ -201,12 +201,15 @@ void PID_Calc() // pid calc
pid.h_base = pid.h_base_h; pid.h_base = pid.h_base_h;
// if now temp is close to set temp, the heater will be less power // if now temp is close to set temp, the heater will be less power
// TODO::在外界温度温差比较大45-22=23度加热功率也可能不够
if (pid.set_tem - pid.now_tem < 3) { if (pid.set_tem - pid.now_tem < 3) {
pid.hp = pid.hp_h * 0.6; pid.hp = pid.hp_h * 0.6;
} }
// TODO::在外界温度温差比较大45-22=23度加热功率不够
if (pid.set_tem - pid.now_tem < 1) { if (pid.set_tem - pid.now_tem < 1) {
pid.hp = pid.hp_h * 0.3; pid.hp = pid.hp_h * 0.3;
} }
// TODO::要改成根据外界温度调节参数
} }
// l mode // l mode
@ -315,8 +318,8 @@ void PID_Calc() // pid calc
} else { } else {
// if outer temp is got, we calc pid by outer temp // if outer temp is got, we calc pid by outer temp
if (abs(pid.out_tem) > 1e-5) { if (abs(pid.out_tem) > 1e-5) {
// pid.cp = (pid.out_tem - pid.set_tem) * 0.28; pid.cp = (pid.out_tem - pid.set_tem) * 0.28;
pid.cp = (pid.out_tem - pid.set_tem) * 0.2; // pid.cp = (pid.out_tem - pid.set_tem) * 0.2;
} }
// use nagetive error and error diff when calc compressor power // use nagetive error and error diff when calc compressor power
int p_c = calc_cp(delta_t, - Error_calc, - DelEk, pid.c_base, pid.cp, pid.ci, pid.cd); int p_c = calc_cp(delta_t, - Error_calc, - DelEk, pid.c_base, pid.cp, pid.ci, pid.cd);

Loading…
Cancel
Save