第一篇:出租車計(jì)價(jià)器畢業(yè)論文附錄
北京信息科技大學(xué)
畢業(yè)設(shè)計(jì)(論文)附錄
題 目:
學(xué) 院: 專 業(yè):
學(xué)生姓名: 班級/學(xué)號 指導(dǎo)老師/督導(dǎo)老師:
起止時(shí)間:2012 年 月 日 至 2012 年 月 日
目錄
附件1 原理圖············································共 1 頁
附件2 PCB圖 ··········································· 共 1頁
附件3 程序代碼 ········································· 共 19 頁
附件4 外文資料翻譯 ····································· 共 11 頁
原理圖
PCB圖
程序代碼
#include
uchar table2[]=“0123456789abcdef”;
sbit lcdwr=P2^6;sbit lcdrs=P2^5;sbit lcden=P2^7;sbit beep=P2^4;sbit sclk=P3^7;sbit io=P3^6;sbit rst=P3^5;sbit scl=P3^0;sbit sda=P3^1;
uchar model;//模式標(biāo)志位
uchar yue,ri,xq,shi,fen,miao;//月,日,星期,時(shí),分,秒 uchar qibu=50,danjia=5;uint zongjia,lucheng,zzongjia,zlucheng;uchar xiugai;//修改時(shí)間和起步價(jià)單價(jià)標(biāo)志 uint zj;uint zlc;uchar zu;//組數(shù) uint count;//定時(shí)器中的數(shù)
uint waitmiao,waitfen;//等待時(shí)間 uint count1,count2;//外部中斷中的數(shù) uchar xsfen,xsmiao;//行駛時(shí)間 uchar wait;//等待標(biāo)志 uint speed;//速度標(biāo)志
uchar cycount;//速度采樣值
void delayms(uint x){ uint i,j;for(i=x;i>0;i--)
for(j=110;j>0;j--);} void delay(){;;} /****************************** 1602液晶部分
******************************/ void yjwrite_com(uchar com){ lcdrs=0;P0=com;delayms(5);lcden=1;delayms(5);lcden=0;} void yjwrite_date(uchar date){ lcdrs=1;P0=date;delayms(5);lcden=1;delayms(5);lcden=0;} void yjinit(){ lcdwr=0;lcden=0;yjwrite_com(0x38);
yjwrite_com(0x0c);yjwrite_com(0x06);yjwrite_com(0x01);//顯示清0,指針清0 } /*************************************************************************************** DS1302時(shí)間部分
***************************************************************************************/ void write_byte(uchar com,uchar date)//向DS1302模地址寫數(shù)據(jù) { uchar i;rst=0;sclk=0;rst=1;for(i=0;i<8;i++){
if(com&0x01)io=1;
else io=0;
com>>=1;
sclk=0;
delayms(1);
sclk=1;} sclk=0;for(i=0;i<8;i++){
if(date&0x01)io=1;
else io=0;
date>>=1;
sclk=0;
delayms(1);
sclk=1;} sclk=0;rst=0;} uchar read_byte(uchar com){ uchar i,date;rst=0;sclk=0;rst=1;for(i=0;i<8;i++){
if(com&0x01)io=1;else io=0;
com>>=1;
sclk=0;
delayms(1);
sclk=1;} for(i=0;i<8;i++){
if(io)date|=0x80;
date>>=1;
sclk=1;
delayms(1);
sclk=0;} sclk=0;rst=0;return date;} void ds1302init(){ sclk=0;rst=0;write_byte(0x8e,0);//寫保護(hù)寄存器,最高位WP=1,寫保護(hù),WP=0,不寫保護(hù) // write_byte(0x90,0);//充電控制寄存器(此處為不充電)
write_byte(0x90,0xa5);//充電控制寄存器,設(shè)置為充電狀態(tài) } /*void reset_1302(){ write_byte(0x8e,0);write_byte(0x80,0);//秒
write_byte(0x82,0x43);//分
write_byte(0x84,0x13);//時(shí)
write_byte(0x86,0x14);//日
write_byte(0x88,0x10);//月
write_byte(0x8a,0x05);//星期
write_byte(0x8c,0x11);//年
write_byte(0x8e,0x80);//寫保護(hù)
} */
/****************************************************************************** AT24C02存儲與讀取部分
******************************************************************************/ void start1(){ sda=1;delay();scl=1;delay();sda=0;delay();} void stop1(){ sda=0;delay();scl=1;delay();sda=1;delay();} void respons(){ uchar i;scl=1;delay();while((sda==1)&(i<250))i++;scl=0;delay();} void init(){ sda=1;delay();scl=1;delay();} void write_byte1(uchar date){ uchar i,temp;temp=date;for(i=0;i<8;i++){
temp=temp<<1;
scl=0;
delay();
sda=CY;
delay();
scl=1;
delay();} scl=0;delay();sda=1;delay();} uint read_byte1(){ uchar i,k;scl=0;delay();sda=1;delay();for(i=0;i<8;i++){
scl=1;
delay();
k=(k<<1)|sda;
scl=0;
delay();} return k;} void write_add(uchar address,uint date){ start1();write_byte1(0xa0);respons();write_byte1(address);respons();write_byte1(date);respons();stop1();} uint read_add(uchar address){ uchar date;start1();write_byte1(0xa0);respons();write_byte1(address);respons();start1();write_byte1(0xa1);respons();date=read_byte1();stop1();return date;} /***************************************************************************************** 鍵盤檢測
*****************************************************************************************/ uchar key_scan(){ uchar k=0,temp;static uchar key_up=1;P1=0xff;temp=P1;if(temp!=0xff&&key_up){
delayms(10);
key_up=0;
temp=P1;
if(temp!=0xff)
{
temp=P1;
switch(temp)
{
case 0xfe:k=1;break;
case 0xfd:k=2;break;
case 0xfb:k=3;break;
case 0xf7:k=4;break;
case 0xef:k=5;break;
case 0xdf:k=6;break;
case 0xbf:k=7;break;
case 0x7f:k=8;break;
}
} } temp=P1;if(temp==0xff){
key_up=1;} return k;} void display_time();/**************************************************************************************** 時(shí)間起步價(jià)和單價(jià)調(diào)整部分
****************************************************************************************/ void tiaoshi(){ uchar i;uchar t=0,n=1;write_byte(0x8e,0);//寫保護(hù)寄存器,最高位WP=1,寫保護(hù),WP=0,不寫保護(hù)
yue=read_byte(0x89);ri=read_byte(0x87);xq=read_byte(0x8b);shi=read_byte(0x85);fen=read_byte(0x83);miao=read_byte(0x81);yue=(yue/16)*10+yue%16;ri=(ri/16)*10+ri%16;xq=(xq/16)*10+xq%16;shi=(shi/16)*10+shi%16;fen=(fen/16)*10+fen%16;miao=(miao/16)*10+miao%16;t=key_scan();if(t==6){ n++;if(n==10){
n=0;
xiugai=0;} } if(t==8){n=0;xiugai=0;} while(n){ t=key_scan();if(t==8){n=0;xiugai=0;} if(t==6){
n++;
if(n==10)
{
n=0;
xiugai=0;
goto a;
}
} switch(n){
case 1:
yjwrite_com(0x80);yjwrite_com(0x0f);delayms(5);
switch(t)
{
case 2:
yue++;
if(yue==13)yue=1;
write_byte(0x88,((yue/10)*16+yue%10));//
break;
case 3:
月
;
;
yue--;
if(yue==-1)yue=12;
write_byte(0x88,((yue/10)*16+yue%10));
break;
}
yjwrite_com(0x80);yjwrite_date(table2[yue/10]);yjwrite_date(table2[yue%10])
break;
case 2:
yjwrite_com(0x80+3);yjwrite_com(0x0f);delayms(5);
switch(t)
{
case 2:
ri++;
if(ri==32)ri=0;
write_byte(0x86,((ri/10)*16+ri%10));//日
break;
case 3:
ri--;
if(ri==-1)ri=31;
write_byte(0x86,((ri/10)*16+ri%10));
break;
}
yjwrite_com(0x80+3);yjwrite_date(table2[ri/10]);yjwrite_date(table2[ri%10])
break;case 3: yjwrite_com(0x80+6);yjwrite_com(0x0f);delayms(5);switch(t){
case 2:
xq++;
if(xq==8)xq=1;
write_byte(0x8a,((xq/10)*16+xq%10));//星期
break;
case 3:
xq--;
if(xq==-1)xq=7;
write_byte(0x84,((xq/10)*16+xq%10));
break;} yjwrite_com(0x80+5);yjwrite_date('-');yjwrite_date(table2[xq%10]);
break;
case 4:
yjwrite_com(0x80+0x40);yjwrite_com(0x0f);delayms(5);
switch(t)
{
case 2:
shi++;
if(shi==24)shi=0;
write_byte(0x84,((shi/10)*16+shi%10));
break;
case 3:
shi--;
if(shi==-1)shi=23;
write_byte(0x84,((shi/10)*16+shi%10));
break;
}
yjwrite_com(0x80+0x40);yjwrite_date(table2[shi/10]);yjwrite_date(table2[shi%10]);
break;
case 5:
yjwrite_com(0x80+0x43);yjwrite_com(0x0f);delayms(5);
switch(t)
{
case 2:
fen++;
if(fen==60)fen=0;
write_byte(0x82,((fen/10)*16+fen%10));//分
break;
case 3:
fen--;
if(fen==-1)fen=59;
write_byte(0x82,((fen/10)*16+fen%10));//分
break;
}
yjwrite_com(0x80+0x40+3);yjwrite_date(table2[fen/10]);yjwrite_date(table2[fen%10]);
break;
case 6:
yjwrite_com(0x80+0x46);yjwrite_com(0x0f);delayms(5);
switch(t)
{
case 2:
miao=0;
write_byte(0x80,((miao/10)*16+miao%10));//秒
break;
case 3:
miao=0;
write_byte(0x80,((miao/10)*16+miao%10));//秒
break;
}
yjwrite_com(0x80+0x40+6);yjwrite_date(table2[miao/10]);yjwrite_date(table2[miao%10]);
break;
case 7: //起步價(jià)調(diào)整
yjwrite_com(0x80+11);yjwrite_com(0x0f);
qibu=read_add(2);
switch(t)
{
case 2:qibu++;write_add(2,qibu);break;
case 3:qibu--;write_add(2,qibu);if(qibu==-1)qibu=0;break;
}
yjwrite_com(0x80+11);
//顯示起步價(jià)
yjwrite_date(table2[qibu/100]);
yjwrite_date(table2[qibu%100/10]);
yjwrite_date('.');
yjwrite_date(table2[qibu%10]);
break;
case 8: //單價(jià)調(diào)整
yjwrite_com(0x80+0x40+11);yjwrite_com(0x0f);
danjia=read_add(0);
t=key_scan();
switch(t)
{
case 2:danjia++;write_add(0,danjia);break;
case 3:danjia--;write_add(0,danjia);if(danjia==-1)danjia=0;break;
}
yjwrite_com(0x80+0x40+11);
//顯示單價(jià)
yjwrite_date(table2[danjia/100]);
yjwrite_date(table2[danjia%100/10]);
yjwrite_date('.');
yjwrite_date(table2[danjia%10]);
break;
case 9:zu=0;yjwrite_com(0x01);write_add(250,zu);
yjwrite_com(0x80);
yjwrite_date('C');yjwrite_date('l');yjwrite_date('e');yjwrite_date('a');
yjwrite_date('r');yjwrite_date('.');yjwrite_date('.');
for(i=3;i<247;i++)
{
write_add(i,0);
delayms(5);
}
yjwrite_com(0x80+0x40);yjwrite_date('O');yjwrite_date('K');
break;
} // display_time();} a: xiugai=0;write_byte(0x8e,0x80);//ds1302寫保護(hù)
yjwrite_com(0x0c);//1602液晶取消光標(biāo)閃爍 } /*********************************************** 按鍵處理函數(shù)
***********************************************/ void key_do(){ uchar num1,num2;uchar key=0;key=key_scan();switch(key){
case 1:model++;if(model==3)model=0;break;
case 4:
//啟動按鍵
TR0=1;
EX0=1;
count=0;count1=0;lucheng=0;zongjia=0,count2=0;
waitmiao=0;
waitfen=0;
xsfen=0;
xsmiao=0;
break;
case 5:
//停止按鍵
TR0=0;
EX0=0;
num1=lucheng/256;
write_add((7+zu*2),num1);
num2=lucheng%256;
delayms(5);
write_add((8+zu*2),num2);
num1=zongjia/256;
delayms(5);
write_add((127+zu*2),num1);
num2=zongjia%256;
delayms(5);
write_add((128+zu*2),num2);
delayms(5);
zu++;
if(zu==60)zu=0;
write_add(250,zu);
zzongjia=zzongjia+zongjia;
num1=zzongjia/256;
write_add(5,num1);
delayms(5);
num2=zzongjia%256;
write_add(6,num2);
delayms(5);
zlucheng=zlucheng+lucheng;//計(jì)算出累計(jì)的總路程
num1=zlucheng/256;//當(dāng)總路程超過255時(shí),一個(gè)字節(jié)就存儲不下了,需要分成兩個(gè)字節(jié)存儲
write_add(3,num1);
num2=zlucheng%256;//分離出總路程的低位字節(jié)
delayms(7);
write_add(4,num2);//存儲總路程的低位字節(jié)
break;
case 6:xiugai=!xiugai;break;
case 7:
wait=!wait;
if(wait==1)EX0=0;
else EX0=1;
break;
case 8:model=0;xiugai=0;break;} } void chaxun(){ static uchar n=0;uchar key=0,num,num1,a=0;num=read_add(3);//讀取總路程的高位
num1=read_add(4);//讀取總路程的高位
zlucheng=num*256+num1;num=read_add(5);//讀取總總價(jià)的高位 num1=read_add(6);//讀取總總價(jià)的高位 zzongjia=num*256+num1;yjwrite_com(0x80);yjwrite_date(table2[qibu/100]);//顯示起步價(jià) yjwrite_date(table2[qibu%100/10]);yjwrite_date('.');yjwrite_date(table2[qibu%10]);yjwrite_com(0x80+8);
//顯示單價(jià) yjwrite_date(table2[danjia/100]);yjwrite_date(table2[danjia%100/10]);yjwrite_date('.');yjwrite_date(table2[danjia%10]);yjwrite_com(0x80+0x40);yjwrite_date(table2[zlucheng/1000]);//顯示總路程 yjwrite_date(table2[zlucheng%1000/100]);yjwrite_date(table2[zlucheng%1000%100/10]);yjwrite_date('.');yjwrite_date(table2[zlucheng%10]);yjwrite_date('k');yjwrite_date('m');yjwrite_com(0x80+0x40+8);
//顯示總總價(jià) yjwrite_date(0x5c);//顯示人民幣的符號 yjwrite_date(table2[zzongjia/1000]);yjwrite_date(table2[zzongjia%1000/100]);yjwrite_date(table2[zzongjia%1000%100/10]);yjwrite_date('.');yjwrite_date(table2[zzongjia%10]);
key=key_scan();switch(key){ case 1:a=0;model=0;break;case 2:a=1;n++;if(n==60)n=0;break;case 3:a=1;n--;if(n==-1)n=59;break;case 8:a=0;model=0;break;} while(a){ key=key_scan();switch(key){
case 1:a=0;model++;break;
case 2:n++;if(n==60)n=0;break;
case 3:n--;if(n==-1)n=59;break;
case 8:a=0;break;
}
if(key==2||key==3)
{
yjwrite_com(0x01);
num=read_add(7+2*n);//讀取總路程的高位
num1=read_add(8+2*n);//讀取總路程的高位
zlc=num*256+num1;
num=read_add(127+2*n);//讀取總總價(jià)的高位
num1=read_add(128+2*n);//讀取總總價(jià)的高位
zj=num*256+num1;
yjwrite_com(0x80);
//顯示組數(shù)
yjwrite_date(table2[(n+1)/10]);
yjwrite_date(table2[(n+1)%10]);
yjwrite_com(0x80+0x40);
//顯示路程
yjwrite_date(table2[zlc/100]);
yjwrite_date(table2[zlc%100/10]);
yjwrite_date('.');
yjwrite_date(table2[zlc%10]);
yjwrite_date('k');
yjwrite_date('m');
yjwrite_com(0x80+0x40+8);
//顯示總價(jià)
yjwrite_date(0x5c);
yjwrite_date(table2[zj/100]);
yjwrite_date(table2[zj%100/10]);
yjwrite_date('.');
yjwrite_date(table2[zj%10]);
} } } void display_time(){ uchar i;uchar time[11];yue=read_byte(0x89);ri=read_byte(0x87);xq=read_byte(0x8b);shi=read_byte(0x85);fen=read_byte(0x83);miao=read_byte(0x81);time[0]=yue/16;//提取月的第一位數(shù)據(jù),讀出來的時(shí)間是16進(jìn)制的,所以對16取模
time[1]=yue%16;//提取月的第二位數(shù)據(jù) time[2]=ri/16;time[3]=ri%16;time[4]=xq%16;time[5]=shi/16;time[6]=shi%16;time[7]=fen/16;time[8]=fen%16;time[9]=miao/16;time[10]=miao%16;yjwrite_com(0x80);for(i=0;i<2;i++){ yjwrite_date(table2[time[i]]);} yjwrite_date('-');for(i=2;i<4;i++){ yjwrite_date(table2[time[i]]);} yjwrite_date('-');yjwrite_date(table2[time[4]]);yjwrite_com(0x80+11);
//顯示起步價(jià) yjwrite_date(table2[qibu/100]);yjwrite_date(table2[qibu%100/10]);yjwrite_date('.');yjwrite_date(table2[qibu%10]);yjwrite_com(0x80+0x40+11);
//顯示單價(jià) yjwrite_date(table2[danjia/100]);yjwrite_date(table2[danjia%100/10]);yjwrite_date('.');yjwrite_date(table2[danjia%10]);yjwrite_com(0x80+0x40);for(i=5;i<7;i++){ yjwrite_date(table2[time[i]]);} yjwrite_date(':');for(i=7;i<9;i++){ yjwrite_date(table2[time[i]]);} yjwrite_date(':');for(i=9;i<11;i++){
yjwrite_date(table2[time[i]]);}
} void main(){ uchar fristtime=0,fristtime1=0,fristtime2=0;ds1302init();//ds1302初始化
init();//24c02初始化
yjinit();//1602液晶初始化 // reset_1302();danjia=read_add(0);qibu=read_add(2);TMOD=0X01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;IT0=1;zu=read_add(250);PT0=1;while(1){
key_do();
switch(model)
{
case 0:
fristtime1=0;
fristtime2=0;
if(fristtime==0)
{
yjwrite_com(0x01);
fristtime=1;
}
if(lucheng>30)
zongjia=(qibu*10+(danjia*(lucheng-30)))/10;
else
zongjia=qibu;
yjwrite_com(0x80);
//顯示行駛時(shí)間
yjwrite_date(table2[xsfen/10]);
yjwrite_date(table2[xsfen%10]);
yjwrite_date('-');
yjwrite_date(table2[xsmiao/10]);
//
yjwrite_date(table2[xsmiao%10]);yjwrite_date(' ');yjwrite_date(table2[waitfen/10]);//顯示等待時(shí)間
yjwrite_date(table2[waitfen%10]);yjwrite_date('-');yjwrite_date(table2[waitmiao/10]);yjwrite_date(table2[waitmiao%10]);yjwrite_date(' ');yjwrite_date(table2[speed/100]);//顯示速度
yjwrite_date(table2[speed%100/10]);yjwrite_date('.');yjwrite_date(table2[speed%10]);if(speed>650)beep=0;else beep=1;yjwrite_com(0x80+0x40);
//顯示路程的yjwrite_date(table2[lucheng/100]);yjwrite_date(table2[lucheng%100/10]);yjwrite_date('.');yjwrite_date(table2[lucheng%10]);yjwrite_date('k');yjwrite_date('m');yjwrite_date(' ');yjwrite_date(table2[(zu+1)/10]);//顯示當(dāng)前組數(shù)
yjwrite_date(table2[(zu+1)%10]);yjwrite_date(' ');yjwrite_com(0x80+0x40+10);
//顯示總價(jià)
yjwrite_date(0x5c);yjwrite_date(table2[zongjia/1000]);yjwrite_date(table2[zongjia%1000/100]);yjwrite_date(table2[zongjia%1000%100/10]);yjwrite_date('.');yjwrite_date(table2[zongjia%10]);break;case 1: fristtime=0;fristtime2=0;if(fristtime1==0){
yjwrite_com(0x01);
fristtime1=1;} display_time();if(xiugai==1){
tiaoshi();
}
break;
case 2:
fristtime=0;
fristtime1=0;
if(fristtime2==0){yjwrite_com(0x01);fristtime2=1;}
chaxun();
break;
}
}
} void timer0()interrupt 1 { TH0=(65536-50000)/256;TL0=(65536-50000)%256;count1++;if(count1==20){
speed=cycount*9;
cycount=0;
count1=0;
xsmiao++;
if(wait==1)
{
waitmiao++;
if(waitmiao==60){waitmiao=0;waitfen++;}
}
if(xsmiao==60)
{
xsmiao=0;
xsfen++;
}
} } void ex0()interrupt 0 { count++;cycount++;if(count==12){
} count=0;count2++;} lucheng=count2*1;
外文資料翻譯
ABSTRACT In this paper, a multi-channel taximeter that is able to deal with more than one passenger simultaneously is proposed.In order to demonstrate the theory of operation of the proposed system, a complete design for an experimental three-channel taximeter(whose prototype has been built under grant from the Egyptian Academy for Scientific and Technological Research)is presented.System location, outline, block diagrams as well as detailed circuit diagrams for the experimental taximeter are also included.1.INTRODUCTION Transporting people in the morning from their homes to their works and back in the afternoon has become a big problem in big cities especially in undeveloped countries.As a partial solution of this problem, the authorities in some countries had, unofficially, left the taxicab drivers to carry different passengers to different places at the Same time.For example, a taxicab with four seats may carry four different passengers without any relation between them except that their way of travelling is the same.Accordingly, it has become very difficult to rely on the present conventional single-channel taximeter to determine the fare required from each passenger separately.Accordingly, an unfair financial relation was created between the taxicab driver, owner, passengers and the state taxation department.Under these circumstances, taxicab drivers force the passengers to pay more than what they should pay.In some cases passengers had to pay double fare they should pay.With the present conventional single-channel taximeter, taxicab owners are not able to determine the daily income of their taxicab.In some cases(a taxicab with four seats)they may only get one quarter of the income of the taxicab(collected by the taxicab driver).From which they should pay the salary of the taxicab driver as well as the cost of fuel, minor and major repairs in addition to the car depreciation.As a matter of fact the position of the taxicab owners is not so bad as it seems.A general agreement has been reached between the taxicab drivers and owners such that the drivers should guarantee a fixed daily income to the owners as well as the paying for the cost of fuel as well as the minor repaires.Even though the taxicab drivers still share the large portion ofthe income of the taxicab.Also with the presence of the single-channel taximeter, it has become very difficult for the state taxation department to know the yearly income of the taxicab and accordingly it has become very difficult to estimate the taxes to be paid by the taxicab owners.In order to face this problem, the state taxation department had to impose a fixed estimated taxes for each seat of the taxicab whatever the income of the taxicab.In this paper, we introduced a multichannel taximeter that can deal with more than one passenger simultaneously.I t should be pointed out that by the term passenger we mean a one person or a group of related persons.I t should also be pointed out that our proposed multi-channel taximeter is not, simply, a multi display readouts.As a matter of fact it contains logic circuits that automatically changes the fare per killometer of travelling distance or per minutes of 'waiting time according to the number of passengers hiring the taxicab.In the following part and as an example, we will present a complete design for a three-channel taximeter.Block diagrams as well as detailed circuit diagrams of the experimental three-channel taximeter are also included.A prototype has been built under grant from the Egyptian Academy for Scientific and Technological Research.2.AN EXPERIMENTAL THREECHANNEL TAXIMETER Theory of operation of our experimental device to work as an electronic digital taximeter is based on t h e fact thathe speedometer cable rotates one revolution for each meter of travelling distance.Accordingly, if the speedometer cable is coupled with a speed sensor that generates a single pulse for each meter of travelling distance, then our taximeter could be three up counter modules associated with a speed sensor unit.However, our experimental taximeter is not simply a three display readouts.As a matter offact it contains logic circuits that automatically changes the fare per kilometer of travelling distance or per minutes of waiting time according to the number of passengers hiring the taxicab.The device may be splitted into two main parts: The first is the speed sensor unit which may be located anywhere in the taxicab such that an easy coupling to the speedometer cable can be achieved.The second unit contains the main electronic circuit, the displayand control panel.The unit should be located somewhere in front of both the driver and the passengers.A possible components locations is shown in Figure 1.A.Speed Sensor Unit The main function of this unit is to supply train of pulses whose frequency is proportional to the angular rotation of the wheels.A possible form of a speed sensor is shown in Figure 2.If may consist of a tj.pica1 permanent magnet sine wave generator with its output connected to a pulse shapping circuit(two general purpose silicon diodes, 1K ohms resistor and a schmit trigger inverter).In order to find some way to detect the movement of the taxicab, the output of the sine wave generator is rectified through a general purpose silicon diode Dl then smoothed by a 1000 F capacitor.The output voltage at terminal Q is then limited to the value of 4.7 volts by using a Ik ohms resistor as well as a zener diode ZD.The level of the voltage at terminal Q would be high whenever the taxicab is moving and will be zero otherwise.This voltage can be used for the automatic switching from distance fare to time fare.B.Main Electronic and Display Unit A suggested shape for the main electronic and display unit is shown in Figure 3.The control and display panel contains all ' controls necessary for operating the taximeter as well as four readout displays.The first channel will give the sum of money required from the first passenger, while the second and third readouts are for the second and third passengers, respectively.The fourth readout will give the total income of the taxicab.The contents of the last readout should be nonvolatile and be able to be retained even during parking the taxicab.The channel rotary selector switchs 1 , 2 and 3 have fully clockwise/anticlockwise positions.In the fully anticlockwise position, the counter of the corresponding readout is blancked and disabled.In the fully clockwise position, the counter is unblanked, cleared to zero and enabled to be ready for counting the sum of money required from the first, second and third passengers, respectively.Pushing the total sum pushbutton 4 unblanks the fourth readout enabling any person to retain the readout corresponding to the total income.After the release of the pushbutton, the fourth readout will be blanked again.This unit also contains the main electronic circuit which will be fully described in the following section.3.DESCRIBTION OF THE MAIN ELECTRONIC CIRCUIT The general block diagram of the main electronic circuit is shown in Figure 4.It consists of five subcircuits designated by the symboles CTI up to CT4supporting circuits, these are: The number of passenger deticition circuit CTI, travelling distance scaling circuit CT2, waiting time scaling circuit CT3, circuit CT4 which generates clock pulses for the display circuit.A.Number of Passengers Detection Circuit CT1 As shown from the general block diagram, the circuit CTI has three inputs I, 2 and 3 as well as three outputs J, K and L.The function of the circuit is to supply a high level voltage at terminals J, K or L if and only if one, two or three passengers are hiring the taxicab, respectively.The term passenger, here, means one person or a group of related persons.When a passenger is getting into the cab, we simply turn on a free readout display by turning the corresponding rotary selector switch to a fully clockwise direction.This will automatically disconnect the corresponding terminal I, 2 or 3 from ground.The logical relation between various input terminals I, 2 and 3 and the output terminals J, K and L is shown in Table 1.As a combinational circuit we start the design by deriving a set of boolean functions.A possible simplified boolean functions that gives minimum number of inputs to gates may be obtained from Table I.A possible logical diagram that is based on the above derived expressions is shown in Figure 5.It consists of two inverters, four 2-input AND, to3-input AND two 3-input OR gates B.Tavelling Distance Scaling Circuit CT2 As shown from the block diagram of Figure 4, the circuit CT2 has four input J, K, L and E and one output M.The function of the circuit is to supply a single pulse at the output M for a certain number of pulses generated at the output of the speed sensor(certain number of meters travelled by the taxicab), according to the number of passengers hiring the car.A suggested fare per kilometer of travelling distance is shown in colomn two of Table 2.the circuit, in this case, should supply a single pulse at the output M for every 100, 125 or 143 pulses generated at the input terminal E according to the level of voltage at input terminale 3, K or L, respectively.Our circuit could be, as shown in Figure 5, three decade counters, connected as a three digit frequency divider whose dividing ratios 100, 125 and 143 are automatically selected by the voltage level at terminals J, K and L, respectively.A possible circuit diagram that may verify the above function is shown in Figure 6.It consists of three decade counters type 7490, one BCD-to decimal decoder type 7445, three 4-input AND, one 3-input ANDone 2-input AND two 3-input OR gates.C.Time Scaling Circuit CT3 As shown in the block diagram, the time scalingcircuit will have four inputs J, K, L and F and one output N.The function of this circuit and accordingto colomn three of Table 2(fare per 2 minuts of waiting time)is to supply a single pulse at the output N for every 120, 240 or 360 pulses supplied at the input terminal F from the I Hz clock according to level of voltage at inputs J, K and L, respectively.Time scaling circuit would be similar to the distance scaling circuit but with different diving ratios.A Possible circuit diagram is shown in figure 7.It consists, in this case, of three decade counter type 7490, two 3-input AND, one 5-input AND, one 2-input AND one 3-input OR gates.D.Circuit CT4 Which Generates Clock Pulses for Display Circuit The function of this circuit is to supply one, two or three pulses at the output terminal R for each pulse generated at any of the terminals N or M, according to the voltage level at the input terminals J, K or L, respectively.The output P will receive a pulse for each pulse generated at any of the input terminals N or M.This function can be performed by the circuit shown in Figure 8, it consists of one ripple counter type 7493, one half of a dual JK masterslave flip-flops circuit type 7476, three inverters, three 2-input AND, one 3-input AND, one 2-input OR and one 3-input OR gates.When a pulse is generated at either input terminals N or M, a high level voltage will be generated at the output Q of the flip-flop.This will g a t e t h e I Khz signal to be connected to the input A of the ripple counter as well as to the output terminal R.When one, two or three pulses are counted by the ripple counter, according to the level of voltage at the input terminals J, K and L, respectively, a high is generated to reset the counter and change the state of the flip-flopsuch that Q becomes low.Hence, the 1 KHz signal is disabled to reach the outputerminal R or the input A of the ripple counter.In order to ensure the proper function of the circuit, the flip-flop should be cleared whenever a new channel is operated.This has been achieved by the input 5 and will be explained later when describing the function of the channels rotary selector switchs.E.Display Circuit As shown in Figure 2, the display panel would contain three 4-digit displays that give the sum of money required from each passenger separately as well as a one six-digit display that gives the total income of the taxicab.A possible wiring diagram for the display circuit is shown in Figure 9.Rotating any of the rotary selector switches to fully clockwise direction will supply the corresponding display by5 volts through terminals 1, 2 and 3, respectively.The corresponding display will be unblanked by supplying a low level of voltage through terminals A, C and G, respectively.Keeping terminals 8, D and H, respectively, at low level will keep them reset to zero.The corresponding display is then enabled by removing the low voltage from terminals B, D, and H, respectively, to be ready for counting the sum of money required from the corresponding passenger starting from zero.The counting pulses for these three displays are supplied through terminal P.The total sum display will be enabled whenever any of the three displays is enabled(this is done by a 3-input OR gate as shown in Figure 8).Retaining the contents of the last display will be done by unblanking it by supplying a low level of voltage to terminal I as shown in Figure 10 b.F.Changing Over Between Time and Distance Fares In the following part, two different methods for changing over between time andistance fares are suggested: The first is to switch to time fare whenever the distance fare is less than the time fare.Hence, a simple look to fares table(Table 2)can show that time fare should be used whenever the taxicab moves with speed less than 50 m/min.A possible circuit that can perform this switching action is shown in Figure IO c.It contains one rpm limit switch and a one inverter as well as two 2-input AND gates.The contacts of the limit switch are normally closed and will be opened whenever the angular speed of the speedometer cablexceeds 50 rmp.The second alternation is to connect the input of the inverter in Figure 10 c.to the output terminal Q of the speedometer circuit, Figure 2.In this case, the switching into time fare will be done whenever the taxicab is at stand still.G.Function of the Rotary Selector Switches The voltage levels that should be supplied by the terminals of the rotary selector switches in order to ensure proper operation by the electronic circuit are given in Table 3.Connection of three rotary selector switches each witb four decks of five poles each, that satisfy the logic function of Table 3, is shown in Figure 10 a.Rotating any of the three switches into fully clockwise direction will pass through five positions.The function of the rotary selector switches can be described starting from the first position passing through variousteps until reaching the final position as follows: Initial position: In this position a low voltage level is applied to terminals I, 2 and 3, this will disconnect the 5 volts supply from the three first displays, set the three inputs of the number of passenger detection circuit CTI to low level.A low voltage level is applied to terminals 8, D and H, this is to ensure that the total income display is disabled.Voltage levels at terminals A, C, G and S are at no care condition.Step I: Rotating any of the rotary selector switches one step toward clockwise direction will supply 5 volts to the corresponding display, provides a high level voltage at terminals 1, 2 or 3 indicating that one passenger have entered the taxicab.A high level voltage should be applied to terminals A, C or G in order to ensure that the corresponding display is still blanked.Other terminals B, D, H and S are kept unchanged.Step 2: Rotating the rotary selector switch one step further, will change the state of voltages at terminal A, C or G to be at low level and unblanks the corresponding display.States of voltages at terminals I, 2, 3 and S are remained unchanged.Terminals B, D and H should be remained at low level to ensure that the corresponding readout is cleared to zero while unblanking the display.二、中文翻譯
摘要
本文提出了一種出租車多通道計(jì)價(jià)的方案,能同時(shí)處理一個(gè)以上乘客的情形。為了從理論上說明本方案,提出了一個(gè)實(shí)驗(yàn)上的三通道型的士的完整設(shè)計(jì)(其原型是根據(jù)埃及科學(xué)和技術(shù)研究學(xué)院的研究而建成得)。.導(dǎo)言
在不發(fā)達(dá)的國家,早上把人們從他們家送到工作的地方,然后下午送回來已成為一個(gè)大問題,尤其是在大城市。
作為解決這個(gè)問題的一個(gè)部分,在某些國家出租車用來解決這個(gè)問題,送人們從一個(gè)地方到另外一個(gè)地方。例如,出租車的四個(gè)席位可攜帶四個(gè)不同的沒有任何關(guān)系的乘客,除了他們的路線是相同的。
因此,依靠目前的傳統(tǒng)的單車道計(jì)價(jià)以確定所需的票價(jià),把每個(gè)乘客的計(jì)費(fèi)分開,這已成為一個(gè)非常困難的問題。因此,在出租車司機(jī),車主,乘客和國家稅務(wù)部門之間存在著不公平的財(cái)政關(guān)系。
在這種情況下,出租車司機(jī)強(qiáng)迫乘客支付多于他們所應(yīng)付的。在某些情況下乘客支付了他們應(yīng)付車費(fèi)的雙倍。
本常規(guī)單頻道計(jì)程車,出租車司機(jī)不能夠確定出租車日常收入。在某些情況下(出租車的4個(gè)席位),他們可能只有出租車四分之一的收入(大部分的出租車司機(jī))。從這些支付工資的出租車司機(jī)以及作為燃料費(fèi)用外,還要維修以及汽車折舊等費(fèi)用。事實(shí)上,出租車業(yè)主并非似乎如此糟糕。一項(xiàng)在出租車司機(jī)和車主之間的協(xié)議已經(jīng)達(dá)成,司機(jī)應(yīng)保證每天固定收入,以及向業(yè)主支付燃料以及維修的費(fèi)用。即使如此,還是有的出租車司機(jī)的很大一部分份額之收入的出租車?,F(xiàn)在還存在的單聲道計(jì)價(jià),已經(jīng)變得非常,國家稅務(wù)部門也知道這種困難 每年估計(jì)出租車業(yè)主的收入支出,以及應(yīng)支付的稅務(wù)也很困難。
為了應(yīng)對這一問題,國家稅務(wù)部已實(shí)行固定估計(jì)稅,每個(gè)座位的出租車不論收入。在本文中,我們介紹了多通道的士計(jì)程表,可處理超過一名乘客同時(shí)進(jìn)行的情況。我應(yīng)該指出,我所說的長期旅客指一個(gè)人或一組相關(guān)的人。我同時(shí)也應(yīng)指出,我們提出的多渠道的計(jì)價(jià),不是簡單地說,一個(gè)多顯示讀數(shù)。作為一個(gè)先進(jìn)的事項(xiàng),事實(shí)上它包含邏輯電路,可以自動計(jì)算變化的車費(fèi)以及每公里行走距離或每分鐘的候車時(shí)間按照乘客人數(shù)雇用出租車。在下面的部分,我舉出一個(gè)例子,我們將介紹一個(gè)完整的三通道計(jì)價(jià)??驁D以及詳細(xì)的電路圖,實(shí)驗(yàn)三通道計(jì)價(jià)功能也包括在內(nèi)。原型下已建成 埃及贈款科學(xué)學(xué)院 和技術(shù)研究。.實(shí)驗(yàn)THREECHANNEL 出租車計(jì)價(jià)器理論的運(yùn)作我們的實(shí)驗(yàn)裝置從事電子數(shù)字計(jì)價(jià)依據(jù)。事實(shí)上速度電纜旋轉(zhuǎn)1 圈的每米距離行駛。因此,如果車速電纜耦合與速度傳感器,產(chǎn)生一個(gè)單脈沖每平方米的旅行距離,那么,我們的的士可以三倍于反模塊相與速度傳感器的單位。然而,我們的實(shí)驗(yàn)是計(jì)價(jià)而不僅僅是只顯示三個(gè)讀數(shù)。事實(shí)上,它包含邏輯電路,可以根據(jù)每公里的行駛距離或每分鐘等候時(shí)間按照乘客人數(shù)雇用出租車來自動改變車費(fèi)。該裝置可能會分成兩個(gè)主要部分組成:第一是速度傳感器,這個(gè)傳感器可位于任何地方,在出租車內(nèi)進(jìn)行這樣一個(gè)簡單的耦合車速電纜是可以實(shí)現(xiàn)的。
單位包含了主要的電子電路,顯示器以及控制面板。該單位應(yīng)位于前排的司機(jī)和乘客之間。
A. 速度傳感器
其主要職能是本單位提供脈沖的培訓(xùn),這個(gè)脈沖的頻率會于旋轉(zhuǎn)角度相適合。一種可能的形式一個(gè)速度傳感器。如果可以包含正弦波發(fā)生器的輸出連接到脈沖整形電路的永磁器件(2通用芯片二極管,1000歐姆的電阻和施密特觸發(fā)逆變器)。
為了找到某種方式來檢測出租車的運(yùn)動,正弦波發(fā)生器的輸出是糾正通過一個(gè)通用的硅二極管延胡索乙然后平滑的1000年F電容。那個(gè)輸出電壓在終端Q是當(dāng)時(shí)限于價(jià)值4.7伏特用益歐姆的電阻以及一個(gè)齊納二極管ZD。出租車的終端電壓在終端Q將高電壓降為零。這電壓可作為改變出租車從距離計(jì)費(fèi)到時(shí)間計(jì)費(fèi)方式的開關(guān)電壓。
主要的電子和顯示單元
一個(gè)建議是主要形式的電子和顯示單元??刂坪惋@示器面板包含所有'控制所必需的經(jīng)營的士以及四個(gè)可讀顯示器。第一頻道將給出從第一乘客,第二乘客,第三乘客分別應(yīng)付的費(fèi)用,第四個(gè)會給出總收入給予出租車。最后讀出的數(shù)據(jù)會包括停車的費(fèi)用等等費(fèi)用。頻道選擇器開關(guān)1,第2和第3個(gè),按順時(shí)針/逆時(shí)針的立場。在充分逆時(shí)針的立場,反相應(yīng)的讀出是未標(biāo)明和殘疾人。以順時(shí)針方向則是未定義的,清除為零,對于第一第二第三的乘客分別計(jì)費(fèi)。第四號推進(jìn)總鈕第四次讀出,使任何人保留讀出相應(yīng)的總收入。經(jīng)過釋放按鈕,第四次讀出將再次保留。這個(gè)單位還包含主要電子電路將在下一節(jié)充分描述。描述的主要電子電路
它由五個(gè)部分指定的電腦符號與電話系統(tǒng)整合成為4個(gè)支撐電路,它們是:判斷乘客數(shù)量電路CT1,旅行距離電路CT2,等待時(shí)間電路CT3,時(shí)鐘脈沖顯示電路CT4。
乘客人數(shù)檢測電路CT1如圖所示的一般框圖,該電路電腦與電話系統(tǒng)整合有三個(gè)輸出:1,2和3相對應(yīng)于三個(gè)輸出J,K和L。
這個(gè)循環(huán)電路函數(shù)包含高電壓的終端 J,K或L,如果有1個(gè)或者2,3個(gè)乘客分別租用出租車。這個(gè)組里的任意乘客都是一組相關(guān)的人。當(dāng)一個(gè)乘客進(jìn)入出租車后,我們只是表示這樣一種情況,自由讀出顯示在談到相應(yīng)的旋轉(zhuǎn)選擇開關(guān),以一個(gè)完全順時(shí)針方向。這將自動斷開相應(yīng)的終端1,2或3個(gè)從地面。邏輯關(guān)系各種輸入端子之間第1,第2和第3個(gè)輸出端J,K和L是列于表1。作為一個(gè)組合電路,我們開始設(shè)計(jì)產(chǎn)生了一系列布爾函數(shù)。
一種可能的邏輯圖的基礎(chǔ)上,它包括兩個(gè)變頻器,4個(gè)2輸入和3輸入以及2個(gè)3輸入或門。B.行駛距離標(biāo)量環(huán)路CT2,電路CT2有4個(gè)輸入J,K,L及E和1個(gè)輸出M,輸出功能的電路是供應(yīng)單脈沖的輸出M的某一些脈沖產(chǎn)生的輸出的速度傳感器(出租車行駛了一定得距離),根據(jù)乘客的人數(shù)租用的汽車。我們建議票價(jià)按每公里行駛距離顯示在兩個(gè)表格2里面。
表2 這個(gè)環(huán)路,在這種情況下,應(yīng)提供單脈沖的輸出M的每100,125或143脈沖所產(chǎn)生的輸入端根據(jù)級別的電壓輸入終端3,K或L。
我們的電路按圖5顯示,三個(gè)十年的計(jì)數(shù)器,作為一個(gè)三位數(shù)分頻器的分比率100,125和143個(gè)自動選定的電壓一級終端J,K和L分別。一種可能的線路圖可被驗(yàn)證,它包括三個(gè)十年的計(jì)數(shù)器7490,一個(gè)聲BCD-以杜威解碼器輸入7445,3個(gè)4輸入和1個(gè)3輸入以及1個(gè)2輸入和2個(gè)3輸入或門。
時(shí)間縮放電路CT3.時(shí)間縮放電路含有4個(gè)輸入端 J,K,L及F和一個(gè)輸出端N,這個(gè)電路的函數(shù)根據(jù)表格2的意思(車費(fèi)每2分鐘的等待時(shí)間)是在J,K和L分別供應(yīng)單脈沖到輸出端N時(shí),提供單脈沖的輸出N。時(shí)間縮放電路將類似于距離標(biāo)量環(huán)路,但是有不同的行駛比率。它包括3個(gè)十進(jìn)制計(jì)數(shù)器7490,2個(gè)3輸入與門和一個(gè)5輸入與門,1個(gè)2輸入與門和一個(gè)3輸入或門。
電路產(chǎn)生時(shí)鐘脈沖的顯示電路CT4 這條電路的作用根據(jù)電壓電平在輸入終端J、K或者L,分別供應(yīng)1,2或者脈沖在每脈沖的輸出終端R引起在任何終端N或M。無論輸入端N或者M(jìn)中的誰發(fā)送脈沖,都只有一個(gè)脈沖能被輸出端P接收。它由一個(gè)反向計(jì)數(shù)器7493構(gòu)成,其中一半是雙JK主從觸發(fā)器電路,型號為7476,包括三個(gè)變頻器,三個(gè)2輸入與門,一個(gè)3輸入與門,1 2輸入或門以及一個(gè)3輸入或門。當(dāng)脈沖引起在輸入的終端N或M,觸發(fā)器的輸入Q上將產(chǎn)生高級電壓。這個(gè)門信號將被連接到計(jì)數(shù)器的輸入A并且連接到輸出終端R。當(dāng)?shù)谝?,第二或第三個(gè)脈沖由漣波計(jì)數(shù)器開始計(jì)數(shù),J,K,L端會分別根據(jù)電壓的大小來使產(chǎn)生重置或者翻轉(zhuǎn)來改變狀態(tài),然后Q端變?yōu)檩敵龅碗妷?。因此? KHz信號沒有能力到達(dá)輸出端R或是計(jì)數(shù)器的輸入端A。為了確保電路的函數(shù)準(zhǔn)確無誤,當(dāng)切換到新頻道時(shí),觸發(fā)器要清零。對于功能選擇開關(guān)旋轉(zhuǎn)渠道的描述,稍后會以一個(gè)成功的5輸入門函數(shù)來解釋。顯示電路
該顯示面板將包含三個(gè)4位數(shù)顯示器,這樣可以給出每個(gè)乘客應(yīng)付車費(fèi)的總和,一個(gè)六位數(shù)顯示器可以給出出租車的總收入。以順時(shí)針方向旋轉(zhuǎn)所選擇的開關(guān)將提供相應(yīng)的顯示,這可以通過5伏電壓來分別控制1,第2和3終端。對應(yīng)的顯示通過供應(yīng)低級電壓通過終端A、C和G,分別。保持終端D和H在低級狀態(tài)下重置為零對應(yīng)的顯示分別通過終端B,D,H而改變低壓狀態(tài),并準(zhǔn)備好從對應(yīng)的乘客那里計(jì)算出相應(yīng)的計(jì)數(shù)款額,計(jì)數(shù)脈沖這三個(gè)顯示器通過終端提供總額。計(jì)數(shù)器還將通過終端P為3個(gè)顯示器提供脈沖只要這三個(gè)顯示器中任意一個(gè)是正常的,那么總額將被顯示出來。
時(shí)間和距離變化時(shí)車費(fèi)的改變
在下面的部分,兩種不同的方法使得時(shí)間和距離改變從而導(dǎo)致車費(fèi)發(fā)生變化,有如下建議:首先是當(dāng)以路程計(jì)價(jià)的費(fèi)用低于以時(shí)間計(jì)費(fèi)的費(fèi)用時(shí),采用時(shí)間計(jì)費(fèi)。從此,一個(gè)簡單的票價(jià)表顯示當(dāng)出租車移動速度小于50米/分時(shí)應(yīng)該采用時(shí)間計(jì)費(fèi)方式。一種可能的電路可以執(zhí)行此開關(guān)行動如圖10c,它包含一個(gè)轉(zhuǎn)速限位開關(guān)和一個(gè)反轉(zhuǎn)器以及兩個(gè)2輸入與門。接觸的限位開關(guān)通常是封閉,只有當(dāng)角速度超過50RMP的時(shí)候才會打開。第二個(gè)改變將中斷連接到圖10C的輸入端,輸出端Q連接速度的電路。在這種情況下,只要出租車的狀態(tài)保持靜止,那么計(jì)費(fèi)開關(guān)就會處于關(guān)閉狀態(tài)。
功能選擇旋轉(zhuǎn)開關(guān)
功能選擇開關(guān)旋轉(zhuǎn)的電壓應(yīng)提供的該終端的旋轉(zhuǎn)選擇開關(guān),以確保正常運(yùn)行的電子電路列于表3。每5個(gè)桿就有4個(gè)板連接著3個(gè)旋轉(zhuǎn)選擇開關(guān),每個(gè)符合邏輯功能表3,旋轉(zhuǎn)任何三個(gè)切換到完全順時(shí)針方向?qū)⑼ㄟ^5個(gè)職位。功能的旋轉(zhuǎn)選擇開關(guān)可以說是從第一的位置通過直到達(dá)到最后的立場如下:
初始位置:在這個(gè)位置上的低電壓電平適用于第一第二和第三終端,浙江斷開來自三個(gè)中一個(gè)顯示器的5伏特電壓供應(yīng),設(shè)置三個(gè)顯示器,乘客檢測電路并與電路系統(tǒng)整合到較低的水平。終端D,H采用低電壓,這是為了確保顯示的總收入選項(xiàng)已被禁用。
步驟1:以順時(shí)針方向旋轉(zhuǎn)任何旋轉(zhuǎn)選擇開關(guān)一格將提供5伏特電壓到相應(yīng)的顯示,提供一個(gè)高等級的電壓終端1,2或3,這表明一名乘客已經(jīng)進(jìn)入了出租車。終端C,G應(yīng)為高電平,以確保相應(yīng)的顯示仍然是籠罩。其他端口,如D,H端口保持不變。
步驟2:旋轉(zhuǎn)旋轉(zhuǎn)選擇開關(guān)1,然后將在終端A,C或G上改變電壓使其處于低電壓狀態(tài),并會產(chǎn)生相應(yīng)的顯示。終端1,2,3以及S上的電壓狀態(tài)保持不變。終端B,D和H應(yīng)保持在較低水平,以確保當(dāng)顯示為無數(shù)據(jù)時(shí)相應(yīng)的讀出清除為零。
第二篇:出租車計(jì)價(jià)器
基于單片機(jī)的出租車計(jì)價(jià)器設(shè)計(jì)
摘要
出租車計(jì)價(jià)器的數(shù)字系統(tǒng)的設(shè)計(jì)正是基于一些專用的芯片,才發(fā)揮其有效特性,從而實(shí)現(xiàn)出租車的計(jì)價(jià)功能。此數(shù)字系統(tǒng)主要分為三個(gè)單元,即里程計(jì)數(shù)及顯示單元、價(jià)格計(jì)數(shù)及顯示單元、脈沖產(chǎn)生。本設(shè)計(jì)是一個(gè)基于單片機(jī)AT89C51的出租車自動計(jì)費(fèi)設(shè)計(jì),附有復(fù)位電路,時(shí)鐘電路等。關(guān)鍵詞:出租車計(jì)費(fèi)器;單片機(jī);控制
Abstract Taximeter design digital system is based on some special chip, to play their effective characteristics, thus realizing the taxi valuation function.This system is mainly divided into there modules, namely the mileage counting and display unit, and display unit price counting, pulsing.The design is based on a single chip AT89C51taxis design, a reset circuit, clock circuit.Keywords:taximeter,a single-chip microcomputer,control
1引言
1.1 設(shè)計(jì)目的
近幾年來,出租汽車行業(yè)在各地得以蓬勃發(fā)展,但采用模擬電路和數(shù)字電路設(shè)計(jì)的計(jì)價(jià)器整體電路的規(guī)模較大,用到的器件多,造成故障率高,難調(diào)試。而采用單片機(jī)進(jìn)行的設(shè)計(jì),相對來說功能強(qiáng)大,用較少的硬件和適當(dāng)?shù)能浖嗷ヅ浜峡梢院苋菀椎貙?shí)現(xiàn)設(shè)計(jì)要求,且靈活性強(qiáng)。
1.2 功能要求
(1)用前4位數(shù)碼管實(shí)時(shí)顯示里程數(shù),單位為千米,最后一位為小數(shù)位;用后4位數(shù)碼管時(shí)時(shí)顯示金額數(shù),單位為元,最后一位為小數(shù)位。
(2)規(guī)定出租車?yán)锍绦∮?千米收費(fèi)5元,超過2千米收費(fèi)為8*(way-20)/5。
1.3 設(shè)計(jì)方法
本設(shè)計(jì)采用AT89C51單片機(jī)為主控器,并用頻率信號發(fā)生器模擬車速,利用AT89C51的定時(shí)器工作在方式1下定時(shí)實(shí)現(xiàn)對出租車的計(jì)價(jià)設(shè)計(jì),輸出采用共陰極的集成8位7段數(shù)碼顯示管。設(shè)計(jì)方案及原理
2.1 設(shè)計(jì)方案
采用AT89C51單片機(jī)為主控器,并用頻率信號發(fā)生器模擬車速,利用AT89C51的定時(shí)器/定時(shí)器T1工作在方式1下定時(shí)實(shí)現(xiàn)對出租車的計(jì)價(jià)設(shè)計(jì),輸出采用共陰極的集成8位7段數(shù)碼顯示管。本電路設(shè)計(jì)的計(jì)價(jià)器不但能實(shí)現(xiàn)基本的計(jì)價(jià),而且
單片機(jī)原理及系統(tǒng)課程設(shè)計(jì)報(bào)告
還能根據(jù)里程來調(diào)節(jié)單價(jià)。
2.2 設(shè)計(jì)原理
出租車計(jì)價(jià)是根據(jù)車所行駛的路程以及乘客乘車的里程綜合決定的。出租車行駛總路程可以通過車輪的周長乘車輪旋轉(zhuǎn)圈數(shù)得到。即可計(jì)算得到車輪旋轉(zhuǎn)幾周出租車能行駛一公里的路程。通過計(jì)數(shù)接收到的脈沖個(gè)數(shù),計(jì)算出當(dāng)前所行駛的路程。同時(shí),通過數(shù)碼管顯示當(dāng)前的行駛里程和需支付的車費(fèi)。出租車計(jì)價(jià)器用于記錄里程、起步公里數(shù)與價(jià)格的關(guān)系。模擬出租車計(jì)價(jià)器能根據(jù)總里程數(shù)、起步公里數(shù)的情況作出相應(yīng)報(bào)價(jià)等。這個(gè)系統(tǒng)以AT89C51單片機(jī)為主控器,單片機(jī)的計(jì)數(shù)器/定時(shí)器T1工作在方式1下來對外部脈沖計(jì)數(shù),最后通過集成的8位7段LED數(shù)碼管顯示里程數(shù)和價(jià)錢??傮w模塊框圖如圖1所示。
總金額顯示單價(jià)顯示AT89C51脈沖產(chǎn)生動態(tài)掃描數(shù)碼管顯示
圖1 總體框圖 硬件設(shè)計(jì)
對于AT89C51的計(jì)數(shù)器/定時(shí)器T1,通過對寄存器TCON的設(shè)置,即使它的M1M0=01,計(jì)數(shù)器/定時(shí)器T1工作在方式1下,構(gòu)成16位計(jì)數(shù)器/定時(shí)器。此時(shí)TH0、TL0都是8位加法計(jì)數(shù)器。此設(shè)計(jì)中,T1為計(jì)數(shù)工作方式,計(jì)數(shù)范圍為1~2^16=1~65536(個(gè)外部脈沖)。當(dāng)計(jì)數(shù)溢出時(shí)則置位并申請中斷,進(jìn)入中斷服務(wù) 執(zhí)行中斷程序。
通過74HC138接P20、P21、P22輸出來對8位7段的智能掃描LED進(jìn)行段選,并且通過P1口對LED進(jìn)行位選,最后將結(jié)果顯示在LED上。硬件設(shè)計(jì)圖如圖2所示。
74HC138是三八譯碼器,在工作之前,使74HC138的使能端有效,再使74HC138的A、B、C接P20、P21、P22的輸出達(dá)到對LED位選線的控制,使相應(yīng)的位顯示相應(yīng)的結(jié)果。硬件總設(shè)計(jì)圖如圖2所示。
第三篇:出租車計(jì)價(jià)器設(shè)計(jì)范文
平頂山工業(yè)職業(yè)技術(shù)學(xué)院
目錄
目錄......................................................................................................................................................1 前言......................................................................................................................................................2 第一章 系統(tǒng)工作原理........................................................................................................................2 1.1 功能說明..............................................................................................................................2 1.2 基本原理..............................................................................................................................2 第二章 硬件設(shè)計(jì)...............................................................................................................................3 2.1 單片機(jī)最小系統(tǒng)單元..........................................................................................................3 2.2 A44E霍爾傳感器檢測單元................................................................................................4 2.3 AT24C01存儲單元..............................................................................................................6 2.4 鍵盤調(diào)整單元......................................................................................................................7 2.5 顯示單元..............................................................................................................................8 第三章 軟件設(shè)計(jì)...............................................................................................................................8 3.1 系統(tǒng)主程序..........................................................................................................................8 3.2 中斷程序..............................................................................................................................9 3.2.1 里程計(jì)數(shù)中斷程序...................................................................................................9 3.2.2 中途等待中斷程序.................................................................................................10 3.3 計(jì)算程序............................................................................................................................10 3.4 顯示程序............................................................................................................................10 3.5 鍵盤程序............................................................................................................................10 第四章 總結(jié).....................................................................................................................................11 參考文獻(xiàn)............................................................................................................................................12
平頂山工業(yè)職業(yè)技術(shù)學(xué)院
算出行駛公里數(shù),再根據(jù)從EEPROM中讀取的價(jià)格等相關(guān)數(shù)據(jù)進(jìn)行金額的計(jì)算,計(jì)算好的金額、里程和單價(jià)都實(shí)時(shí)地顯示在數(shù)碼管上。獨(dú)立鍵盤可以調(diào)節(jié)價(jià)格等相關(guān)數(shù)據(jù),按下相應(yīng)的按鈕,產(chǎn)生信號交由單片機(jī)處理并實(shí)時(shí)顯示出來,調(diào)節(jié)好的數(shù)據(jù)存儲到EEPROM中,掉電后可以使調(diào)好的數(shù)據(jù)不丟失,下次得電后直接從EEPROM讀到單片機(jī),系統(tǒng)結(jié)構(gòu)圖如圖1。
圖1 系統(tǒng)結(jié)構(gòu)圖
第二章 硬件設(shè)計(jì)
2.1 單片機(jī)最小系統(tǒng)單元
主控機(jī)系統(tǒng)采用了Atmel 公司生產(chǎn)的 AT89S52單片機(jī),它含有256 字節(jié)數(shù)據(jù)存儲器,內(nèi)置8K 的電可擦除FLASH ROM,可重復(fù)編程,大小滿足主控機(jī)軟件系統(tǒng)設(shè)計(jì),所以不必再擴(kuò)展程序存儲器。復(fù)位電路和晶振電路是AT89S52 工作所需
平頂山工業(yè)職業(yè)技術(shù)學(xué)院 的最簡外圍電路。單片機(jī)最小系統(tǒng)電路圖如圖2所示。
圖2 單片機(jī)最小系統(tǒng)圖
AT89S52 的復(fù)位端是一個(gè)史密特觸發(fā)輸入,高電平有效。RST端若由低電平上升到高電平并持續(xù)2個(gè)周期,系統(tǒng)將實(shí)現(xiàn)一次復(fù)位操作。在復(fù)位電路中,按一下復(fù)位開關(guān)就使在RST端出現(xiàn)一段時(shí)間的高電平,外接11.0592M 晶振和兩個(gè)30pF 電容組成系統(tǒng)的內(nèi)部時(shí)鐘電路。
2.2 A44E霍爾傳感器檢測單元
A44E 屬于開關(guān)型的霍爾器件,其工作電壓范圍比較寬(4.5~18V),其輸出的信號符合TTL電平標(biāo)準(zhǔn),可以直接接到單片機(jī)的IO 端口上,而且其最高檢測頻率可達(dá)到1MHZ。
A44E 集成霍耳開關(guān)由穩(wěn)壓器A、霍耳電勢發(fā)生器(即硅霍耳片)B、差分放大器C、施密特觸發(fā)器D和OC門輸出E五個(gè)基本部分組成。
在輸入端輸入電壓Vcc,經(jīng)穩(wěn)壓器穩(wěn)壓后加在霍爾電勢發(fā)生器的兩端,根據(jù)霍爾效應(yīng)原理,當(dāng)霍爾片處在磁場中時(shí),在垂直于磁場的方向通以電流,則與這二者相垂直的方向上將會產(chǎn)生霍爾電勢差VH輸出,該VH信號經(jīng)放大器放大后送至施密特觸發(fā)器整形,使其成為方波輸送到OC門輸出。當(dāng)施加的磁場達(dá)到工作點(diǎn)(即Bop)時(shí),觸發(fā)器輸出高電壓(相對于地電位),使三極管導(dǎo)通,此時(shí)OC門輸出端輸出低電壓,三極管截止,使OC門輸出高電壓,這種狀態(tài)為關(guān)。這樣兩次電壓變換,使霍爾開關(guān)完成了一次開關(guān)動作。A44E霍爾傳感器原理如圖3所示。
平頂山工業(yè)職業(yè)技術(shù)學(xué)院
圖3 A44E霍爾傳感器原理
里程計(jì)算是通過安裝在車輪上的霍爾傳感器檢測到的脈沖信號,送到單片機(jī)產(chǎn)生中斷,單片機(jī)再根據(jù)程序設(shè)定,計(jì)算出里程。其原理如圖4所示。
圖4 傳感器測距示意圖
本系統(tǒng)選擇了將A44E的脈沖輸出口接到P3.3口外部中斷1作為信號的輸入端(這樣可以減少程序設(shè)計(jì)的麻煩),車輪每轉(zhuǎn)一圈(設(shè)車輪的周長是1米),霍爾開關(guān)就檢測并輸出信號,引起單片機(jī)的中斷,對脈沖計(jì)數(shù),當(dāng)計(jì)數(shù)達(dá)到1000次時(shí),即1公里,單片機(jī)就控制將金額自動增加,如圖5。
圖5 A44E霍爾元件接線圖
平頂山工業(yè)職業(yè)技術(shù)學(xué)院
2.3 AT24C01存儲單元
存儲單元的作用是在電源斷開的時(shí)候,存儲當(dāng)前設(shè)定的單價(jià)信息。AT24C01 是Ateml公司的1KB的電可擦除存儲芯片,采用兩線串行的總線和單片機(jī)通訊,電壓最低可以到2.5V,額定電流為1mA,靜態(tài)電流10uA(5.5V),芯片內(nèi)的資料可以在斷電的情況下保存40年以上,而且采用8 腳的DIP 封裝,使用方便。AT24C02芯片引腳配置如圖6所示。
存儲單元電路連接如圖7所示。
圖 7 存儲單元電路原理圖
圖中R4、R5 是上拉電阻,其作用是減少AT24C01 的靜態(tài)功耗。由于AT24C01的數(shù)據(jù)線和地址線是復(fù)用的,采用串口的方式傳送數(shù)據(jù),所以只用兩根線SCL(時(shí)鐘脈沖)和SDA(數(shù)據(jù)/地址)與單片機(jī)P2.2和P2.3口連接,進(jìn)行傳送數(shù)據(jù)。
平頂山工業(yè)職業(yè)技術(shù)學(xué)院
每當(dāng)設(shè)定一次單價(jià),系統(tǒng)就自動調(diào)用存儲程序,將單價(jià)信息保存在芯片內(nèi);當(dāng)系統(tǒng)重新上電的時(shí)候,自動調(diào)用讀存儲器程序,將存儲器內(nèi)的單價(jià)等信息,讀到緩存單元中,供主程序使用。
2.4 鍵盤調(diào)整單元
當(dāng)單價(jià)等信息需要進(jìn)行修改時(shí),就要用到鍵盤進(jìn)行修改。由于調(diào)節(jié)信息不多,故采用4個(gè)獨(dú)立鍵盤即可,分別實(shí)現(xiàn)清零、切換、增大、減小和功能等作用。電路原理如圖8所示。
圖8 鍵盤調(diào)整單元接線圖
S1:接P1.0口,對上一次的計(jì)費(fèi)進(jìn)行清零,為下次載客準(zhǔn)備
S2:接P1.1口,實(shí)現(xiàn)白天和夜晚單價(jià)的切換;當(dāng)功能鍵S4按下時(shí),S2可對數(shù)據(jù)進(jìn)行增大。
S3:接P1.2口,當(dāng)功能鍵S4按下時(shí),S3可對數(shù)據(jù)進(jìn)行減小。
S4:接P1.3口,按1次,進(jìn)入調(diào)整白天單價(jià);按2次,進(jìn)入調(diào)整夜晚單價(jià);按3次,進(jìn)入調(diào)整等待單價(jià);按4次,進(jìn)入調(diào)整起步價(jià);按5次,返回。
平頂山工業(yè)職業(yè)技術(shù)學(xué)院
2.5 顯示單元
顯示單元由7個(gè)8段共陽數(shù)碼管組成,采用動態(tài)掃描進(jìn)行顯示。前三個(gè)數(shù)碼管分別接P3.0、P3.1和P3.2,用于顯示總金額;中間兩個(gè)分別接P3.4和P3.5,用于顯示里程;后邊兩個(gè)分別接P3.6和P3.7,用于顯示單價(jià)。電路如圖9所示。
圖9 數(shù)碼管顯示圖
第三章 軟件設(shè)計(jì)
3.1 系統(tǒng)主程序
在主程序模塊中,需要完成對各參量和接口的初始化、出租車起價(jià)和單價(jià)的初始化以及中斷、計(jì)算、循環(huán)等工作。另外,在主程序模塊中還需要設(shè)置啟動/清除標(biāo)志寄存器、里程寄存器和價(jià)格寄存器,并對它們進(jìn)行初始化。然后,主程序?qū)⒏鶕?jù)各標(biāo)志寄存器的內(nèi)容,分別完成啟動、清除、計(jì)程和計(jì)價(jià)等不同的操作。當(dāng)汽車運(yùn)行起來時(shí),就啟動計(jì)價(jià),根據(jù)里程寄存器中的內(nèi)容計(jì)算和判斷行駛里程是否已超過起步價(jià)公里數(shù)。若已超過,則根據(jù)里程值、每公里的單價(jià)數(shù)和起步價(jià)數(shù)來計(jì)算出當(dāng)前的總金額,并將結(jié)果存于總金額寄存器中;中途等待時(shí),無脈沖輸入,不產(chǎn)生中斷,當(dāng)時(shí)間超過等待設(shè)定值時(shí),開始進(jìn)行計(jì)時(shí),并把等待價(jià)格加到總金額里,然后將總金額、里程和單價(jià)送數(shù)碼管顯示出來。程序流程如圖10所示。
平頂山工業(yè)職業(yè)技術(shù)學(xué)院
圖10 主程序流程圖
圖11 計(jì)算程序流程圖
3.2 中斷程序
3.2.1 里程計(jì)數(shù)中斷程序
每當(dāng)霍爾傳感器輸出一個(gè)低電平信號就使單片機(jī)中斷一次,當(dāng)里程計(jì)數(shù)器對里程脈沖計(jì)滿1000次時(shí),進(jìn)入里程計(jì)數(shù)中斷服務(wù)程序中,里程變量加一。主函數(shù)中總金額也相應(yīng)地變化。
101112-
第四篇:出租車計(jì)價(jià)器 硬件課程設(shè)計(jì)
硬件課程設(shè)計(jì)報(bào)告
題目:出租車計(jì)價(jià)器
目錄
1. 引言....................................................................................................................................錯誤!未定義書簽。
1.1設(shè)計(jì)目的................................................................................................................錯誤!未定義書簽。1.2設(shè)計(jì)任務(wù)................................................................................................................錯誤!未定義書簽。1.3設(shè)計(jì)思路................................................................................................................錯誤!未定義書簽。
2.需求分析.............................................................................................................................錯誤!未定義書簽。
2.1芯片原理................................................................................................................錯誤!未定義書簽。2.1.1可編程計(jì)數(shù)器/定時(shí)器8253/8254原理.............................................................錯誤!未定義書簽。2.1.2可編程外圍接口芯片8255原理.......................................................................錯誤!未定義書簽。2.1.3 12864液晶顯示器ST7920原理........................................................................錯誤!未定義書簽。2.2硬件設(shè)計(jì)................................................................................................................錯誤!未定義書簽。2.3軟件設(shè)計(jì)................................................................................................................錯誤!未定義書簽。2.3.1功能模塊圖.........................................................................................................錯誤!未定義書簽。2.3.2程序流程圖.........................................................................................................錯誤!未定義書簽。2.3.3模塊流程圖.........................................................................................................錯誤!未定義書簽。
3.詳細(xì)設(shè)計(jì).............................................................................................................................錯誤!未定義書簽。
3.1程序模塊分析........................................................................................................錯誤!未定義書簽。3.1.1初始化模塊程序分析.........................................................................................錯誤!未定義書簽。3.1.2判斷開關(guān)程序模塊分析.....................................................................................錯誤!未定義書簽。3.1.3圈數(shù)統(tǒng)計(jì)模塊程序分析.....................................................................................錯誤!未定義書簽。3.1.4計(jì)算里程模塊程序分析.....................................................................................錯誤!未定義書簽。3.1.5顯示模塊程序分析.............................................................................................錯誤!未定義書簽。3.1.6結(jié)束模塊程序分析.............................................................................................錯誤!未定義書簽。3.2程序代碼................................................................................................................錯誤!未定義書簽。
4.5.6.程序結(jié)果.............................................................................................................................錯誤!未定義書簽。分析與測試.........................................................................................................................錯誤!未定義書簽。體會.....................................................................................................................................錯誤!未定義書簽。
附錄A:參考文獻(xiàn).....................................................................................................................錯誤!未定義書簽。
一、引言
1.1設(shè)計(jì)目的
現(xiàn)在各大城市出租車已經(jīng)成為了一種重要的交通工具,當(dāng)然出租車的收費(fèi)問題也成了人們關(guān)注的焦點(diǎn),那么怎么樣才能實(shí)現(xiàn)一種合理的收費(fèi)方式讓大家都認(rèn)可呢?在這種要求下,出租車自動計(jì)價(jià)器就走進(jìn)了人們的生活,當(dāng)然這就要求有一種合理公正的計(jì)價(jià)器收費(fèi)方式。這不僅關(guān)系到出租車計(jì)價(jià)器的市場,也影響這出租車的市場,這就要求我們設(shè)計(jì)出更好的計(jì)價(jià)器來滿足人們的需求。
本設(shè)計(jì)是關(guān)于出租車計(jì)價(jià)器的設(shè)計(jì)。在本次設(shè)計(jì)中,我以計(jì)價(jià)器的基本功能作為設(shè)計(jì)的重點(diǎn)。為了完成上述設(shè)計(jì),我們采用了8254、8255等芯片,用計(jì)算機(jī)匯編語言進(jìn)行軟件功能的實(shí)現(xiàn)。
1.2設(shè)計(jì)任務(wù)
1.實(shí)現(xiàn)一個(gè)出租車計(jì)價(jià)器,可以顯示起步價(jià)。2.一個(gè)鍵來控制是否到達(dá)終點(diǎn),是否計(jì)價(jià)要清零。3.基于路程的出租車計(jì)價(jià)方式。
1.3設(shè)計(jì)思路
利用直流電機(jī)來模仿出租車輪子的轉(zhuǎn)動來計(jì)算出租車行進(jìn)的路程。將直流電機(jī)的直流端與滑動變阻器相連,通過人工控制滑動變阻器來模擬出租車的行進(jìn);并將計(jì)數(shù)端與8253CLK0端相連,GATE0接高電平,工作方式為方式二。直流電機(jī)每轉(zhuǎn)1000圈,8253輸出一個(gè)高電平,假設(shè)出租車已經(jīng)走了1公里。同時(shí)將8253OUT0接入8255方便CPU讀取。再將8255與ST7920顯示器相連,CPU通過控制8255來控制顯示,一旦8255從8253讀入一個(gè)高電平,則公里數(shù)加一,同時(shí)價(jià)格相應(yīng)增加。另有一個(gè)開關(guān)連入8255,用以判斷出租車計(jì)價(jià)器是否啟動。
二、需求分析
2.1芯片原理
本節(jié)主要在介紹本次設(shè)計(jì)所用到的芯片的原理,共有可編程計(jì)數(shù)器/定時(shí)器8253/8254、可編程外圍接口芯片8255和12864液晶顯示器ST7920原理三種芯片。
2.1.1可編程計(jì)數(shù)器/定時(shí)器8253/8254原理
圖2-1 8254內(nèi)部結(jié)構(gòu)圖
從圖2-1可見,8254內(nèi)部包含數(shù)據(jù)總線緩沖器、讀/寫控制邏輯、控制字寄存器和3個(gè)結(jié)構(gòu)完全相同的計(jì)數(shù)器,這3個(gè)計(jì)數(shù)器分別稱為計(jì)數(shù)器0、計(jì)數(shù)器1和計(jì)數(shù)器2。
圖2-2 8254管腳圖
A1、A0:地址輸入線,用來控制8253內(nèi)部的4個(gè)端口,即3個(gè)計(jì)數(shù)器和1個(gè)控制字寄存器與CPU系統(tǒng)地址線相連。
CLK0-2:時(shí)鐘脈沖輸入端,用于輸入定時(shí)脈沖或計(jì)數(shù)脈沖信號。CLK可以是系統(tǒng)的時(shí)鐘脈沖,也可以由系統(tǒng)時(shí)鐘分頻或者其他脈沖源提供。當(dāng)用于定時(shí)時(shí),這個(gè)脈沖必須是均勻的、連續(xù)的、周期精確的,而用于計(jì)數(shù)時(shí),這個(gè)脈沖可以是不均勻的、斷續(xù)的、周期不定的。
GATE0-2:門控輸入端,用于外部控制計(jì)數(shù)器的啟動計(jì)數(shù)和停止計(jì)數(shù)的操
作。兩個(gè)或兩個(gè)以上計(jì)數(shù)器連用時(shí),可用此信號同步,也可用于與外部某信號的同步。
OUT0-2:計(jì)數(shù)輸出,當(dāng)計(jì)數(shù)器從初值開始完成計(jì)數(shù)操作進(jìn),OUT引腳輸出相應(yīng)的信號。
8253的方式控制字
圖2-3 8254控制字圖
本設(shè)計(jì)中8254的功能
只是用通道1,采用方式三。采用二進(jìn)制計(jì)數(shù),輸入0FFFH。先輸入低字節(jié),再輸入高字節(jié)。當(dāng)8254從0FFFFH遞減到159FH時(shí)(即轉(zhuǎn)了60000圈時(shí)),8254向總線發(fā)信號使程序向下進(jìn)行。
2.1.2可編程外圍接口芯片8255原理
內(nèi)部結(jié)構(gòu)如圖所示,由以下4個(gè)部分組成:
圖2-4 8255內(nèi)部結(jié)構(gòu)圖
(1)輸入/輸出端口A、B、C。這三個(gè)端口均可看作是I/O端口,但它們的結(jié)構(gòu)和功能也稍有不同。A口和B口是一個(gè)獨(dú)立的8位I/O口。C口:可以看作是一個(gè)獨(dú)立的8位I/O口;也可以看作是兩個(gè)獨(dú)立的4位I/O口。
(2)A組和B組控制電路。這是兩組根據(jù)CPU命令控制8255A工作方式的電路,這些控制電路內(nèi)部設(shè)有控制寄存器,可以根據(jù)CPU送來的編程命令來控制8255A的工作方式,也可以根據(jù)編程命令來對C口的指定位進(jìn)行置/復(fù)位的操作。A組控制電路用來控制A口及C口的高4位;B組控制電路用來控制B口及C口的低4位
(3)讀/寫控制邏輯。(同上:它負(fù)責(zé)管理8255A的數(shù)據(jù)傳輸過程。它接收CS*及RD*、WR*、RESET,還有來自系統(tǒng)地址總線的口地址選擇信號A0和A1。將這些信號組合后,得到對A組控制部件和B組控制部件的控制命令,并將命令發(fā)給這兩個(gè)部件,以完成對數(shù)據(jù)、狀態(tài)信息和控制信息的傳輸。)
(4)數(shù)據(jù)總緩沖器。(同上:它是8位的雙向的三態(tài)緩沖器。作為8255A與系統(tǒng)總線連接的界面,輸入/輸出的數(shù)據(jù),CPU的編程命令以及外設(shè)通過8255A傳送的工作狀態(tài)等信息,都是通過它來傳輸?shù)?。?/p>
如圖所示8255A的芯片引腳信號。除了電源和地以外,其他信號可以分為兩組:
圖2-5 8255管腳圖
1.和外設(shè)一邊相連的: PA7-PA0:A組數(shù)據(jù)信號
PB7-PB0:B組數(shù)據(jù)信號 PC7-PC0:C組數(shù)據(jù)信號 2.和CPU一邊相連的:
RESET:復(fù)位信號,低電平有效。當(dāng)RESET信號來到時(shí),所有內(nèi)部寄存器就被清除,同時(shí),3個(gè)數(shù)據(jù)端口被自動設(shè)為輸入端口。
D7-D0:它們是8255A的數(shù)據(jù)線,和系統(tǒng)數(shù)據(jù)總線相連。
CS*:芯片選擇信號,低電平有效。在一個(gè)系統(tǒng)中,一般根據(jù)全部接口芯片來分配若干較低位地址(比如A5、A4、A3)來組成各種芯片選擇碼,當(dāng)這幾位地址組成某一個(gè)代碼時(shí),譯碼器便往8255A的CS*端輸出一個(gè)低電平,于是8255A被選中。只有當(dāng) CS*有效時(shí),讀信號RD*和寫信號WR*才對8255A有效。
RD*:芯片讀出信號低電平有效。WR*:芯片寫入信號低電平有效。8255的方式控制字格式
圖2-6 8255控制字圖
本設(shè)計(jì)中8255的功能
8255PA0-PA7和PC0-PC2與ST7920相連,控制輸出。PB0與8253的OUT1相連,讀入8253OUT1 的數(shù)據(jù)。PB1與開關(guān)K0相連,讀入K0的數(shù)值用于確定是否開啟計(jì)價(jià)器。
2.1.3可編程外圍接口芯片8255原理
ST7920控制器系列中文圖形液晶模塊的軟件特性主要由ST7920控制驅(qū)動器決定。ST7920同時(shí)作為控制器和驅(qū)動器,它可提供33路com輸出和64路seg輸出。在驅(qū)動器ST7921的配合下,最多可以驅(qū)動256×32點(diǎn)陣液晶。
ST7920是臺灣矽創(chuàng)電子公司生產(chǎn)的中文圖形控制芯片,它是一種內(nèi)置12864漢字圖形點(diǎn)陣的液晶顯示控制模塊,用于顯示漢字及圖形。該芯片共內(nèi)置8192
個(gè)中文漢字(16×16點(diǎn)陣)、128個(gè)字符的ASCII字符庫(8×16點(diǎn)陣)及64×2256點(diǎn)陣顯示RAM(GDRAM)。
為了能夠簡單、有效地顯示漢字和圖形,該模塊內(nèi)部設(shè)計(jì)有2MB的中文字型CGROM和64×256點(diǎn)陣的GDRAM繪圖區(qū)域;同時(shí),該模塊還提供有4組可編程控制的16×16點(diǎn)陣造字空間;除此之外,為了適應(yīng)多種微處理器和單片機(jī)接口的需要,該模塊還提供了4位并行、8位并行、2線串行以及3線串行等多種接口方式。利用上述功能可方便地實(shí)現(xiàn)漢字、ASCII碼、點(diǎn)陣圖形、自造字體的同屏顯示,所有這些功能(包括顯示RAM、字符產(chǎn)生器以及液晶驅(qū)動電路和控制器)都包含在集成電路芯片里,因此,只要一個(gè)最基本的微處理系統(tǒng)就可以通過ST7920芯片來控制其它的芯片
圖2-7 ST7920外觀尺寸圖
本設(shè)計(jì)中ST7920的功能
用于顯示出租車行駛路程與應(yīng)收費(fèi)用。
2.2硬件設(shè)計(jì)
其中,8253GATE1連+5V高電平,直流電機(jī)連0~+5V,8253連280h~287h,8255連288h~28fh。8255PA0-PA7連ST7920顯示器D0-D7,PC0連DI,PC1連RW,PC2連E。開關(guān)K0連8255PB0。8253CLK1連直流電機(jī)計(jì)數(shù)端。
0~+5V直流電機(jī)D0-D7計(jì)數(shù)ST7920顯示屏DIRWE+5VGATE1CLK1PA0-PA7+5VPC0PC1PC2開關(guān)K0PB0+5V8253CS8255CS280H-288H289H-28FH總線圖2-8硬件連接圖
實(shí)際連接圖如下圖所示
圖2-9硬件實(shí)際連接圖
2.3軟件設(shè)計(jì) 2.3.1功能模塊圖
本節(jié)先給出一個(gè)程序的功能模塊圖。
出租車計(jì)價(jià)器系統(tǒng)計(jì)價(jià)器開關(guān)功能模塊讀入直流電機(jī)轉(zhuǎn)圈數(shù)模塊ST7920顯示功能模塊根據(jù)里程計(jì)算價(jià)格模塊
圖2-10軟件功能模塊圖
2.3.2程序流程圖
本節(jié)先給出一個(gè)程序的整體流程圖。
開始結(jié)束8253初始化液晶顯示屏初始化8255初始化是計(jì)價(jià)器是否開始工作通過8255讀入b0否是否有鍵盤輸入否液晶顯示屏初始化是液晶顯示屏調(diào)用顯示價(jià)格功能從直流電機(jī)讀入輸入圈數(shù)將更改過的路程在顯示器中顯示出來讀到一定圈數(shù)走的路程加一比較路程是否大于3公里是價(jià)格為(路程-3)*2+7 元將儲存的顯示字符串內(nèi)路程價(jià)格改為目前路程價(jià)格否價(jià)格為7元
圖2-11軟件程序流程圖
2.3.3模塊流程圖
如果對整個(gè)程序進(jìn)行細(xì)分則可以分為初始化模塊,判斷開關(guān)模塊,圈數(shù)統(tǒng)計(jì)模塊,計(jì)算里程模塊、結(jié)束模塊和顯示模塊。其中初始化模塊是8253芯片、8255芯片和顯示屏的初始化。判斷開關(guān)模塊是對8255的b0端是否有高電平進(jìn)行判斷。
圈數(shù)統(tǒng)計(jì)模塊是對直流電機(jī)傳入8253中高電平的數(shù)量進(jìn)行圈數(shù)統(tǒng)計(jì)。計(jì)算里程模塊是對里程及價(jià)格進(jìn)行計(jì)算的模塊。結(jié)束模塊是程序結(jié)束的操作與方法。顯示模塊是控制顯示屏顯示計(jì)算模塊的結(jié)果。
初始化模塊顯示模塊調(diào)用關(guān)判斷開關(guān)模塊開結(jié)束模塊圈數(shù)統(tǒng)計(jì)模塊計(jì)算里程模塊調(diào)用顯示模塊圖2-12軟件模塊流程圖
三、詳細(xì)設(shè)計(jì)
3.1程序模塊分析
我們將按模塊分析程序的功能并給出模塊內(nèi)的功能流程圖。
3.1.1初始化模塊分析
在初始化模塊中,我們定義了需要使用的8255和8254的接口,需要使用的變量如JSS,要輸出的字符串等,初始化了DS,完成了8255的初始化以及顯示屏的初始化。其流程圖為
開始圖3-1初始化模塊流程圖
3.1.2判斷開關(guān)模塊分析
以上為判斷開關(guān)模塊,在判斷開關(guān)模塊中,系統(tǒng)讀入8255PB0的電平,如果是高電平則程序繼續(xù)進(jìn)行,如果是低電平則程序調(diào)用chushi函數(shù),用屏幕顯示“空車歡迎乘坐”,并繼續(xù)度8255PB0直到有高電平為止。其流程圖如下所示:
8255PB0是否為高電平是圈數(shù)統(tǒng)計(jì)模塊否Chushi函數(shù)計(jì)數(shù)變量和對應(yīng)的字符串置零顯示 空車 歡迎乘坐 調(diào)用顯示模塊
圖3-2判斷開關(guān)模塊流程圖
3.1.3圈數(shù)統(tǒng)計(jì)模塊分析
在圈數(shù)統(tǒng)計(jì)模塊中,我們將直流電機(jī)計(jì)數(shù)端連入8254CLK1中(8253采用方式三),在CLK1中讀所記的數(shù),從0FFFFH向下計(jì),一直計(jì)到159FH,即轉(zhuǎn)了6000圈后,進(jìn)入程序的下一段。其流程圖如下所示:
讀8254計(jì)數(shù)值否是否到159FH以下是重新將8254計(jì)數(shù)初值設(shè)為0FFFFH計(jì)算里程模塊
圖3-3圈數(shù)統(tǒng)計(jì)模塊流程圖
3.1.4計(jì)算里程模塊分析
我們用地址JSS里表示已經(jīng)走過的公里,即8254傳過來的高電平,同時(shí)我們采用價(jià)格公式來計(jì)算價(jià)格,將其里程和價(jià)格對應(yīng)的中文字碼表存入要顯示的字符串中。我們用地址JSS里表示已經(jīng)走過的公里,即8254傳過來的高電平,同時(shí)我們采用價(jià)格公式來計(jì)算價(jià)格,將其里程和價(jià)格對應(yīng)的中文字碼表存入要顯示的字符串中。
計(jì)算公式為: 價(jià)格=(里程-3)* 2……(里程>3)
價(jià)格= 7…………………..(里程<=3)并調(diào)用顯示模塊來顯示這些字碼其流程圖如下所示:
圈數(shù)統(tǒng)計(jì)模塊計(jì)數(shù)值JSS加一并十進(jìn)制化里程數(shù)加一里程數(shù)是否是大于3是價(jià)格為(里程-3)*2調(diào)用顯示模塊否價(jià)格為7
圖3-4計(jì)算里程模塊流程圖
3.1.5顯示模塊分析
在顯示模塊中,我們使用ST7920顯示我們要顯示的兩行字符串。我們采取先顯示第一行,再顯示第二行的方法,只是用ST7920的中間兩行。
調(diào)整顯示屏指針指向第二行調(diào)整顯示屏指針指向第三行調(diào)整字符串指針指向第一個(gè)字調(diào)整字符串指針指向第九個(gè)字輸出輸出延時(shí)延時(shí)
圖3-5顯示模塊流程圖
3.1.6結(jié)束模塊分析
結(jié)束模塊在程序的尾部在結(jié)束模塊中,我們規(guī)定只要在鍵盤上按任意一個(gè)鍵就會結(jié)束整個(gè)程序。如果無鍵按下,則程序自動跳轉(zhuǎn)到程序頭部。其程序流程圖如下圖所示:
調(diào)用DOS中斷是否有鍵按下是結(jié)束否判斷開關(guān)模塊
圖3-6結(jié)束模塊流程圖
3.2程序代碼
IO8253A
EQU 280H IO8253B
EQU 281H IO8253C
EQU 283H
DATA
SEGMENT HZ DW 0C2B7H,0B3CCH,0A3B0H,0A3B0H,0A3AEH,0A3B0H,0B9ABH,0C0EFH
DW BCDBH,0B8F1H,0A3B0H,0A3B0H,0A3B0H,0A3AEH,0A3B0H,0D4AAH;存放原始輸出 HZ_TAB DW 0C2B7H,0B3CCH,0A3B0H,0A3B0H,0A3AEH,0A3B0H,0B9ABH,0C0EFH
DW 0BCDBH,0B8F1H,0A3B0H,0A3B0H,0A3B0H,0A3AEH,0A3B0H,0D4AAH;存放要輸出的值 HZ_BG DW 0BFD5H,0B3B5H,0A2A0H,0A2A0H,0BBB6H,0D3ADH,0B3CBH,0D7F8H
DW 0A2A0H,0A2A0H,0A2A0H,0A2A0H,0A2A0H,0A2A0H,0A2A0H,0A2A0H;存放“空車歡迎乘坐”
HZ_ADR DB ?
;存放顯示行起始端口地址 JSS
DW 0000H DII
DW 0000H GAO
DW 0000H ZHE
DW 0000H NUMBER
DW 0A3B0H,0A3B1H,0A3B2H,0A3B3H,0A3B4H,0A3B5H,0A3B6H,0A3B7H,0A3B8H,0A3B9H DATA
ENDS IO_ADDRESS
EQU 288H
CODE SEGMENT ASSUME CS:CODE,DS:DATA START:
MOV AX,DATA MOV DS,AX
MOV DX,IO_ADDRESS ADD DX,3 MOV AL,82H OUT DX,AL
;8255初始化 MOV AL,0FFH MOV DX,300H OUT DX, AL CALL CLEAR
;LCD 清除
LLL:
MOV DX,IO_ADDRESS ADD DX,1 IN AL,DX
;判斷開關(guān)是否打開 AND AL,01H CMP AL,01H JZ F0 CALL CHUSHI JMP LLL F0: MOV AL,01110110B MOV DX,IO8253C OUT DX,AL
;8254初始化 MOV AL,0FFH MOV DX,IO8253B OUT DX,AL MOV AL,0FFH
;設(shè)置計(jì)數(shù)初值0FFFFH OUT DX,AL F1: MOV AL,01000000B
MOV DX,IO8253C OUT DX,AL MOV DX,IO8253B
IN AL,DX MOV AH,AL IN AL,DX XCHG AH,AL CMP AX,159FH
;查看是否下降到159FH JA F1
;不滿足條件繼續(xù)讀值
MOV AL,01110110B
;重置8253 MOV DX,IO8253C OUT DX,AL MOV AL,0FFH MOV DX,IO8253B OUT DX,AL MOV AL,0FFH OUT DX,AL
CALL DISP
;調(diào)顯示子程序
CALL DDSP
CALL DELAY PUSH DX
MOV AH,06H MOV DL,0FFH INT 21H POP DX
JZ LLL
MOV AH,4CH
;退出
INT 21H L1:
JMP
START;L1
CHUSHI PROC NEAR
LEA SI, HZ_TAB LEA DI,HZ MOV CX,0FH F3: ADD SI,2 ADD DI,2 MOV AX,[DI] MOV [SI],AX LOOP F3
;重置HZ_TAB
MOV AX,0000H LEA BX,JSS MOV [BX],AX LEA BX, HZ_BG MOV CH,2
CALL LCD_DISP LEA BX, HZ_BG MOV CH,3
;顯示“空車歡迎乘坐” CALL LCD_DISP RET CHUSHI ENDP
DDSP
PROC NEAR
LEA DI,HZ_TAB LEA BX,JSS LEA SI,NUMBER MOV AX,WORD PTR[BX]
MOV BP,AX AND BP,00FFH ADD BP,BP
MOV DX,WORD PTR[BP+SI] MOV WORD PTR[DI+6],DX
;將JSS中低八位傳入HZ_TAB MOV BP,AX AND BP,0FF00H ROR BP,8 ADD BP,BP MOV DX,WORD PTR[BP+SI] MOV WORD PTR[DI+4],DX
LEA BX, HZ_TAB
MOV CH,2
息
CALL LCD_DISP LEA DI,HZ_TAB LEA BX,JSS LEA SI,NUMBER MOV AX,WORD PTR[BX] CMP AX,0003H
JBE L3 CALL BJ LEA BX,JSS JMP L4
L3:MOV BP,0007H
ADD BP,BP MOV DX,WORD PTR[BP+SI ] MOV WORD PTR[DI+24],DX JMP L4 L4:
LEA BX, HZ_TAB
MOV CH,3
CALL LCD_DISP RET DDSP
ENDP
BJ
PROC NEAR
LEA DI,HZ_TAB LEA BX,JSS LEA SI,NUMBER MOV AX,WORD PTR[BX] CMP AL,03H
;將JSS中高八位傳入HZ_TAB
;顯示第2行信;比較路程與3的大小;路程比3小的情況
;顯示第3行信息
JAE BJ1 SUB AH,01H ADD AL,0AH SUB AL,03H AAS
;路程減三并十進(jìn)制化 JMP BJ2 BJ1:
SUB AX,0003H BJ2: MOV CX,AX AND AX,00FFH ADD AL,AL AAA ADD AX,07H AAA
LEA BX,DII MOV [BX],AX;DII MOV BP,AX AND BP,00FFH ADD BP,BP MOV DX,WORD PTR[BP+SI] MOV WORD PTR[DI+24],DX
MOV AX,CX SHR AX,8 AND AX,00FFH ADD AL,AL
AAA LEA BX,GAO MOV [BX],AX;GAO LEA BX,DII MOV DX,[BX];DII AND AX,00FFH AND DX,0FF00H SHR DX,8 AND DX,00FFH ADD AL,DL
AAA LEA BX,ZHE MOV [BX],AX;ZHE MOV BP,AX AND BP,00FFH ADD BP,BP MOV DX,WORD PTR[BP+SI]
;路程加七并十進(jìn)制化;先計(jì)算個(gè)位
;十位相加
;再加進(jìn)位
MOV WORD PTR[DI+22],DX
;再計(jì)算十位 LEA BX,ZHE MOV DX,[BX] LEA BX,GAO MOV AX,[BX] AND DX,0FF00H AND AX,0FF00H SHR AX,8 SHR DX,8 ADD DL,AL
;百位加進(jìn)位 AAA MOV BP,DX AND BP,00FFH ADD BP,BP MOV DX,WORD PTR[BP+SI] MOV WORD PTR[DI+20],DX
;最后計(jì)算百位 RET BJ ENDP
DISP
PROC NEAR
;顯示子程序
PUSH DX
LEA BX, JSS
MOV AX,WORD PTR[BX]
ADD AL,01H
CMP AL,09H
;判斷是否<=9
JLE NUM
;若是則為'0'-'9',ASCII碼加30H
MOV AL,00H
ADD AH,01H
CMP AH,0AH
JZ L2 NUM:
MOV WORD PTR[BX],AX
ADD AL,30H
ADD AH,30H
MOV DL,AH
MOV DH,AL
MOV AH,02H
;屏幕顯示
INT 21H
MOV DL,DH
MOV AH,02H
;屏幕顯示
INT 21H
MOV DL,0DH
;加回車符
INT 21H
MOV DL,0AH
;加換行符
INT 21H
POP DX
RET
;子程序返回 DISP ENDP L2: MOV AH,4CH
;退出
INT 21H
CLEAR
PROC
MOV AL,0CH
CLEAR
FUNCUP
;
;
;
FUNCUP
LCD_DISP
;
址
DISP_SEC:
NEXT:
CONTINUE:
MOV DX, IO_ADDRESS OUT DX,AL
;設(shè)置CLEAR命令 CALL CMD_SETUP
;啟動LCD執(zhí)行命令 RET
ENDP
PROC MOV AL, 0FH
;LCD功能設(shè)置命令 OUT DX, AL CALL CMD_SETUP MOV AL, 34H
;LCD顯示狀態(tài)命令 OUT DX, AL CALL CMD_SETUP RET
ENDP PROC LEA BX, HZ_TAB CMP CH, 2 JZ DISP_SEC MOV BYTE PTR HZ_ADR, 88H
;第三行起始端口地ADD BX,16
;指向第二行信息 JMP NEXT MOV BYTE PTR HZ_ADR,90H MOV CL,8
PUSH CX MOV AL,HZ_ADR MOV DX, IO_ADDRESS OUT DX, AL CALL CMD_SETUP
;設(shè)定DDRAM地址命令 MOV AX,[BX] PUSH AX MOV AL,AH
;先送漢字編碼高位 MOV DX,IO_ADDRESS OUT DX,AL CALL DATA_SETUP
;輸出漢字編碼高字節(jié)
CALL DELAY
;延遲
POP AX
MOV DX,IO_ADDRESS
OUT DX, AL
CALL DATA_SETUP
;輸出漢字編碼低字節(jié)
CALL DELAY
INC BX
INC BX
;修改顯示內(nèi)碼緩沖區(qū)指針
INC BYTE PTR HZ_ADR
;修改LCD顯示端口地址
POP CX
DEC CL
JNZ CONTINUE
RET LCD_DISP
ENDP CMD_SETUP
PROC
MOV DX,IO_ADDRESS
制端口
ADD DX,2
NOP
MOV AL,00000000B
(LCD I端=0,W端=0)
OUT DX, AL
CALL DELAY
NOP
MOV AL,00000100B
=1)
OUT DX, AL
NOP
CALL DELAY
MOV AL, 00000000B
0)
OUT DX, AL
CALL DELAY
RET CMD_SETUP
ENDP DATA_SETUP
PROC
MOV DX,IO_ADDRESS
口
ADD DX,2
MOV AL,00000001B
(LCD I端=1)
OUT DX, AL
NOP
CALL DELAY
;指向8255端口控
;PC1置0,PC0置0
;PC2置1(LCD E端
;PC2置0,(LCD E端置
;指向8255控制端
;PC1置0,PC0=1
MOV AL,00000101B
;PC2置1(LCD E端=1)
OUT DX, AL
NOP
CALL DELAY
MOV AL, 00000001B
;PC2置0,(LCD E端=0)
OUT DX, AL
NOP
CALL DELAY
RET DATA_SETUP
ENDP DELAY
PROC
PUSH CX
PUSH DX
MOV CX, 0FFFH X1:
LOOP
X1
POP DX
POP CX
RET DELAY
ENDP
CODE ENDS
END START
四、程序結(jié)果
我們利用8254、8255、ST7920顯示屏、直流電機(jī)等制作出了一個(gè)出租車計(jì)價(jià)器有專用鍵可以表示是否空車,同時(shí)利用直流電機(jī)模擬車輪運(yùn)動,通過路程計(jì)算價(jià)格,成果如下圖所示:
圖4-1程序結(jié)果圖
五、分析與測試
程序中,我遇到的最大的難題就是如何完成正確的十進(jìn)制計(jì)算,因?yàn)樗械挠?jì)算指令都是十六進(jìn)制的,雖然有的計(jì)算里有類似AAA這樣的調(diào)整指令,但是很多時(shí)候就不一定記得起來加上。同時(shí)由于需要根據(jù)數(shù)字來查表對應(yīng)相應(yīng)的字符碼,而且我是建立一個(gè)從零到九的數(shù)組,而由于計(jì)算錯誤導(dǎo)致經(jīng)常出現(xiàn)亂碼,而且比較難找到相應(yīng)的錯誤。而且有些計(jì)算沒有十進(jìn)制轉(zhuǎn)換指令,需要自己編寫。
同時(shí)我認(rèn)為我利用提前存儲變量來表示走過的路程比利用堆棧要好,因?yàn)槎褩H菀子浕?,而變量有?dú)特的名字,利于記憶與調(diào)用。而且易于清零、增減。
六、心得體會
這次課程設(shè)計(jì)中,令我印象最為深刻的就是我們應(yīng)該有一種堅(jiān)持的精神,有時(shí)候幾個(gè)小時(shí)都沒有成果,找不到BUG。顯示的就是有問題,這時(shí)候我們應(yīng)該有一種堅(jiān)持下去的毅力,積極詢問老師同學(xué),問題的解決就很快了。
同時(shí)我發(fā)現(xiàn)編程習(xí)慣非常重要,應(yīng)該有一個(gè)提前的規(guī)劃,不能想到哪寫到哪,這樣的話,后期的DEBUG會非常麻煩,因?yàn)樽约阂部床欢约旱拇a,我們都應(yīng)該有規(guī)范化的代碼意識,這樣的編程能力才能上升。
參考文獻(xiàn)
[1]周荷琴,吳秀清,《微型計(jì)算機(jī)原理與接口技術(shù)》,合肥:中國科學(xué)技術(shù)大學(xué)出版社 2008。[2] 曹國清,《數(shù)字電路與邏輯設(shè)計(jì)》,徐州:中國礦業(yè)大學(xué)出版社 2003。[3] 8255芯片原理:http://baike.baidu.com/link?url=KHojvZzBGmo26_6iYGTdrdqH6PxQbM1Hnnc8hWQNPIp60L7TWG5LZu_ppSkXo5maU5M4APs4qCGSudiqZ0bdl_ [4]ST7920芯片原理:http://wenku.baidu.com/view/0dafd9232f60ddccda38a0fa.html訪問時(shí)間2013/10/15 [5]ST7920中文字碼表:http://wenku.baidu.com/view/d4abe628647d27284b735127.html訪問時(shí)間:2013/10/15
第五篇:出租車計(jì)價(jià)器調(diào)試報(bào)告
出租車計(jì)價(jià)器調(diào)試報(bào)告
本設(shè)計(jì)可分為單片機(jī)主控模塊、鍵盤、顯示器、溫度檢測、狀態(tài)指示、時(shí)鐘日歷、語音收錄播報(bào)、分頻器電路、脈沖信號發(fā)生器等9部分。仔細(xì)分析系統(tǒng)的工作原理,分別按照模塊在系統(tǒng)中的作用,對各個(gè)模塊分別單獨(dú)調(diào)試,最后形成該系統(tǒng)的用戶程序,實(shí)現(xiàn)功能要求。
一、接通電源
調(diào)試要求:1.首先仔細(xì)檢查該系統(tǒng)板的電源和地是否有短路問題,在未接入電源輕快下,使用萬用表檢驗(yàn)電源和地檢查是否短路,如果沒有短路,再仔細(xì)核查電源極性后予以通電,觀察電源指示燈D1是否點(diǎn)亮。如果電源指示的燈不亮應(yīng)立即關(guān)閉電源,并用手觸摸各個(gè)芯片,檢查是否用某芯片發(fā)熱。如果沒有發(fā)熱的器件,很可能是電源指示二極管極性安裝錯誤,或者是該發(fā)光二極管的串聯(lián)電阻阻值偏大。
2.黑板上調(diào)試要求:(1)焊接好電路板加電前,用萬用表測量板上Vcc 和
GND之間的電阻,應(yīng)大于1KΩ
(2)加電后測量電路板上各電壓,應(yīng)大于4.2V 調(diào)試結(jié)果:1.經(jīng)萬用表檢驗(yàn),電路板無短路問題。
2.通電后,D1指示燈點(diǎn)亮。
3.測量Vcc 與 地之間的電阻,1.14KΩ > 1KΩ
4.測量Vcc與 地之間的電壓:4.28V > 4.20V
二、測試狀態(tài)指示
本系統(tǒng)中狀態(tài)指示二極管共有3個(gè),它們分別是D1、D2、D3。D1是指示電源的,可以在電源接通時(shí)直接看到,D2用于指示語音芯片的工作狀態(tài),留作語音模塊調(diào)試時(shí)觀察。D3是可以由單片機(jī)的引腳控制的。
編寫測試D3的程序: #include
sbit a_c=P1^0;extern serial_initial();
main(){ serial_initial();a_c=0;while(1);}
測試結(jié)果: 1.2.三、脈沖信號發(fā)生器測試
測試要求:該模塊由5G555芯片構(gòu)成一個(gè)多諧振蕩器,使用示波器觀察該芯片的第3引腳的波形,并調(diào)節(jié)電位器W1,觀察輸出波形及頻率變化。
測試結(jié)果:
調(diào)整W1前,f=147.1Hz
調(diào)整W1后,f=130.5Hz
四、分頻電路測試
測試要求:該模塊由一個(gè)4位二進(jìn)制計(jì)數(shù)器74HC161和一個(gè)多路選擇器74HC153構(gòu)成。調(diào)試時(shí)可以利用由5G555芯片構(gòu)成一個(gè)多諧振蕩器的輸出,或信號發(fā)生器作為計(jì)數(shù)器74HC161的計(jì)數(shù)輸入信號。值得注意的是控制多路選擇器74HC153的S0、S1與單片機(jī)調(diào)試時(shí)所使用的引腳復(fù)用,要采取特殊措施才能正確試驗(yàn)檢測。
測試結(jié)果:利用函數(shù)信號發(fā)生器生成一個(gè)方波,周期/頻率如圖:
其在輸出端輸出的波形為:
f1=3.881kHz
f2 =1.235kHz 分頻功能無誤。
五、鍵盤測試
測試要求:本系統(tǒng)相對比較簡單,僅有5個(gè)按鍵,其中4個(gè)為系統(tǒng)功能鍵,它們分別是S1、S2、S3、S4,另一個(gè)是系統(tǒng)復(fù)位按鍵S6。對于系統(tǒng)復(fù)位按鍵S6可以在上電之后,使用萬用表予以檢查,按下該按鍵,單片機(jī)的第9腳應(yīng)該為高電平,釋放后應(yīng)該為點(diǎn)電平。
對于系統(tǒng)功能鍵,編寫如下程序予以測試檢查:
#include
#define BIT_LED XBYTE[0x0a000] void display();sbit k1=P1^0;sbit k2=P1^1;sbit k3=P1^2;sbit k4=P1^3;unsigned char a;unsigned
char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67,0x40,0x00,0x63,0x39,};void delay(unsigned int i);main(){ while(1){ if(k1==0)a=0x06;if(k2==0)a=0x5b;if(k3==0)a=0x4f;if(k4==0)a=0x66;display();} } 測試結(jié)果:對于復(fù)位鍵S6,按下前應(yīng)為低電平,按下后應(yīng)為高電平
按下前
按下后
對于S1—S4,按下前為高電平,按下后為低電平。其測試結(jié)果均符合預(yù)期。
六、動態(tài)數(shù)碼管測試
測試要求:本系統(tǒng)中的數(shù)碼管的原理采用的是動態(tài)掃描方式,即某一時(shí)刻只用一個(gè)數(shù)碼管在顯示,利用人的視覺暫留特性,讓數(shù)碼管高速輪流顯示,達(dá)到完整顯示的目的。
編寫如下程序進(jìn)行測試: #include
#define BIT_LED XBYTE[0x0a000] void displayhello();sbit k1=P1^0;sbit k2=P1^1;sbit k3=P1^2;sbit k4=P1^3;unsigned char a;unsigned char table[]={0x06,0x06,0x3f,0x3e,0x79,0x6e,0x3f,0x3e,0x7f,0x67,0x40,0x00,0x63,0x39,};void delayms(unsigned int i);main(){ while(1){ displayhello();} }
void displayhello(){
unsigned char BIT=1;
unsigned int i;
BIT_LED=1;
for(i=0;i<=7;i++)
{
SEGMENT=table[i];
BIT_LED=BIT;
BIT=BIT<<1;
delayms(1);
}
} void delayms(unsigned int i){ unsigned int n;while(i--){
for(n=0;n<125;n++);
} }
測試結(jié)果:顯示“I love you”
由于是動態(tài)顯示,所以按下復(fù)位鍵后,只有一個(gè)數(shù)碼管點(diǎn)亮
七、溫度傳感器測試
測試要求:本系統(tǒng)使用的是一款單線溫度傳感器(DS18B20),可將溫度穿換成12的數(shù)字量,以表示溫度。
編寫如下程序予以測試檢查: #include
//段碼寄存器地址 #define BIT_LED XBYTE[0x0a000]
//位碼寄存器地址 #define fosc 11.0592
unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67,0x40,0x00,0x63,0x39,};//分別顯示0 1 2 3 4 5 6 7 8 9-o C
unsigned char table1[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};//分別顯示0.1.2.3.4.5.6.7.8.9.unsigned char table2[]={0x76,0x79,0x38,0x38,0x3f};sbit k1=P1^0;sbit k2=P1^1;sbit k3=P1^2;unsigned char data display_buffer[13];unsigned char bdata data_ds1302;
unsigned char disbuf[]={0,0,0,0};sbit k4=P1^3;
sbit TMDAT=P3^4;
//溫度入口
void dmsec(unsigned int count);void tmreset(void);
//ds18b20 reset void tmstart(void);
// void tmrtemp(void);void Disbuf(unsigned int temper);void displaytemper();void delay(unsigned int);main(){ display_buffer[0]=0x01;
display_buffer[1]=0x00;
display_buffer[2]=0x00;display_buffer[3]=0x08;
display_buffer[4]=0x05;
display_buffer[5]=0x00;display_buffer[6]=0x01;
display_buffer[7]=0x04;
display_buffer[8]=0x00;display_buffer[9]=0x05;
display_buffer[10]=0x00;
display_buffer[11]=0x01;
display_buffer[12]=0x04;while(1){ tmstart();
tmrtemp();
displaytemper();} }
void tmreset(void){
unsigned int i;
TMDAT = 0;
i = 103;while(i>0)i--;
TMDAT = 1;
i = 4;while(i>0)i--;}
void tmpre(void){
unsigned int i;
while(TMDAT);
while(~TMDAT);
i = 4;while(i>0)i--;}
bit tmrbit(void){
// ds1820
// Reset TX
unsigned int i;
bit dat;
TMDAT = 0;i++;
TMDAT = 1;i++;i++;
dat = TMDAT;
i = 8;while(i>0)i--;
return(dat);}
unsigned char tmrbyte(void){
unsigned char i,j,dat;
dat = 0;
for(i=1;i<=8;i++){
j = tmrbit();
dat =(j << 7)|(dat >> 1);
}
return(dat);}
void tmwbyte(unsigned char dat){
unsigned int i;
unsigned char j;
bit testb;
for(j=1;j<=8;j++){
testb = dat & 0x01;
dat = dat >> 1;
if(testb){
TMDAT = 0;
i++;i++;
TMDAT = 1;
i = 8;while(i>0)i--;
}
else {
TMDAT = 0;
i = 8;while(i>0)i--;
TMDAT = 1;
i++;i++;
}
} }
void tmstart(void){
tmreset();
tmpre();
// ds1820
displaytemper();//delay(100);
tmwbyte(0xcc);
tmwbyte(0x44);
}
void tmrtemp(void){
unsigned char a,xiao,b,y1,y2,y3;
tmreset();
tmpre();
delay(1);
tmwbyte(0xcc);
tmwbyte(0xbe);
a = tmrbyte();
b = tmrbyte();
xiao=a&0x0f;//小數(shù)部分
y1=a>>4;
y2=b<<4;
y3=y1|y2;if((b&0x0f8)==0x0f8)
{y3=~y3+1;
disbuf[0]=10;//顯示符號
disbuf[1]=y3/10;
disbuf[2]=y3%10;
disbuf[3]=xiao*10*0.0625;} else
disbuf[0]=11;//不顯示
disbuf[1]=y3/10;
disbuf[2]=y3%10;
disbuf[3]=xiao*10*0.0625;}
void displaytemper()
//溫度顯示函數(shù)
{ unsigned int i;unsigned char e=0x01;//<<1;for(i=1;i<6;i++)
{ switch(i)
{
case 1:{SEGMENT=table[disbuf[1]];BIT_LED=e;break;}
case 2:{SEGMENT=table1[disbuf[2]];BIT_LED=e;break;}
case 3:{SEGMENT=table[disbuf[3]];BIT_LED=e;break;}
case 4:{SEGMENT=table[12];BIT_LED=e;break;}
case 5:{SEGMENT=table[13];BIT_LED=e;break;}
}
e=e<<1;
delay(80);
}
BIT_LED=0;
}
void delay(unsigned int i)
//delay函數(shù) {
while(i--);}
測試結(jié)果:
經(jīng)傳感器及數(shù)碼管延時(shí),溫度重新顯示
八、時(shí)鐘日歷測試
測試要求:本系統(tǒng)使用了時(shí)鐘日歷專用芯片,該芯片是以串行方式實(shí)現(xiàn)控制和數(shù)據(jù)傳輸?shù)摹?/p>
編寫如下程序進(jìn)行測試: #include
//段碼寄存器地址 #define BIT_LED XBYTE[0x0a000]
//位碼寄存器地址 #define fosc 11.0592
unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67,0x40,0x00,0x63,0x39,};unsigned char table1[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};unsigned char table2[]={0x76,0x79,0x38,0x38,0x3f};sbit k1=P1^0;sbit k2=P1^1;sbit k3=P1^2;sbit k4=P1^3;//利用開關(guān)量實(shí)現(xiàn)切換
//頻率變量及子函數(shù)預(yù)定義 void displayfreq();void read_freq();unsigned char tcount=0,timecount=0;unsigned long freq=0.0;bit freqflag=0;unsigned char fr[6];unsigned int i=0,x=0;
//日期變量及子函數(shù)預(yù)定義 sbit SCL_ds1302=P2^0;sbit IO_ds1302=P2^1;sbit RST_ds1302=P2^2;
unsigned char data display_buffer[13];unsigned char bdata data_ds1302;
//傳輸符
unsigned char disbuf[]={0,0,0,0};void open_write_bit();void initial_ds1302();unsigned char read_ds1302(char command);void close_write_bit();void read_time();void set_time();void delay(unsigned int i);void delayms(unsigned int i);void displaytime();void displaydate();main(){ initial_ds1302();
//上電走時(shí)
read_time();
//讀取當(dāng)前時(shí)間,放到數(shù)組中
display_buffer[0]=0x01;
display_buffer[1]=0x05;
display_buffer[2]=0x01;display_buffer[3]=0x07;
display_buffer[4]=0x04;
display_buffer[5]=0x00;display_buffer[6]=0x01;
display_buffer[7]=0x06;
display_buffer[8]=0x00;display_buffer[9]=0x05;
display_buffer[10]=0x00;
display_buffer[11]=0x01;
display_buffer[12]=0x04;
set_time();
//設(shè)置時(shí)間
while(1){
if(k1==0)
{
while(1){
read_time();
displaytime();
if(k2==0)break;
}
}
read_time();
displaydate();} }
void close_write_bit()//close write { unsigned int i;
SCL_ds1302=0;
_nop_();
RST_ds1302=1;_nop_();_nop_();data_ds1302=0x8e;
for(i=1;i<=8;i++){
SCL_ds1302=0;
IO_ds1302=(data_ds1302&0x01);
_nop_();
SCL_ds1302=1;
data_ds1302=data_ds1302>>1;} data_ds1302=0x80;
IO_ds1302=0;for(i=1;i<=8;i++){
SCL_ds1302=0;
IO_ds1302=(data_ds1302&0x01);
_nop_();
SCL_ds1302=1;
data_ds1302=data_ds1302>>1;} }
void open_write_bit()//open write { unsigned int i;SCL_ds1302=0;_nop_();
//打開寫保護(hù)//關(guān)閉寫保護(hù)
RST_ds1302=1;_nop_();_nop_();data_ds1302=0x8e;for(i=1;i<=8;i++){
SCL_ds1302=0;
IO_ds1302=data_ds1302&0x01;
_nop_();SCL_ds1302=1;
data_ds1302=data_ds1302>>1;} data_ds1302=0x00;
//0x00,書上為0x80 IO_ds1302=0;for(i=1;i<=8;i++){
SCL_ds1302=0;
IO_ds1302=data_ds1302&0x01;
_nop_();SCL_ds1302=1;
data_ds1302=data_ds1302>>1;} }
void initial_ds1302()
//初始化函數(shù) { unsigned int i;SCL_ds1302=0;_nop_();RST_ds1302=1;_nop_();_nop_();data_ds1302=0x8e;
for(i=1;i<=8;i++){
SCL_ds1302=0;
IO_ds1302=data_ds1302&0x01;
_nop_();SCL_ds1302=1;
data_ds1302=data_ds1302>>1;} IO_ds1302=0;data_ds1302=0x00;
for(i=1;i<=8;i++){
SCL_ds1302=0;
IO_ds1302=data_ds1302&0x01;
_nop_();SCL_ds1302=1;
data_ds1302=data_ds1302>>1;} RST_ds1302=0;SCL_ds1302=0;_nop_();RST_ds1302=1;_nop_();_nop_();data_ds1302=0x90;
for(i=1;i<=8;i++){ SCL_ds1302=0;IO_ds1302=data_ds1302&0x01;_nop_();SCL_ds1302=1;data_ds1302=data_ds1302>>1;}
data_ds1302=0x0a4;
for(i=1;i<=8;i++){ SCL_ds1302=0;IO_ds1302=data_ds1302&0x01;_nop_();SCL_ds1302=1;data_ds1302=data_ds1302>>1;} RST_ds1302=0;_nop_();SCL_ds1302=0;_nop_();RST_ds1302=1;
data_ds1302=0x8e;
for(i=1;i<=8;i++){ SCL_ds1302=0;IO_ds1302=data_ds1302&0x01;_nop_();SCL_ds1302=1;data_ds1302=data_ds1302>>1;}
data_ds1302=0x80;
for(i=1;i<=8;i++){ SCL_ds1302=0;IO_ds1302=data_ds1302&0x01;_nop_();SCL_ds1302=1;data_ds1302=data_ds1302>>1;} RST_ds1302=0;_nop_();SCL_ds1302=0;}
unsigned char read_ds1302(char command)
//read函數(shù) { unsigned int i;data_ds1302=command;SCL_ds1302=0;_nop_();RST_ds1302=1;for(i=1;i<=8;i++){
SCL_ds1302=0;IO_ds1302=data_ds1302&0x01;_nop_();SCL_ds1302=1;data_ds1302=data_ds1302>>1;}
SCL_ds1302=1;for(i=1;i<=8;i++){
SCL_ds1302=0;
if(IO_ds1302)data_ds1302=(data_ds1302>>1)|0x80;
//送入到data_ds1302中,準(zhǔn)備送出
else data_ds1302>>=1;SCL_ds1302=1;} RST_ds1302=0;_nop_();SCL_ds1302=0;return(data_ds1302);}
void write_ds1302(unsigned char address,unsigned char numb){
unsigned int i;
SCL_ds1302=0;
RST_ds1302=0;
RST_ds1302=1;
data_ds1302=address;for(i=1;i<=8;i++){
SCL_ds1302=0;
IO_ds1302=data_ds1302&0x01;
//送入寫地址
_nop_();SCL_ds1302=1;
data_ds1302=data_ds1302>>1;} data_ds1302=numb;for(i=1;i<=8;i++){
SCL_ds1302=0;
IO_ds1302=data_ds1302&0x01;
_nop_();SCL_ds1302=1;
data_ds1302=data_ds1302>>1;} } void read_time(){ unsigned char second,minte,hour,d,date,month,year,zhou;second=0x81;
//讀秒
d=read_ds1302(second);display_buffer[5]=d&0x0f;display_buffer[4]=d>>4;minte=0x83;
//讀分
d=read_ds1302(minte);display_buffer[3]=d&0x0f;display_buffer[2]=d>>4;hour=0x85;
//讀時(shí)
d=read_ds1302(hour);display_buffer[1]=d&0x0f;display_buffer[0]=d>>4;year=0x8d;
//讀年
d=read_ds1302(year);display_buffer[7]=d&0x0f;display_buffer[6]=d>>4;month=0x89;
//讀月
d=read_ds1302(month);display_buffer[9]=d&0x0f;display_buffer[8]=d>>4;
//送入寫的內(nèi)容
zhou=0x8b;
//讀周d=read_ds1302(zhou);display_buffer[12]=d;date=0x87;
//讀日期
d=read_ds1302(date);display_buffer[11]=d&0x0f;display_buffer[10]=d>>4;}
void set_time(){ unsigned char data temp;unsigned char data hour_address=0x84,minte_address=0x82,second_address=0x80,date_address=0x86,month_address=0x88,zhou_address=0x8a,year_address=0x8c;//各個(gè)時(shí)間量的地址
open_write_bit();
temp=(display_buffer[0]<<4)|display_buffer[1];write_ds1302(hour_address,temp);
//寫小時(shí)
temp=(display_buffer[2]<<4)|display_buffer[3];write_ds1302(minte_address,temp);
//寫分鐘
temp=(display_buffer[4]<<4)|display_buffer[5];write_ds1302(second_address,temp);
//寫秒
temp=(display_buffer[6]<<4)|display_buffer[7];write_ds1302(year_address,temp);
//寫年
temp=(display_buffer[8]<<4)|display_buffer[9];write_ds1302(month_address,temp);
//寫月
temp=display_buffer[12];write_ds1302(zhou_address,temp);
//寫周temp=(display_buffer[10]<<4)|display_buffer[11];write_ds1302(date_address,temp);
//寫日期
close_write_bit();
}
void delay(unsigned int i)
//delay函數(shù) {
while(i--);}
void delayms(unsigned int i){ unsigned int n;while(i--){
for(n=0;n<125;n++);
} }
void displaytime(){ unsigned char e=0x01;unsigned int i;BIT_LED=0;
for(i=0;i<=5;i++){
if(i==5||i%2==0||i==11)
SEGMENT=table[display_buffer[i]];
else
SEGMENT=table1[display_buffer[i]];
BIT_LED=e;
e<<=1;
delayms(1);
}
}
void displaydate(){ unsigned char e=0x01;unsigned int i;BIT_LED=0;
for(i=6;i<=13;i++){
if(i==7||i==9)
SEGMENT=table1[display_buffer[i]];
else if(i==12)
SEGMENT=table[10];
else if(i==13)
SEGMENT=table[display_buffer[i-1]];
else
SEGMENT=table[display_buffer[i]];
BIT_LED=e;
e<<=1;delayms(1);
}
}
測試結(jié)果:
S1,S2實(shí)現(xiàn)年月日周與時(shí)分秒的切換
九、語音收錄播報(bào)測試:
測試要求:本系統(tǒng)中使用的是語音專用芯片IDS1760芯片,該芯片是以串行方式實(shí)現(xiàn)控制和數(shù)據(jù)傳輸?shù)摹?/p>
編寫如下程序進(jìn)行測試: #include
unsigned char bdata SR0_L;unsigned char bdata SR0_H;unsigned char bdata SR1;unsigned char APCL=0,APCH=0;unsigned char PlayAddL=0,PlayAddH=0;unsigned char RecAddL=0,RecAddH=0;
sbit CMD=SR0_L^0;sbit FULL=SR0_L^1;sbit PU=SR0_L^2;sbit EOM=SR0_L^3;sbit INTT=SR0_L^4;sbit RDY=SR1^0;sbit ERASE=SR1^1;sbit PLAY=SR1^2;sbit REC=SR1^3;
unsigned char ISD_SendData(unsigned char dat);void ISD_PU(void);void ISD_Rd_Status(void);void ISD_WR_APC2(unsigned char apcdatl,apcdath);void ISD_SET_PLAY(unsigned char Saddl,Saddh,Eaddl,Eaddh);void ISD_SET_Rec(unsigned char Saddl,Saddh,Eaddl,Eaddh);void ISD_SET_Erase(unsigned char Saddl,Saddh,Eaddl,Eaddh);
sbit SS=P1^4;sbit SCK=P1^7;sbit MOSI=P1^5;sbit MISO=P1^6;
void Cpu_Init(void);void ISD_Init(void);void delay(unsigned int t);
void main(){ Cpu_Init();ISD_Init();
while(1){ ISD_SET_Erase(0,0,9,0);ISD_SET_Rec(0,0,9,0);ISD_SET_PLAY(0,0,9,0);} }
void Cpu_init(void){ P0=P1=P2=P3=0xff;TMOD=0x01;EA=0;} void ISD_Init(void){ uchar i=2;SS=1;SCK=1;MOSI=0;do { ISD_PU();//上電 delay(50);ISD_Rd_Status();//讀取狀態(tài)
}while(CMD||(!PU));
//if(CMD_Err==1||(PU!+1))則再次發(fā)送上電指令 ISD_WR_APC2(0x40,0x04);//將0x0440寫入APC寄存器
do { ISD_Rd_Status();}while(RDY==0);do { delay(300);delay(300);i--;}while(i>0);}
//向cpu讀回或發(fā)送數(shù)據(jù)
unsigned char ISD_SendData(unsigned char dat){ unsigned char i,j,BUF_ISD=dat;SCK=1;SS=0;for(j=4;j>0;j--){;}
for(i=0;i<8;i++){ SCK=0;for(j=2;j>0;j--){;} if(BUF_ISD&0x01)
{MOSI=1;} else
{MOSI=0;} BUF_ISD>>=1;if(MISO)
{BUF_ISD|=0x80;} SCK=1;for(j=6;j>0;j--){;} } MOSI=0;return(BUF_ISD);} void ISD_PU(void){
ISD_SendData(0x01);
ISD_SendData(0x00);
SS=1;} void ISD_Rd_Status(void){ unsigned char i;ISD_SendData(0x05);ISD_SendData(0x00);ISD_SendData(0x00);SS=1;for(i=2;i>0;i--){;} SR0_L=ISD_SendData(0x05);SR0_H=ISD_SendData(0x00);SR1=ISD_SendData(0x00);SS=1;}
void ISD_WR_APC2(unsigned char apcdatl,apcdath){ ISD_SendData(0x65);ISD_SendData(apcdatl);ISD_SendData(apcdath);SS=1;}
void ISD_SET_PLAY(unsigned char Saddl,Saddh,Eaddl,Eaddh){ ISD_SendData(0x80);ISD_SendData(0x00);ISD_SendData(Saddl);ISD_SendData(Saddh);ISD_SendData(Eaddl);ISD_SendData(Eaddh);ISD_SendData(0x00);SS=1;}
void ISD_SET_Rec(unsigned char Saddl,Saddh,Eaddl,Eaddh){
ISD_SendData(0x81);ISD_SendData(0x00);ISD_SendData(Saddl);ISD_SendData(Saddh);ISD_SendData(Eaddl);ISD_SendData(Eaddh);ISD_SendData(0x00);SS=1;}
void ISD_SET_Erase(unsigned char Saddl,Saddh,Eaddl,Eaddh){ ISD_SendData(0x82);ISD_SendData(0x00);ISD_SendData(Saddl);ISD_SendData(Saddh);ISD_SendData(Eaddl);ISD_SendData(Eaddh);ISD_SendData(0x00);SS=1;} void delay(unsigned int t){ for(;t>0;t--){ TH0=0xfc;TL0=0x18;TR0=1;while(TF0!=1){;} TF0=0;TR0=0;} }
測試結(jié)果:需要在程序中設(shè)置斷點(diǎn),完成錄音,放音再錄音放音的循環(huán)操作。
測試功能正常。
十、單片機(jī)模塊調(diào)試
測試要求:該模塊的調(diào)試很復(fù)雜,牽扯面也很多。其實(shí)通過前面各個(gè)模塊的調(diào)試,已經(jīng)大部分得到了間接地驗(yàn)證。例如在“動態(tài)數(shù)碼管測試”和“串行通訊測試”中就是用到了定時(shí)器。
如有必要可以再編寫一些測試程序。例如檢測單片機(jī)的某一口線的功能是否正常、測試某段程序運(yùn)行時(shí)間,等等。
測試結(jié)論:因單片機(jī)大部分功能在前調(diào)試方案中大部分已使用過,此處不再進(jìn)行其余調(diào)試。