第五届飞思卡尔智能车电磁组获奖程序osqdi8vk.docVIP

  • 4
  • 0
  • 约9.56千字
  • 约 10页
  • 2018-09-01 发布于湖北
  • 举报

第五届飞思卡尔智能车电磁组获奖程序osqdi8vk.doc

第五届飞思卡尔智能车电磁组获奖程序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 ) {

文档评论(0)

1亿VIP精品文档

相关文档