开短路测试程序.docx

上传人:b****1 文档编号:13636357 上传时间:2023-06-15 格式:DOCX 页数:11 大小:16.24KB
下载 相关 举报
开短路测试程序.docx_第1页
第1页 / 共11页
开短路测试程序.docx_第2页
第2页 / 共11页
开短路测试程序.docx_第3页
第3页 / 共11页
开短路测试程序.docx_第4页
第4页 / 共11页
开短路测试程序.docx_第5页
第5页 / 共11页
开短路测试程序.docx_第6页
第6页 / 共11页
开短路测试程序.docx_第7页
第7页 / 共11页
开短路测试程序.docx_第8页
第8页 / 共11页
开短路测试程序.docx_第9页
第9页 / 共11页
开短路测试程序.docx_第10页
第10页 / 共11页
开短路测试程序.docx_第11页
第11页 / 共11页
亲,该文档总共11页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

开短路测试程序.docx

《开短路测试程序.docx》由会员分享,可在线阅读,更多相关《开短路测试程序.docx(11页珍藏版)》请在冰点文库上搜索。

开短路测试程序.docx

开短路测试程序

#include<>"

#include"002-EEPROM读、写.h"

#include""

//==============================================

//延时1ms函数

//==============================================

voiddelay_ms(intms)

{

unsignedchari;

while(ms--)

{for(i=0;i<120;i++);}

}

//=============================================================================

//蜂鸣器响二声OK

//=============================================================================

voidbeep()

{unsignedchari;

for(i=0;i<4;i++)

{BEEP=!

BEEP;delay_ms(40);}//取反并延时

}

//=============================================================================

//蜂鸣器响一声NG

//=============================================================================

voidbeep_NG()

{unsignedchari;

for(i=0;i<2;i++)

{BEEP=!

BEEP;delay_ms(400);}//取反并延时

}

//=============================================================================

//计算加显示

//=============================================================================

voidxianshi()

{uinta,b,c,d;

 

d=((i/16)+1)/10;//求板十位

c=((i/16)+1)%10;//求板个位

b=((i%16)+1)/10;//求点十位

a=((i%16)+1)%10;//求点个位

LCD_disp_char(6,1,d+0x30);//显示板十位

LCD_disp_char(7,1,c+0x30);//显示板个位

LCD_disp_char(6,2,b+0x30);//显示点十位

LCD_disp_char(7,2,a+0x30);//显示点个位

}

//=============================================================================

//不良结果处理

//=============================================================================

voidfall_out(ucharl_h,s)

{

uchary;//

ucharspot;//开路与短路点的位置

ucharKL_DL;//开路与短路显示的量

uchardat;//开路与短路数据差

BEEP=0;

fall=0;

n=n+1;//不良数加一

if(cs_data>sd_tata_l[i])//区分开路与短路

{

dat=cs_data-sd_tata_l[i];//找出开路点的位置

KL_DL=0x4b;

}

else//短路

{

dat=sd_tata_l[i]-cs_data;//找出短路点的位置

KL_DL=0x44;

}

for(y=1;y<9;y++)

{

if(dat&0x01)//最低位是否为1

{spot=y;

break;

}

dat=dat>>1;

}

spot=spot+l_h;

xianshi();

LCD_disp_char(10,1,0X4e);//第一位数显示"N"(0X4e)

LCD_disp_char(11,1,0X47);//第二位数显示"G"(0X47)

LCD_disp_char(12,1,0x28);//第三位数显示"("(0X28)

LCD_disp_char(13,1,(n/10)+0x30);//显示这个板已测NG的点

LCD_disp_char(14,1,(n%10)+0x30);//显示这个板已测NG的点

LCD_disp_char(15,1,0x29);//显示")"(0X29)

LCD_disp_char(8,2,0x2d);//显示

LCD_disp_char(9,2,(spot/10)+0x30);//显示这个板NG的点

LCD_disp_char(10,2,(spot%10)+0x30);//显示这个板NG的点

LCD_disp_char(11,2,0x20);//

LCD_disp_char(12,2,KL_DL);//显示KD

LCD_disp_char(13,2,0x4c);//显示L

I1:

if(SW1==0)//按绿色键接着测试

{delay_ms(15);

while(!

SW1);

BEEP=1;

fall=1;

display();//待机显示

}

elseif(SW2==0)//按红色键不良数加50

{while(!

SW2);

delay_ms(15);

BEEP=1;

n=n+50;

}

else

{gotoI1;}//重复检测按键

}

//===================================================

//学习程序

//===================================================

voidxie_xi()

{

uinti;

while(SW3);//合上治具没有

delay_ms(16);

BEEP=1;

Send_595_wei(1,480);//输入点全部置1

Send_595_wei(0,1);//输入点送一个0第一点开始

Send_595B_wei(1,30);//输出点全部置1

Send_595B_wei(0,1);//输出点送一个0

IAP_erase(0x00,0x00);//扇区擦除-(高8位地址,低8位地址)

IAP_write(0x00,0x00,cs_data);//写数据-(高8位地址,低8位地址,数据值)

Send_595B_wei(1,1);//输出点送一个1

IAP_erase(0x10,0x00);//扇区擦除-(高8位地址,低8位地址)

IAP_write(0x10,0x00,cs_data);//写数据-(高8位地址,低8位地址,数据值)

//----------------------------------------------------------

for(i=1;i<16;i++)//

{

Send_595_wei(1,1);//输入点送一个1第二点开始

Send_595B_wei(1,30);//全部置1

Send_595B_wei(0,1);//输出点送一个0高8位

IAP_write(0x80,i,cs_data);//写数据-(高8位地址,低8位地址,数据值)

Send_595B_wei(1,1);//输出点送一个1

IAP_write(0x90,i,cs_data);//写数据-(高8位地址,低8位地址,数据值)

}

pass=0;

beep();

LCD_disp_char(10,1,0X50);//第一位数显示"p"(0X50)

LCD_disp_char(11,1,0X41);//第二位数显示"a"(0X41)

LCD_disp_char(12,1,0x53);//第三位数显示"s"(0X53)

LCD_disp_char(13,1,0x53);//第三位数显示"s"(0X53)

}

//===================================================

//测试程序

//===================================================

voidcscy()

{

uintw_data;

beep();

for(w_data=0;w_data<16;w_data++)

sd_tata_l[w_data]=IAP_read(0x00,w_data);//读数据-(高8位地址,低8位地址)

for(w_data=0;w_data<16;w_data++)

sd_tata_h[w_data]=IAP_read(0x10,w_data);

//------------------------------------------------------------------

while

(1)

{i=0;

T1:

while(!

SW3);//打开治具没有

delay_ms(16);

while(SW3);//合上治具没有

cs_data=0xff;i=0;n=0;BEEP=1;fall=1;pass=1;

delay_ms(16);

display();//待机显示

while(SW1);//开始测试

delay_ms(16);

while(!

SW1);

Send_595_wei(1,480);//输入点全部置1

Send_595_wei(0,1);//输入点送一个0

Send_595B_wei(1,30);//输出点全部置1

Send_595B_wei(0,1);//输出点送一个0

if(cs_data!

=sd_tata_l[i])//第一点前8位测试

{

fall_out(0);

if(n>=50)

gotoT1;

}

else

xianshi();

//delay_ms(150);

Send_595B_wei(1,1);//输出点送一个1

if(cs_data!

=sd_tata_h[i])//第一点后8位测试

{

fall_out(8);

if(n>=50)

gotoT1;

}

else

xianshi();

//delay_ms(150);

//----------------------------------------------------------

for(i=1;i<480;i++)//16*30=480

{

Send_595_wei(1,1);//送一个1第二点开始

Send_595B_wei(1,30);//全部置1

Send_595B_wei(0,1);//输出点送一个0

Send_595B_wei(1,(i/16)*2);//跳过已测试的板

if(cs_data!

=sd_tata_l[i%16])//前8位测试

{

fall_out(0);//单步NG处理

if(n>=50)

gotoT1;

}

else//单步OK处理

xianshi();

//delay_ms(150);

Send_595B_wei(1,1);//输出点送一个1

if(cs_data!

=sd_tata_h[i%16])//后8位测试

{

fall_out(8);

if(n>=50)

gotoT1;

}

else

xianshi();

//delay_ms(150);

}

if(n==0)//全部测完后OK处理

{

pass=0;

beep();

LCD_disp_char(10,1,0X50);//第一位数显示"p"(0X50)

LCD_disp_char(11,1,0X41);//第二位数显示"a"(0X41)

LCD_disp_char(12,1,0x53);//第三位数显示"s"(0X53)

LCD_disp_char(13,1,0x53);//第三位数显示"s"(0X53)

}

else//全部测完后NG处理

{

LCD_disp_char(10,1,0X4e);//第一位数显示"N"(0X4e)

LCD_disp_char(11,1,0X47);//第二位数显示"G"(0X47)

LCD_disp_char(12,1,0x28);//第三位数显示"("(0X28)

LCD_disp_char(13,1,(n/10)+0x30);//显示这个板已测NG的点

LCD_disp_char(14,1,(n%10)+0x30);//显示这个板已测NG的点

LCD_disp_char(15,1,0x29);//显示")"(0X29)

while(!

SW3)//打开治具没有

beep_NG();

}

}

}

//===================================================

//主程序

//===================================================

voidmain(void)

{

delay_ms(80);//延时

lcd_init();//初始化LCD

BEEP=1;//关闭蜂鸣器

display();//待机显示

//==================================================

while

(1)

{ucharm=0;

while(SW1);//按下按键没有

I1:

delay_ms(150);

if(SW1)//3秒钟前进入测试程序

{cscy();}

else

if(m<20)

{m++;gotoI1;}

else//3秒钟后进入学习程序

{

while(!

SW1)//放开

beep_NG();

BEEP=0;

xie_xi();

}

}

}

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

当前位置:首页 > 初中教育 > 语文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2