一次尝试,引入外部温度到加热部分

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

@ -200,16 +200,48 @@ void PID_Calc() // pid calc
pid.hd = pid.hd_h;
pid.h_base = pid.h_base_h;
// 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) {
pid.hp = pid.hp_h * 0.6;
}
// TODO::在外界温度温差比较大45-22=23度加热功率不够
if (pid.set_tem - pid.now_tem < 1) {
pid.hp = pid.hp_h * 0.3;
}
// // 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) {
// pid.hp = pid.hp_h * 0.6;
// }
// // TODO::在外界温度温差比较大45-22=23度加热功率不够
// if (pid.set_tem - pid.now_tem < 1) {
// pid.hp = pid.hp_h * 0.3;
// }
// TODO::要改成根据外界温度调节参数
// TODO::A test
// 1 大于3度时候最大6000
// 2 小于3度时候在0度外界温差时最小到0
// 3 小于3度时候在12度外界温差时最小到1800
// 4 小于3度时候在23度外界温差时最小到2700
// 变量:外界温差 t_out内部温差 t_in
// 由2-4, hp_base = -3.125*t_out^2+187.5*t_out
// 由1, hp = min( (6000 - hp_base) / 3 * t_in + hp_base, 6000 )
if (abs(pid.out_tem) > 1e-5) {
float t_out = pid.set_tem - pid.out_tem; // 7
float t_in = pid.set_tem - pid.now_tem; // 1.1
float hp_base = -0.003125 * t_out * t_out + 0.1875 * t_out;
pid.hp = (6 - hp_base) / 3 * t_in + hp_base;
if (pid.hp < 0) {
pid.hp = 0;
}
if (pid.hp > 6) {
pid.hp = 6;
}
} else {
if (pid.set_tem - pid.now_tem < 3) {
pid.hp = pid.hp_h * 0.6;
}
if (pid.set_tem - pid.now_tem < 1) {
pid.hp = pid.hp_h * 0.4;
}
}
}
// l mode

@ -491,13 +491,12 @@ void RS485_1_Upload_Params(void)
sendbuf[36] = (int)(pid.cp * 1000) % 256; // Kp 110
sendbuf[37] = ((int)(pid.ci * 100000)) / 256; // Ti 0.001
sendbuf[38] = ((int)(pid.ci * 100000)) % 256; // Ti 0.001
sendbuf[39] = (int)pid.cd / 256; // Td 340
sendbuf[40] = (int)pid.cd % 256; // Td 340
// // TODO::temply print out_tem
// sendbuf[39] = (int)(pid.out_tem * 10) / 256; // Td 340
// sendbuf[40] = (int)(pid.out_tem * 10) % 256; // Td 340
sendbuf[39] = (int)(pid.cd * 1000) / 256; // Td 340
sendbuf[40] = (int)(pid.cd * 1000) % 256; // Td 340
sendbuf[41] = pid.c_speed / 256; // h_percent
sendbuf[42] = pid.c_speed % 256; // h_percent
sendbuf[43] = (int)(pid.out_tem * 10) / 256;
sendbuf[44] = (int)(pid.out_tem * 10) % 256;
sendbuf[45] = (int)(pid.out_humidity * 10) / 256;

Loading…
Cancel
Save