[转载]PID 算法(c 语言)(来自老外)
(2011-05-17 17:01:05)
转载▼
标签:
转载
原文地址:PID 算法(c 语言)(来自老外)作者:俊俊
#include <stdio.h>
#include<math.h>
struct _pid
{
int pv; //integer that contains the process value 过程量
int sp; //*integer that contains the set point 设定值
float integral; // 积分值 -- 偏差累计值
float pgain;
float igain;
float dgain;
int deadband; //死区
int last_error;
};
struct _pid warm,*pid;
int process_point, set_point,dead_band;
float p_gain, i_gain, d_gain, integral_val,new_integ;;
//---------------------------------
-------------
pid_init DESCRIPTION This function initializes the pointers in the _pid
structure to the process variable and the setpoint. *pv and *sp are integer
pointers.
//---------------------------------
-------------
void pid_init(struct _pid *warm, int process_point, int set_point)
{
struct _pid *pid;
pid = warm;
pid->pv = process_point;
pid->sp = set_point;
}
评论0