自动蔽障论文程序Word下载.docx

上传人:b****6 文档编号:19980912 上传时间:2023-01-13 格式:DOCX 页数:12 大小:17.17KB
下载 相关 举报
自动蔽障论文程序Word下载.docx_第1页
第1页 / 共12页
自动蔽障论文程序Word下载.docx_第2页
第2页 / 共12页
自动蔽障论文程序Word下载.docx_第3页
第3页 / 共12页
自动蔽障论文程序Word下载.docx_第4页
第4页 / 共12页
自动蔽障论文程序Word下载.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

自动蔽障论文程序Word下载.docx

《自动蔽障论文程序Word下载.docx》由会员分享,可在线阅读,更多相关《自动蔽障论文程序Word下载.docx(12页珍藏版)》请在冰豆网上搜索。

自动蔽障论文程序Word下载.docx

unsignedcharcodeID[]={"

310808030304"

unsignedcharcodesensor1[]={"

Down:

"

unsignedcharcodesensor2[]={"

Ahead:

unsignedcharcodecharactor[]={'

0'

'

1'

2'

3'

4'

5'

6'

7'

8'

9'

.'

-'

C'

M'

 

staticunsignedcharDisNum=0;

//显示用指针

unsignedinttime=0,y;

unsignedlongS=0;

unsignedlongAnother_S=0;

bitflag=0;

unsignedchardisbuff[4]={0,0,0,0,};

voiddelay(unsignedintcnt)

{

while(--cnt);

}

/********************************************************/

voiddelay1ms(unsignedintms)

unsignedchari=100,j;

for(;

ms;

ms--)

{

while(--i)

{

j=10;

while(--j);

}

}

/*********************************************************/

/********************************************************/

voidConut(unsignedinty)

time=TH0*256+TL0;

TH0=0;

TL0=0;

S=(time*1.7)/100;

//算出来是CM

if((S>

=450)||flag==1)//超出测量范围显示“-

{

flag=0;

DisplayOneChar(8,y,charactor[11]);

DisplayOneChar(9,y,charactor[9]);

//显示点

DisplayOneChar(10,y,charactor[10]);

DisplayOneChar(11,y,charactor[9]);

DisplayOneChar(12,y,charactor[9]);

else

disbuff[0]=S%1000/100;

disbuff[1]=S%1000%100/10;

disbuff[2]=S%1000%10%10;

disbuff[3]=S%100%10%10;

DisplayOneChar(8,y,charactor[disbuff[0]]);

DisplayOneChar(9,y,charactor[disbuff[1]]);

DisplayOneChar(10,y,charactor[disbuff[2]]);

DisplayOneChar(11,y,charactor[10]);

DisplayOneChar(12,y,charactor[disbuff[3]]);

DisplayOneChar(13,y,charactor[12]);

//显示C

DisplayOneChar(14,y,charactor[13]);

//显示M

voidStartModule(bitTXC)//启动模块bitTXC

TXC=1;

//启动一次模块

_nop_();

TXC=0;

voidzd0()interrupt1//T0中断用来计数器溢出,超过测距范围

flag=1;

//中断溢出标志

voidalart(unsignedinta)

unsignedinti;

if(a==0)

while

(1)

for(i=0;

i<

100;

i++)//喇叭发声的时间循环,改变大小可以改变发声时间长短

{

delay(60);

//参数决定发声的频率,估算值,可以自行更改参数并

SPK=~SPK;

if(K1==0||K2==0||K3==0)

{SPK=0;

break;

}

if(K1==0||K2==0||K3==0)

if(a==1)

delay(30);

if(a==2)

delay(15);

voidcal(unsignedlongl,unsignedlongh)

if(l<

=2*h)

if((2*h-l)>

80)

alart

(2);

if((2*h-l)<

=80&

&

(2*h-l)>

40)

alart

(1);

if((((2*h-l)>

10)&

((2*h-l)<

=40)))

alart(0);

if(l>

2*h)

if((l-2*h)>

=40&

(l-2*h)<

=60)

=10&

=40)

voidmain(void)

unsignedcharTempCyc;

Delayms(400);

//启动等待,等LCM讲入工作状态

LCMInit();

//LCM初始化

Delayms(5);

//延时片刻(可不要)

DisplayListChar(2,0,Name);

DisplayListChar(1,1,ID);

ReadDataLCM();

//测试用句无意义

for(TempCyc=0;

TempCyc<

10;

TempCyc++)

;

//延时

TMOD=0x01;

//设T0为方式1,GATE=1;

ET0=1;

//允许T0中断

EA=1;

//开启总中断

DisplayListChar(0,0,sensor1);

StartModule(TX);

while(!

RX);

//当RX为零时等待

TR0=1;

//开启计数

while(RX);

//当RX为1计数并等待

TR0=0;

//关闭计数

Conut(0);

//计算

delay1ms(80);

//80MS

Another_S=S;

DisplayListChar(0,1,sensor2);

StartModule(Another_TX);

Another_RX);

//开启计数

while(Another_RX);

Conut

(1);

cal(S,Another_S);

//计算*/

Delayms(80);

//80MS*/

//写数据RS="

H"

RW=L,D0~D7=数据,E=高脉冲

voidWriteDataLCM(unsignedcharWDLCM)

{

dellay(100);

LCM_E=0;

LCM_RS=1;

LCM_RW=0;

LCM_Data=WDLCM;

//dellay(100);

//短暂延时,代替检测忙状态

//ReadStatusLCM();

//检测忙

LCM_E=1;

//写指令RS="

L"

RW=L,D0~D7=指令码,E=高脉冲

voidWriteCommandLCM(unsignedcharWCLCM,BuysC)

//BuysC为0时忽略忙检测

//if(BuysC)ReadStatusLCM();

//根据需要检测忙

LCM_RS=0;

LCM_Data=WCLCM;

//读数据RS="

RW=H,E=H

unsignedcharReadDataLCM(void)

LCM_RW=1;

return(LCM_Data);

//读状态RS="

unsignedcharReadStatusLCM(void)

LCM_Data=0xFF;

//while(LCM_Data&

Busy);

//检测忙信号

voidLCMInit(void)//LCM初始化

LCM_Data=0;

Delayms(15);

WriteCommandLCM(0x38,0);

//三次显示模式设置,不检测忙信号

WriteCommandLCM(0x38,1);

//显示模式设置,开始要求每次检测忙信号

WriteCommandLCM(0x08,1);

//关闭显示

WriteCommandLCM(0x01,1);

//显示清屏

WriteCommandLCM(0x06,1);

//显示光标移动设置

WriteCommandLCM(0x0C,1);

//显示开及光标设置

//按指定位置显示一个字符

voidDisplayOneChar(unsignedcharX,unsignedcharY,unsignedcharDData)

Y&

=0x1;

X&

=0xF;

//限制X不能大于15,Y不能大于1

if(Y)X|=0x40;

//当要显示第二行时地址码+0x40;

X|=0x80;

//算出指令码

WriteCommandLCM(X,1);

//这里不检测忙信号,发送地址码

WriteDataLCM(DData);

//按指定位置显示一串字符

voidDisplayListChar(unsignedcharX,unsignedcharY,unsignedcharcode*DData)

unsignedcharListLength;

ListLength=0;

while(DData[ListLength]>

0x1f)//若到达字串尾则退出

if(X<

=0xF)//X坐标应小于0xF

DisplayOneChar(X,Y,DData[ListLength]);

//显示单个字符

ListLength++;

X++;

//延时程序

voidDelayms(unsignedintn)

unsignedinti,j;

for(j=n;

j>

0;

j--)

for(i=112;

i>

i--);

/**************************************************

**函数名称:

dellay

**入口参数:

h(unsignedint型)

**出口参数:

**功能描述:

短暂延时,使用12MHz晶体,约0.01MS

****************************************************/

voiddellay(unsignedinth)

while(h--);

//0.01MS

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 职业规划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1