资源简介

这是我做小车时的全部资料,包括各个模块的原理图,以及对舵机和电机的控制的讲解,完整的控制C 程序,智能车竞赛培训内容。

资源截图

代码片段和文件信息

#include 			
#include 
#include 
#define middle  920   
#define high 9000                 
                                       
#define uchar unsigned char
#define uint unsigned int
sbit rudder=P0^0;
sbit pulse=P0^1;                        
sbit dir=P0^2;                                       
bit  flag1=0flag2=0;         
unsigned int b=middlea=0;                
unsigned char highhhighllowhlowl;
                                        
main()
{
unsigned char receiveek1=7ek2=7;
pulse=0;
dir=0;
highh=(unsigned char)((16384-high)/256+192);
                                        
highl=(unsigned char)((16384-high)%256);   
lowh=(unsigned char)(high/256+200);
lowl=(unsigned char)(high%256);
IE=0x8a;                            
                                                                                                                                                                                                 
TMOD=0x11;

TH0=0x00;   
TL0=0x00;
TH1=0x00;
TL1=0x00;
TR0=1; //启动T0
TR1=1; //启动T1
/*--------------for1----------------*/
for(;;)
{
receive=P2;                //采集光电传感器的值
/*--------------switch----------------*/
switch(receive)            //根据采集到的值进行判断
{
case 0x7f:ek1=15;break; //0111 1111  
case 0x3f:ek1=14;break; //0011 1111  
case 0xbf:ek1=13;break; //1011 1111  
case 0x9f:ek1=12;break; //1001 1111
case 0xdf:ek1=11;break; //1101 1111
case 0xcf:ek1=10;break; //1100 1111
case 0xef:ek1=9;break; //1110 1111
case 0xe7:ek1=8;break; //1110 0111
case 0xf7:ek1=7;break; //1111 0111
case 0xf3:ek1=6;break; //1111 0011
case 0xfb:ek1=5;break; //1111 1011
case 0xf9:ek1=4;break; //1111 1001
case 0xfd:ek1=3;break; //1111 1101
case 0xfc:ek1=2;break; //1111 1100
case 0xfe:ek1=1;break; //1111 1110
default:  ek1=ek2;break; //1111 1111  没有检测到黑线(是需要保持上一次测量值的)
}
/*--------------switch----------------*/

   b=110*ek1-55*ek2-385+middle;
                                
                              

        
if(b>1230)
b=1230;
if(b<610)
b=610;
ek2=ek1;
}
/*--------------for1----------------*/
}
void zhongduan_t0(void) interrupt 1
{
if(flag1==0)
{   
TH0=(unsigned char)((16384-b)/256+192);    
                         



TL0=(unsigned char)((16384-b)%256);
a=b;
flag1=1;
rudder=1;
}
else
{
TH0=(unsigned char)(a/256+184);
TL0=(unsigned char)(a%256);
 

rudder=0;
flag1=0;    
}
//TF0=0;
//TF1=0;
}
void zhongduan_t1(void) interrupt 3
{
if(flag2==0)
{
TH1=highh;
TL1=highl;    
pulse=1;
flag2=1;    
}
else
{
TH1=lowh;
TL1=lowl;
pulse=0; //P1.1管脚电平跳变
flag2=0;
}
//TF1=0;
//TF0=0;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2010-09-11 00:28  51 智能小车\
     文件      175593  2010-04-09 23:34  51 智能小车\HMOTRORD.pdf
     文件      416461  2010-04-09 23:34  51 智能小车\MAINBORD.pdf
     文件      252268  2010-04-09 23:34  51 智能小车\SENSOR.pdf
     文件        5120  2010-09-11 00:28  51 智能小车\Thumbs.db
     文件      152576  2010-09-08 00:25  51 智能小车\小车各个部分的电路图.ppt
     目录           0  2010-05-03 18:26  51 智能小车\小车程序\
     文件        6236  2010-04-25 07:47  51 智能小车\小车程序\1
     文件        2891  2010-04-25 07:57  51 智能小车\小车程序\1.c
     文件        1603  2010-04-25 07:47  51 智能小车\小车程序\1.hex
     文件          50  2010-04-25 07:47  51 智能小车\小车程序\1.lnp
     文件        7133  2010-04-25 07:47  51 智能小车\小车程序\1.LST
     文件        8725  2010-04-25 07:47  51 智能小车\小车程序\1.M51
     文件        6505  2010-04-25 07:47  51 智能小车\小车程序\1.OBJ
     文件        1061  2010-04-25 09:53  51 智能小车\小车程序\1.Opt
     文件         186  2010-04-25 09:53  51 智能小车\小车程序\1.plg
     文件        2009  2010-04-25 07:39  51 智能小车\小车程序\1.Uv2
     文件        1062  2010-04-25 07:57  51 智能小车\小车程序\1_Opt.Bak
     文件           0  2010-04-25 05:36  51 智能小车\小车程序\1_Uv2.Bak
     文件        5115  2002-04-16 14:32  51 智能小车\小车程序\STARTUP.A51
     文件       11665  2010-04-25 15:55  51 智能小车\小车程序\STARTUP.LST
     文件         749  2010-04-25 15:55  51 智能小车\小车程序\STARTUP.OBJ
     文件        6504  2010-04-25 09:09  51 智能小车\小车程序\变速控制
     文件        2984  2010-04-25 09:09  51 智能小车\小车程序\变速控制.c
     文件        1807  2010-04-25 09:09  51 智能小车\小车程序\变速控制.hex
     文件          64  2010-04-25 09:09  51 智能小车\小车程序\变速控制.lnp
     文件        6938  2010-04-25 09:09  51 智能小车\小车程序\变速控制.LST
     文件        9247  2010-04-25 09:09  51 智能小车\小车程序\变速控制.M51
     文件        6954  2010-04-25 09:09  51 智能小车\小车程序\变速控制.OBJ
     文件        1078  2010-04-25 10:01  51 智能小车\小车程序\变速控制.Opt
     文件        1656  2010-04-25 09:09  51 智能小车\小车程序\变速控制.plg
............此处省略43个文件信息

评论

共有 条评论