You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.1 KiB
73 lines
1.1 KiB
#ifndef _PID_H
|
|
#define _PID_H
|
|
|
|
#include "SysTick.h"
|
|
|
|
void PID_Init(void);
|
|
void PID_Calc(void);
|
|
|
|
typedef struct Pid
|
|
{
|
|
float set_tem;// User settings
|
|
float now_tem;// current temperature
|
|
|
|
float max_compressor_tem; // maximum temperature of the compressor. When the target tem is greater than this value, the compressor is turned off.
|
|
|
|
float out_tem; // outer temperature
|
|
float out_humidity; // outer humidity
|
|
|
|
// in h mode
|
|
float hp_h;
|
|
float hi_h;
|
|
float hd_h;
|
|
int h_base_h; // base power percent in h mode
|
|
|
|
// in l mode
|
|
float hp_l;
|
|
float hi_l;
|
|
float hd_l;
|
|
int h_base_l; // base power percent in l mode
|
|
int h_percent;
|
|
|
|
|
|
float cp;
|
|
float ci;
|
|
float cd;
|
|
float c_base;
|
|
int c_speed;
|
|
|
|
float Kp; // 110
|
|
float Ki; // 0.001
|
|
float Kd; // 340
|
|
int t; // PID calculation cycle - sampling cycle
|
|
float Ti;
|
|
float Td;
|
|
|
|
float Ek; // This deviation
|
|
float Ek_prev;// Last deviation
|
|
float SEk; // The sum of historical deviations
|
|
|
|
float Iout;
|
|
float Pout;
|
|
float Dout;
|
|
|
|
float OUT0;
|
|
|
|
float OUT;
|
|
|
|
int C1ms;
|
|
|
|
int pwmcycle;// PWM cycle
|
|
|
|
int times;
|
|
|
|
float tem_offset;
|
|
|
|
float tem_threshold;
|
|
}PID;
|
|
|
|
extern PID pid;
|
|
#endif
|
|
|
|
|