c语言模糊pid算法实例,模糊PID的c语言算法.docx

模糊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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值