模糊PID的c语言算法
#include #include #include "succus.h"#include #include #include #include #include #define parameterPID 0.1 //PID常数#define maxcontroldata 10 //最大控制量#define parameterfuzzy 12 //模糊控制常数#define Pe1 4 //隶属度范围#define Pe2 8#define Psess1 2#define Psess2 4#define parainput 100 //输入常数staticintpanelHandle;static intL_PIDstart; //运行标签staticintL_fuzzystart;static float P_control; //获得参数static float I_control;static float D_control;staticintwhatmode;static float model_K; //模型参数static float model_T;static float model_t;static float cycle; //设定周期static float savedata[3];//储存偏差量static float savecontrol[20];//存储控制量static float result[2]; //存储仿真结果static float getsum;static char senddata[22];//通信协议static char recievedata[18];static char nak[6];static char ack[6];int main (intargc, char *argv[]){if (InitCVIRTE (0, argv, 0) == 0)return -1;/* out of memory */if ((panelHandle = LoadPanel (0, "succus.uir", PANEL)) < 0)return -1;OpenComConfig (2, "", 9600, 0, 8, 1, 512, 512); //打开串口senddata[0] = 5; //构造协议senddata[1] = '0';senddata[2] = 'A';senddata[3] = 'F';senddata[4] = 'F';senddata[5] = 'W';senddata[6] = 'W';senddata[7] = '0';senddata[8] = 'D';senddata[9] = '5';senddata[10] = '0';senddata[11] = '6';senddata[12] = '4';senddata[13] = '0';senddata[14] = '1';senddata[21] = 0;recievedata[0] = 5;recievedata[1] = '0';recievedata[2] = 'A';recievedata[3] = 'F';recievedata[4] = 'F';recievedata[5] = 'W';recievedata[6] = 'R';recievedata[7] = '0';recievedata[8] = 'D';recievedata[9] = '5';recievedata[10] = '0';recievedata[11] = '0';recievedata[12] = '0';recievedata[13] = '0';recievedata[14] = '1';recievedata[15] = '4';recievedata[16] = '0';recievedata[17] = 0;nak[0] = 21;nak[1] = '0';nak[2] = 'A';nak[3] = 'F';nak[4] = 'F';nak[5] = 0;ack[0] = 6;ack[1] = '0';ack[2] = 'A';ack[3] = 'F';ack[4] = 'F';ack[5] = 0;FlushInQ (2);FlushOutQ (2);DisplayPanel (panelHandle);RunUserInt