|
|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#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);
|
|
|
|
|
|