资源描述:
《飞思卡尔智能车 智能车源代码光电组(有注解)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、智能车源代码光电组(有注解)#include/*commondefinesandmacros*/#include/*derivativeinformation*/#include"math.h"#include"PWM.h"#include"ATD.h"#include"LQprintp.h"#pragmaLINK_INFODERIVATIVE"mc9s12dg256b"unsignedinti=0;unsignedintj=0;unsignedintt=0;bytead_value[13];uchardata[13];intsum=0
2、;ucharstart_flag=0;ucharnum=0;ucharlw=0;unsignedintper=65530;intSPWM=0;intL_SPWM=0;unsignedintSPmax=1000;intMPWM=0;ucharcurrent_corrd=0;staticunsignedintmem_num=0;//***********************PID*******************************staticunsignedintKp=25;staticunsignedintKp2=60;staticunsignedintKi=9;stat
3、icunsignedintKd=30;staticunsignedintrKp=100;staticunsignedintrKp2=60;staticunsignedintrKi=0;staticunsignedintrKd=60;unsignedshortE=5;unsignedcharq=1;intMp=0;intMi=0;intMd=0;intMp2=0;intP_Speed=0;intL_u[3];//**********************************************************//***********************舵机PID
4、变量**********************staticunsignedints_sKp=35;//直道PID的P值staticunsignedints_sKp2=0;//直道PID的二阶P值staticunsignedints_sKi=0;//直道PID的I值staticunsignedints_sKd=10;//直道PID的D值//****用于防止PID溢出******unsignedshorts_sE=5;unsignedchars_sq=1;//*************************//****分别存放PID值*****ints_sMp=0;ints_sMi=
5、0;ints_sMd=0;ints_sMp2=0;//*************************intsL_u[3];//存放前3次理论速度与实际速度的差值intlast_corrd[3][10]={{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}};//*********************************************************//*********************PID调试中断**************************unsignedc
6、harcp=0;unsignedcharci=0;unsignedcharcd=0;unsignedintsearch_PACN10;unsignedintnp=0;unsignedintsp[500];//**********************************************************//*********************存储前20点的数据*********************intL_num[10]={0,0,0,0,0,0,0,0,0,0};intsum_corrd=0;intwb=0;//记录当前状态黑为0,白为1;//****
7、******************************************************//********************红外滤波*****************************intcorrd[10]={0,0,0,0,0,0,0,0,0,0};intT_corrd=0;intis_white=0;intnumb=0;//***********************************************