PID算法(C语言)
PID算法(C语言)
作者:61IC 文章来源:本站原创 点击数: 更新时间:2007-1-16
#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;
}
/*------------------------------------------------------------------------
pid_tune
DESCRIPTION Sets the proportional gain (p_gain), integral gain (i_gain),
derivitive gain (d_gain), and the dead band (dead_band) of
a pid control structure _pid.
------------------------------------------------------------------------*/
void pid_tune(struct _pid *pid, float p_gain, float i_gain, float d_gain, int dead_band)
{
pid->pgain = p_gain;
pid->igain = i_gain;
pid->dgain = d_gain;
pid->deadband = dead_band;
pid->integral= integral_val;
pid->last_error=0;
}
/*------------------------------------------------------------------------
pid_setinteg
DESCRIPTION Set a new value for the integral term of the pid equation.
This is useful for setting the initial output of the
pid controller at start up.
------------------------------------------------------------------------*/
void pid_setinteg(struct _pid *pid,float new_integ)
{
pid->integral = new_integ;
pid->last_error = 0;
}
/*------------------------------------------------------------------------
pid_bumpless
DESCRIPTION Bumpless transfer algorithim. When suddenly changing
setpoints, or when restarting the PID equation after an
extended pause, the derivative of the equation can cause
a bump in the controller output. This function will help
smooth out that bump. The process value in *pv should
be the updated just before this function is used.
----------------------------------------------------
你可能喜欢
- PID程序
- PID温度控制
- 智能小车
- 汇编语言程序
- 增量式PID C程序3页
- PID程序9页
- 跑的不错的PID程序文档8页
- PID算法及程序5页
- PID控制C源程序3页
- PID PWM脚本程序2页
- 数字PID温度自动控制系统的应用2页
- 基于PID电加热炉温度控制系统设计18页
- 基于单片机的PID温度控制系统57页
- 高精度 PID温度控制器5页
- PID温度控制的PLC程序设计5页
- PID温度控制的PLC程序设计5页
- 电动智能小车2页
- 4智能避障小车系统的设计与实现4页
- 智能循迹小车8页
- 智能小车要求-2页
- 智能循迹小车___设计报告16页
- 智能小车48页
- 第八讲 汇编语言程序的阅读与理解11120123页
- 第5章 汇编语言程序设计91页
- 第4章 汇编 语言程序设计74页
- 汇编语言程序设计24页
- 第五章 汇编语言程序设计57页
- 11《汇编语言程序设计》实验教学大纲4页


