1、燕山大学电气工程学院智能车实验室1一、 智能车制作路线图了解往届比赛规则选择比赛组别选择主控单片机购买相应配件机械+ 硬件设计软件设计与调试校内赛、区赛、国赛50%下落不明25%半路跳槽15%壮烈牺牲官网查询光电电磁摄像头直立趴着16 位 xs12832 位冷火32 位 k60同一学校同一组别单片机型号不同燕山大学电气工程学院智能车实验室2二、 摄像头组小车构成框图需要视频分离模拟摄像头最小系统单片机电源:DC 3.3VDC 5V舵机电机舵机电源电机驱动输出调试模块输入调试模块测速模块摄像头I/OECTI/O或ADI/OPWMvoid pwm_init();void delayms(uint
2、ms);void IO_Init(void);void TIM_Init(void);void SCI_Init(void);void SCI_Write(unsigned char SendChar); void delay(uint num);void myfun();#define lie 31#define hang_end 130uchar c_lie=0;uint lie_count=0;uchar taliehang_end;uint get_hang=17,40,60,78,94,109,123,135,146,156,165,174,181,187,195,200,206,2
3、10,215,219,燕山大学电气工程学院智能车实验室12223,227,231,234,237,240,243,245,248,250,251;uint h,l,i,mlz,mly,zhongxian,lie_1,start_flag=0;void main() pll_init();pwm_init();IO_Init();TIM_Init();SCI_Init();EnableInterrupts;DDRE=0xff; for(;) /*for(lie_1=0;lie_10;l-)if(tahl=1) mly=l;zhongxian=(mlz+mly)/2; if(zhongxian90
4、) PWMDTY23=3000;else if(zhongxian0;l-) if(tahl=1) mly=l;zhongxian=(mlz+mly);zhongxian=zhongxian/2;if(zhongxian65) PWMDTY23=3500;PORTE=0xff;else PWMDTY23=5000;PORTE=0x00;break;break; */void delay(uint num) uint a,b; for(a=0;a0;m-)for(n=4400;n0;n-);void SCI_Init(void) SCI0BD=312.5; /115200bps SCI0CR1=
5、0; /正常 8 位模式,无奇偶校验SCI0CR2=0X2C; /发送接受允许 中断允许燕山大学电气工程学院智能车实验室16void SCI_Write(unsigned char SendChar) while (!(SCI0SR1SCI0DRH=0x00; SCI0DRL=SendChar; void TIM_Init(void)TIOS=0x00; /外部输入捕捉 0,1 通道TCTL4=0x09; /通道 0 上升沿触发 行中 ,通道 1 下降沿触发 场中断TSCR1=0x80; /使能TSCR2=0X00;TIE=0x03; /通道 0,1 中断使能TFLG1=0xFF; /清中断标
6、志位void IO_Init(void)DDRS_DDRS2=0; /行中断的采集口DDRJ_DDRJ7=0;DDRJ_DDRJ6=0;DDRB=0xff;PORTB=0x00; #pragma CODE_SEG _NEAR_SEG NON_BANKEDvoid interrupt 8 PT0_Interrupt(void)DisableInterrupts;TFLG1_C0F=1;delay(1); /确保不采到消隐信号if(lie_count=get_hangc_lie tac_lie1=PTS_PTS2; tac_lie2=PTS_PTS2; tac_lie3=PTS_PTS2; tac
7、_lie4=PTS_PTS2; tac_lie5=PTS_PTS2;tac_lie6=PTS_PTS2; tac_lie7=PTS_PTS2; tac_lie8=PTS_PTS2;燕山大学电气工程学院智能车实验室17tac_lie9=PTS_PTS2; tac_lie10=PTS_PTS2; tac_lie11=PTS_PTS2;tac_lie12=PTS_PTS2; tac_lie13=PTS_PTS2; tac_lie14=PTS_PTS2;tac_lie15=PTS_PTS2; tac_lie16=PTS_PTS2; tac_lie17=PTS_PTS2;tac_lie18=PTS_PT
8、S2; tac_lie19=PTS_PTS2; tac_lie20=PTS_PTS2;tac_lie21=PTS_PTS2; tac_lie22=PTS_PTS2; tac_lie23=PTS_PTS2;tac_lie24=PTS_PTS2; tac_lie25=PTS_PTS2; tac_lie26=PTS_PTS2;tac_lie27=PTS_PTS2; tac_lie28=PTS_PTS2; tac_lie29=PTS_PTS2;tac_lie30=PTS_PTS2; tac_lie31=PTS_PTS2; tac_lie32=PTS_PTS2;tac_lie33=PTS_PTS2; t
9、ac_lie34=PTS_PTS2; tac_lie35=PTS_PTS2; tac_lie36=PTS_PTS2; tac_lie37=PTS_PTS2; tac_lie38=PTS_PTS2;tac_lie39=PTS_PTS2; tac_lie40=PTS_PTS2; tac_lie41=PTS_PTS2;tac_lie42=PTS_PTS2; tac_lie43=PTS_PTS2; tac_lie44=PTS_PTS2;tac_lie45=PTS_PTS2; tac_lie46=PTS_PTS2; tac_lie47=PTS_PTS2;tac_lie48=PTS_PTS2; tac_l
10、ie49=PTS_PTS2; tac_lie50=PTS_PTS2;tac_lie51=PTS_PTS2; tac_lie52=PTS_PTS2; tac_lie53=PTS_PTS2;tac_lie54=PTS_PTS2; tac_lie55=PTS_PTS2; tac_lie56=PTS_PTS2;tac_lie57=PTS_PTS2; tac_lie58=PTS_PTS2; tac_lie59=PTS_PTS2;tac_lie60=PTS_PTS2; tac_lie61=PTS_PTS2; tac_lie62=PTS_PTS2;tac_lie63=PTS_PTS2; tac_lie64=
11、PTS_PTS2; tac_lie65=PTS_PTS2; tac_lie66=PTS_PTS2; tac_lie67=PTS_PTS2; tac_lie68=PTS_PTS2;tac_lie69=PTS_PTS2; tac_lie70=PTS_PTS2; tac_lie71=PTS_PTS2;tac_lie72=PTS_PTS2; tac_lie73=PTS_PTS2; tac_lie74=PTS_PTS2;燕山大学电气工程学院智能车实验室18tac_lie75=PTS_PTS2; tac_lie76=PTS_PTS2; tac_lie77=PTS_PTS2;tac_lie78=PTS_PT
12、S2; tac_lie79=PTS_PTS2; tac_lie80=PTS_PTS2;tac_lie81=PTS_PTS2; tac_lie82=PTS_PTS2; tac_lie83=PTS_PTS2;tac_lie84=PTS_PTS2; tac_lie85=PTS_PTS2; tac_lie86=PTS_PTS2;tac_lie87=PTS_PTS2; tac_lie88=PTS_PTS2; tac_lie89=PTS_PTS2;tac_lie90=PTS_PTS2; tac_lie91=PTS_PTS2; tac_lie92=PTS_PTS2; tac_lie93=PTS_PTS2;
13、tac_lie94=PTS_PTS2; tac_lie95=PTS_PTS2;tac_lie96=PTS_PTS2; tac_lie97=PTS_PTS2; tac_lie98=PTS_PTS2;tac_lie99=PTS_PTS2; tac_lie100=PTS_PTS2;tac_lie101=PTS_PTS2; tac_lie102=PTS_PTS2;tac_lie103=PTS_PTS2;tac_lie104=PTS_PTS2;tac_lie105=PTS_PTS2;tac_lie106=PTS_PTS2;tac_lie107=PTS_PTS2;tac_lie108=PTS_PTS2;t
14、ac_lie109=PTS_PTS2;tac_lie110=PTS_PTS2; tac_lie111=PTS_PTS2;tac_lie112=PTS_PTS2;tac_lie113=PTS_PTS2;tac_lie114=PTS_PTS2;tac_lie115=PTS_PTS2;tac_lie116=PTS_PTS2;tac_lie117=PTS_PTS2;tac_lie118=PTS_PTS2;tac_lie119=PTS_PTS2;tac_lie120=PTS_PTS2; tac_lie121=PTS_PTS2;tac_lie122=PTS_PTS2;tac_lie123=PTS_PTS2
15、; tac_lie124=PTS_PTS2; tac_lie125=PTS_PTS2;tac_lie126=PTS_PTS2;tac_lie127=PTS_PTS2;tac_lie128=PTS_PTS2;tac_lie129=PTS_PTS2;燕山大学电气工程学院智能车实验室19c_lie+;lie_count+;asm cli; /不允许中断打断void interrupt 9 PT1_Interrupt(void) DisableInterrupts;TFLG1_C0F=1;TFLG1_C1F=1;c_lie=0;lie_count=0;asm cli;#pragma CODE_SEG
16、DEFAULT燕山大学电气工程学院智能车实验室20六、 赛道信息直道* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *062 062 062 063 062 063 063 063 063 063 063 063 063 063 063 063 063 063 064 063 064 063 063 063 063 063 063 064 064 064 063 063 063 063 063 063 063 062 062 060 062 063 063 0
17、62120度弯道* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *080 081 055 051 049 047 047 046 045 045 045 044 044 043 043 043 042 042 042 041 040 040 039 039 039 038 037 036 036 036 036 036 037 037 037 038 038 039 039 039 燕山大学电气工程学院智能车实验室21037 039 044 060* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *