资源描述:
《飞思卡尔电磁组程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、//控制策略car.cpp:DefinestheinitializationroutinesfortheDLL.//#include#include"stdafx.h"#include"控制策略car.h"//#include"Judgement.H"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifextern"C"_declspec(dllexport)voidJudge(unsignedshortSpeed,unsigned
2、charSensorData,unsignedshortSensorCount,unsignedcharCCDData,intCCDWidth,intCCDHeight,unsignedshortMotorPWM,unsignedshortSteerPWM);extern"C"_declspec(dllexport)voidReset();voidInit_ECT(void);voidInit_PWMout(void);voidInit_SCI(void);voidTransmit_Sci(unsignedint);unsignedcharReceive_Sc
3、i(void);voidSignalProcess();voidPWMout(int,int,int);voidMemoryroad(void);voidRoadplay(void);voidPIDinit(void);voiddelay(intcnt);voidSteerContral(void);voidCircles(void);intRunroad_time=0/第一圈时间/,Roadtime,Runroad_time2=0/第二圈时间/;intInbentcount=0,Outbentcount=0;//弯道数目intSpeedout,Steerou
4、t,Speedfout,allspeed;intAD,cnt,flag_delay=0;intf0=0,f1=0,f2=0,f3=0,f4=0,f5=0,f6=0,f7=0,f8=0,f9=0,f10=0;unsignedcharch_0,ch_1,ch_2,ch_3,ch_4,ch_5,ch_6,ch_7,ch_8,ch_9,ch_10,ch_11,ch_12;staticintoldDirection,Direction,Velocity,VelocityFz;//方向速度变量16位intflag0,flag1,flag2,flag3,flag4,flag
5、5,flag6,flag7,flag8,flag9,flag10,Flagstart;unsignedcharJump=0,Jump0=0,Jump1=0,Jump2=0,Jump3=0,Jump4=0,Jump5=0,Jump6=0,Jump7=0,Jump8=0,Jump9=0;unsignedcharPulseCnt,PORTB;unsignedintsudu,Turn=11,bjqushu,oldbjqushu,qushu;unsignedintjstime,SYSCLOCK=0,sctime=0;intStartline,Circle=0,line=
6、0,line0=0,line2=0,line22=0,line3=0,line33=0,aa0=0,aa1=0,aa2=0;intZhuanjiao[]={-250,-235,-215,-195,-175,-150,-120,-90,-60,-30,0,30,60,90,120,150,175,195,215,235,250};intHiShuruSudu[]={15,20,20,20,22,22,25,25,30,30,40,30,30,25,25,22,22,20,20,20,15};intShuruSudu[]={15,20,20,20,22,22,25
7、,25,25,30,30,30,25,25,25,22,22,20,20,20,15};intss=0,insstime[50],outsstime[50],oldsstime=0,ssflag=0,oldssflag=0,sstime_flag2=0,sstime_flag1=0;intoldss;/PID///速度PIDtypedefstruct{intNextPoint;intThisPoint;//设定目标DesiredvalueintKp;//比例常数ProportionalConstintKi;//积分常数IntegralConstintKd;//
8、微分常数DerivativeConst