PID控制C源程序
PID控制C源程序
作者:61IC录入 文章来源:本站原创 点击数: 更新时间:2007-1-1
BC31 TC30 编译过,可运行。
#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 us
你可能喜欢
- C语言PID算法
- 增量式PID控制
- PID电机控制
- DS18B20中文资料
- C语言程序
- 温度PID控制
- 模糊PID控制
- 增量式PID控制算法5页
- 增量式PID控制C语言5页
- 位置式PID控制与增量式PID控制的比较1页
- 基于三菱FX2N的增量式PID控制器设计4页
- 增量式PID控制算法程序22页
- 基于BP神经网络的改进增量式PID暖通控制器设计4页
- 基于单片机采用PID算法的电机运行控制系统设计2页
- 基于PID的电机闭环控制1页
- 基于AT89S52的PID电机控制c语言编程7页
- 基于数字PID的电机速度控制系统设计16页
- 一种基于模糊PID的AFS电机控制方法3页
- 基于干扰观测器PID的直流电机速度控制3页
- DS18B20中文资料15页
- 时钟芯片DS18B20中文资料4页
- DS18B20中文资料9页
- DS18B20中文全套资料,木有时序啊13页
- DS18B20中文资料22页
- DS18B20 中文资料13页
- C语言程序设计期末考试试题A[1]13页
- C语言程序设计教程(第二版)6页
- C语言程序设计A期末模拟试题一9页
- C语言程序设计3页
- 《C语言程序设计基础》上机实验报告(模版)2页
- C语言程序设计(第三版)-谭浩强[开始免费了]322页


