From 05e90da8462f4166ac942c9833bb06f2b1971f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zeng=20wei=20=28=E6=9B=BE=E5=A8=81=29?= Date: Sun, 14 Apr 2024 14:32:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=8E=A5=E5=85=A5ou?= =?UTF-8?q?t=5Ftem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HARDWARE/PID.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HARDWARE/PID.c b/HARDWARE/PID.c index c15307b..cc11033 100644 --- a/HARDWARE/PID.c +++ b/HARDWARE/PID.c @@ -1,3 +1,5 @@ +#include +#include #include "PID.h" #include "Relays.h" #include "USART.h" @@ -257,6 +259,10 @@ void PID_Calc() // pid calc if (pid.set_tem > pid.max_compressor_tem) { pid.c_speed = 0; } else { + // if outer temp is got, we calc pid by outer temp + if (abs(pid.out_tem) > 1e-5) { + pid.cp = (pid.out_tem - pid.set_tem) / 4.3 + 0.7; + } // 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); pid.c_speed = calc_compressor_speed(p_c, min_speed_count, max_speed_count);