第三届全国大学生智能汽车大赛
if(atd_value[l]==0){ for(m=l;m<14;m++){ if(atd_value[m]==1){ exit_flag=1; }else exit_flag=0; }
}else exit_flag=0; }
}else exit_flag=0; } }else exit_flag=0; }
}else exit_flag=0; } if(exit_flag==1) {
exit1++; if(exit1>3003) {
// if(stop_stop<4&&stop_stop>=0) // { exit++; // stop_stop=0xff; // } exit1=0; if(exit>2)exit=2; }
30
第三届全国大学生智能汽车大赛
}
zanshi++; if(zanshi>5) { zanshi=0;
DCDuty=DC_Limit-CaiXinBoPIDController(Object_Speed,(int)AveSpeed,&SpdPID);// if(DCDuty<1) DCDuty=0; if(DCDuty>DC_Limit) DCDuty=DC_Limit; if (exit==2) DCDuty=1;
PWMDTY45=DCDuty; //change Motor PWM duty] } }
/**********************定时器溢出中断*********************/
void interrupt 16 TIMER_OVERFLOW(void)//187.5khz counter freq.349.5ms overflow once { int i; i=TCNT; if(stop_flag==1) {
if(exit<2)
PWMDTY45=DC_Limit; }
stop_flag=1;//in IC0_int ,clearing it }
/**********************ECT捕捉中断************************/
31
第三届全国大学生智能汽车大赛
void interrupt 8 IC0_ISR(void) {
// if(exit_flag==1) // {
// stop_stop1++; // }
// else if(exit_flag==0) // {
// stop_stop=stop_stop1; // stop_stop1=0; // }
stop_flag=0;
IC0Counter=TC0;//获得当前IC0的计数值 ,clearing C0F flag pulse_counter=IC0Counter-IC0Counter_1; IC0Counter_1=IC0Counter; GearWidth[3]=pulse_counter;
for(GearIndex=0;GearIndex<4;GearIndex++) {
GearWidthSum=GearWidthSum+(unsigned long)GearWidth[GearIndex]; }
AveGearWidth=GearWidthSum/4; AveSpeed=93750L/AveGearWidth; NowSpeed=(int)AveSpeed; GearWidthSum=0;
GearWidth[0]=GearWidth[1];;
32
//when speed is 2.4m/s,15 rounds per sec,15*32=480 int per sec
第三届全国大学生智能汽车大赛
GearWidth[1]=GearWidth[2]; GearWidth[2]=GearWidth[3]; }
33
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库智能车程序(7)在线全文阅读。
相关推荐: