This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
#include <string.h>
#define uchar unsigned char
#define uint unsigned int
uint Point,PIDResult;
/*定义 PID 结构体*/
struct PID
{
unsigned int SetPoint; // 设定目标Desired Value
unsigned int Proportion; // 比例常数 ProportionalConst
unsigned int Integral; // 积分常数Integral Const
unsigned int Derivative; // 微分常数 Derivative Const
unsigned int LastError; // 上一次偏差 Error[-1]
unsigned int PrevError; // 当前偏差 Error[-2]
unsigned int SumError; // 偏差累积 Sums of Errors
};
/*定义PID 结构体变量*/
struct PID spid; // PID Control Structure
/*====================================================
Initialize PID Structure
======================================================*/
/*调用 string.h 头文件函数*/
void PIDInit (struct PID *pp)
{
/*memset()给第一个参数赋第二个参数的 ASCII 的值并分配第三个参数大小的空间*/
memset (pp,0,sizeof(struct PID));//PID 各参数存储空间并赋初值 0
}