- 4
- 0
- 约9.56千字
- 约 10页
- 2018-09-01 发布于湖北
- 举报
第五届飞思卡尔智能车电磁组获奖程序osqdi8vk
#include hidef.h /* common defines and macros */
#include derivative.h /* derivative-specific definitions */
#include stdio.h
#include MC9S12XS128.h
#include stdlib.h
#include math.h
#pragma LINK_INFO DERIVATIVE mc9s12xs128
#define K 1
#define N 3
unsigned int i=0,j=0,m=0,n=0;
unsigned char str[]={0};
signed int b=0,c=0,d=0,e=0,f=0,g=0,spe=0,r=0,l,x3,y,z,x1,x2,x4;
int time;
int zd=0,flag;
int pp;
/////////////////////////////////////
//// μ??ú PID ?¨ò?
/////////////////////////////////////
int SetPoint=0; //éè?¨??±ê Desired Value
int FeedBack=0;
float KKp=1.5; //±èày3£êy Proportional Const
float KKi=0;
float KKd=0.6; //?¢·?3£êy Derivative Const
signed int EE0=0; //μ±?°?ó2?
signed int EE1=0; //Error[-1]
signed int EE2=0; //Error[-2]
signed int EError0=0,EError1=0;
signed int iiIncpid=0;
int sp=0;
///////////////////////////////
/// ???ú PID ?¨ò?
//////////////////////////////
float Kp=3; //±èày3£êy Proportional Const
float Ki=1;
float Kd=4.2; //?¢·?3£êy Derivative Const
signed int E0=0 ; //μ±?°?ó2?
signed int E1=0; //Error[-1]
signed int E2=0; //Error[-2]
signed int Error0=0,Error1=0;
signed int iIncpid=0;
/////////////////////////////////////
/////////////////////////////////////
//// μ??ú PID
/////////////////////////////////////
////////////////////////////////////
unsigned int Getspeed(int cch1,int cch2 )
{
EE0=cch1-cch2; //??á?????
EError0=EE0-EE1;
EError1=EE1-EE2;
iiIncpid=(int)(KKi*EError0+KKp*EE0+KKd*(EError0-EError1));
EE1=EE0;
EE2=EE1; //′?′¢?ó2?£?ó?óú??′?????
sp+=iiIncpid;
if(sp210)
sp=210;
if(sp0)
sp=0;
return sp;
}
void sudu(int SetPoint)
{
pp=Getspeed(SetPoint,FeedBack);
PWMDTY2=pp;
}
//////////////////////////////
///////////////////////////////
/// ???ú PID
//////////////////////////////
//////////////////////////////////////
int Pcrtl(int ch1,int ch2 )
{
您可能关注的文档
- 生命体征监测技术试题3tgjji4k.doc
- 生活生命与安全一年级 小学一年级下册生命生活与安全教学设计drpco6pq.doc
- 生物医学工程分团委学生会活动经费管理制度50jcdeik.docx
- 生物多样性与害虫持续控制8ezymtu5.doc
- 生活污水处理技术特点与工艺分析0uyxdvyi.doc
- 生物质固体成型燃料抗结渣研究进展pq7apasv.doc
- 生物质焦油燃烧动力学特性研究yuvjpjw_.doc
- 用于环境风险评价的大连湾溢油预测模型j8y5rfx7.doc
- 用ceramec型陶瓷过滤机对精矿脱水是一种最先进的真空过滤工艺purqf7sl.doc
- 用取芯注浆法处理桩基质量事故的工程实例_otpstu6.doc
原创力文档

文档评论(0)