资源简介
模糊PID源程序,C语言编写,内有详细说明,适用于初学者-Fuzzy PID source
代码片段和文件信息
#include
#include “systick.h“
#include “motor.h“
#include “PID.h“
__IO uint32_t CaptureNumber1;
__IO uint32_t CaptureNumber2;
__IO uint32_t CaptureNumber3;
__IO uint32_t CaptureNumber4;
typedef struct
{
__IO int SetPoint; //设定目标 Desired Value
__IO double Proportion; //比例常数 Proportional Const
__IO double Integral; //积分常数 Integral Const
__IO double Derivative; //微分常数 Derivative Const
__IO int LastError1; //Error[-1]
__IO int PrevError1; //Error[-2]
__IO int LastError2; //Error[-1]
__IO int PrevError2; //Error[-2]
__IO int LastError3; //Error[-1]
__IO int PrevError3; //Error[-2]
__IO int LastError4; //Error[-1]
__IO int PrevError4; //Error[-2]
}PID;
/* 私有宏定义 ----------------------------------------------------------------*/
/*************************************/
//定义PID相关宏
/*************************************/
//定义PID相关宏
// 这三个参数设定对电机运行影响非常大
/*************************************/
#define P_DATA 3.2 //P参数
#define I_DATA 1.1 //I参数
#define D_DATA -0.15 //D参数
static PID sPID;
static PID *sptr = &sPID;
/* 私有函数原形 --------------------------------------------------------------*/
/* 函数体 --------------------------------------------------------------------*/
/**************PID参数初始化********************************/
void IncPIDInit(void)
{
sptr->LastError1=0; //Error[-1]
sptr->PrevError1=0; //Error[-2]
sptr->LastError2=0; //Error[-1]
sptr->PrevError2=0; //Error[-2]
sptr->LastError3=0; //Error[-1]
sptr->PrevError3=0; //Error[-2]
sptr->LastError4=0; //Error[-1]
sptr->PrevError4=0; //Error[-2]
sptr->Proportion=P_DATA; //比例常数 Proportional Const
sptr->Integral=I_DATA; //积分常数 Integral Const
sptr->Derivative=D_DATA; //微分常数 Derivative Const
sptr->SetPoint=100; //设定目标Desired Value
}
/********************增量式PID控制设计************************************/
int IncPIDCalc1(int NextPoint1)
{
int iErroriIncpid; //当前误差
iError=sptr->SetPoint-NextPoint1; //增量计算
iIncpid=(sptr->Proportion * iError) //E[k]项
-(sptr->Integral * sptr->LastError1) //E[k-1]项
+(sptr->Derivative * sptr->PrevError1); //E[k-2]项
sptr->PrevError1=sptr->LastError1; //存储误差,用于下次计算
sptr->Last
- 上一篇:ISE_14.7_license.lic
- 下一篇:railroad铁路CAD生成
相关资源
- railroad铁路CAD生成
- ISE_14.7_license.lic
- STM32f103超声波模块例程
- 最新版TTF16.OCX Formula One v. 6.1.6.2 控件
- stm32f103c8t6 4 oled.rar
- VirTest5.0.rar
- CAD中插入带坐标的正射影像——Inse
- Uninstall_Cortana_WINCLIENT.CN.rar
- mpu6050+hmc5883L.rar
- LCD显示温度+串口接收温度.rar
- 图像的小波包分解
- 数字华容道
- VisualStudioUninstaller vs卸载工具
- 基于MSP430G2553的蓝牙控制小车
- 金蝶K3wise数据字典
- DAC0832波形发生器幅值及频率都精确可
- 安卓QQ6.71协议源码易语言,qq协议源码
- 编译原理实验工具及参考源码(lex&
- E盾偷后台工具源码
- Zprotect专业版(无限制) 一机一码E
- WPF USB 网络 串口 通信软件
- Servlet API中文文档
- 组态王驱动开发包3.0.0.7(中文)
- stm32f030 IAP Demo(原创)
- 用python编写的移动彩信的发送程序
- SSM+Shiro+redis实现单点登陆
- WPE三件套(WPE+CCP+E2G)冰枫修改版
- TCL-S1916 ,1924交换机管理程序
- 飞思卡尔单片机MC9S12XS12G128驱动(硬件
- VNCX
评论
共有 条评论