資源描述:
《飛思卡爾智能車 智能車源代碼光電組(有注解)》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
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];//**********************************************************//***********************舵機(jī)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次理論速度與實(shí)際速度的差值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調(diào)試中斷**************************unsignedc
6、harcp=0;unsignedcharci=0;unsignedcharcd=0;unsignedintsearch_PACN10;unsignedintnp=0;unsignedintsp[500];//**********************************************************//*********************存儲(chǔ)前20點(diǎn)的數(shù)據(jù)*********************intL_num[10]={0,0,0,0,0,0,0,0,0,0};intsum_corrd=0;intwb=0;//記錄當(dāng)前狀態(tài)黑為0,白為1;//****
7、******************************************************//********************紅外濾波*****************************intcorrd[10]={0,0,0,0,0,0,0,0,0,0};intT_corrd=0;intis_white=0;intnumb=0;//***********************************************