智能小車設(shè)計報告智能小車設(shè)計報告
-
資源ID:56730301
資源大?。?span id="hbnbtph" class="font-tahoma">5.57MB
全文頁數(shù):37頁
- 資源格式: DOCX
下載積分:5積分
快捷下載
會員登錄下載
微信登錄下載
微信掃一掃登錄
友情提示
2、PDF文件下載后,可能會被瀏覽器默認(rèn)打開,此種情況可以點(diǎn)擊瀏覽器菜單,保存網(wǎng)頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站資源下載后的文檔和圖紙-無水印,預(yù)覽文檔經(jīng)過壓縮,下載后原文更清晰。
5、試題試卷類文檔,如果標(biāo)題沒有明確說明有答案則都視為沒有答案,請知曉。
|
智能小車設(shè)計報告智能小車設(shè)計報告
電子設(shè)計大賽設(shè)計報告 題目名稱_智能搬運(yùn)小車 _學(xué)生學(xué)院_物理與光電工程學(xué)院 _隊(duì)員 莊偉林 林鑒杰 陳奕利 2009年 5月 1日裝配圖(正面)智能搬運(yùn)小車設(shè)計報告一、 總體框架(1)、本搬動小車通過單片機(jī)AT89S52,用三個373分時輸入外部信號,通過分析處理,再用一個573芯片輸出步進(jìn)電機(jī)驅(qū)動信號,成功地實(shí)現(xiàn)了取放黑鐵,尋找右光源和左光源的功能。(2)、電路方框圖。步進(jìn)電機(jī)運(yùn)轉(zhuǎn)直流電機(jī)驅(qū)動取放鐵片普通光敏電阻控測光源光敏對管PRP控測黑鐵片輸出聲光信號(3)系統(tǒng)總框圖。四相六線步進(jìn)電機(jī)LM2003主控芯片AT89S52系統(tǒng)總框圖二、硬件實(shí)現(xiàn)及單元電路設(shè)計。1、主控芯片AT89S52。AT89S52 主要性能; 與MCS-51單片機(jī)產(chǎn)品兼容 、8K字節(jié)在系統(tǒng)可編程Flash存儲器、 1000次擦寫周期、 全靜態(tài)操作:0Hz33Hz 、 三級加密程序存儲器 、 32個可編程I/O口線 、三個16位定時器/計數(shù)器 八個中斷源 、全雙工UART串行通道、 低功耗空閑和掉電模式 、掉電后中斷可喚醒 、看門狗定時器 、雙數(shù)據(jù)指針 、掉電標(biāo)識符 。功能特性描述 At89s52 是一種低功耗、高性能CMOS8位微控制器,具有 8K 在系統(tǒng)可編程Flash 存儲器。使用Atmel 公司高密度非 易失性存儲器技術(shù)制造,與工業(yè)80C51 產(chǎn)品指令和引腳完 全兼容。片上Flash允許程序存儲器在系統(tǒng)可編程,亦適于 常規(guī)編程器。在單芯片上,擁有靈巧的8 位CPU 和在系統(tǒng) 可編程Flash,使得AT89S52為眾多嵌入式控制應(yīng)用系統(tǒng)提 供高靈活、超有效的解決方案。 AT89S52具有以下標(biāo)準(zhǔn)功能: 8k字節(jié)Flash,256字節(jié)RAM, 32 位I/O 口線,看門狗定時器,2 個數(shù)據(jù)指針,三個16 位 定時器/計數(shù)器,一個6向量2級中斷結(jié)構(gòu),全雙工串行口, 片內(nèi)晶振及時鐘電路。另外,AT89S52 可降至0Hz 靜態(tài)邏輯操作,支持2種軟件可選擇節(jié)電模式??臻e模式下,CPU 停止工作,允許RAM、定時器/計數(shù)器、串口、中斷繼續(xù)工 作。掉電保護(hù)方式下,RAM內(nèi)容被保存,振蕩器被凍結(jié), 單片機(jī)一切工作停止,直到下一個中斷或硬件復(fù)位為止。8 位微控制器 8K 字節(jié)在系統(tǒng)可編程 Flash AT89S52。 2、直流電機(jī)驅(qū)動取放鐵片。考慮到電磁鐵耗電很大,所以我們選擇用直流電機(jī)機(jī)械方式實(shí)現(xiàn)鐵片的取放。通過L298芯片驅(qū)動,用直流電機(jī)實(shí)現(xiàn)磁鐵的磁鐵上升(放下鐵塊)或下降(吸上鐵片)。我們考慮了幾種方案實(shí)現(xiàn)直流電機(jī)的驅(qū)動;L298電路圖如下。直流電機(jī)驅(qū)動電路圖L298電路圖升上磁鐵,放下鐵片天然磁鐵平衡臂步進(jìn)電機(jī)直流電機(jī)鐵片萬向輪放下鐵片放鐵片原理圖直流電機(jī)天然磁鐵平衡臂步進(jìn)電機(jī)放下磁鐵,吸上鐵片鐵片萬向輪取鐵片原理圖3、 探測黑白鐵片與邊界。以下為我們考慮的方案;我們使用PRP光電對管實(shí)現(xiàn)對黑白鐵以及邊界的探測。光電對管實(shí)物圖電壓比較器TL084信號處理實(shí)物圖PRP光電一體化對管原理圖R21M光電對管檢測電路圖4、 步進(jìn)電機(jī)與驅(qū)動。方案選擇;由于本系統(tǒng)為智能電動車,其驅(qū)動輪的驅(qū)動電機(jī)的選擇就顯得十分重要。由于小車要實(shí)現(xiàn)對路徑的準(zhǔn)確定位和精確測量,我們綜合考慮了一下兩種方案:方案1;采用步進(jìn)電機(jī)作為該系統(tǒng)的驅(qū)動電機(jī)。由于其轉(zhuǎn)過的角度可以精確地定位,可以實(shí)現(xiàn)小車前進(jìn)路程和位置的精確確定位。方案2:采用直流減速電機(jī)。直流減速電機(jī)轉(zhuǎn)動力矩大,體積小,重量輕,裝配方便,但是不能做到很好的定位。權(quán)衡利弊,我們選擇了第一方案。小車驅(qū)動部份我們選擇用二相六線步進(jìn)電機(jī)。因?yàn)椴竭M(jìn)電機(jī)可以很好地實(shí)現(xiàn)同步與精確控制功能,但是缺點(diǎn)是耗電大,震動大。但權(quán)衡利弊,與直流電機(jī)相雙,步進(jìn)電機(jī)驅(qū)動力強(qiáng)大,所以我們選擇用步進(jìn)電機(jī)。步進(jìn)電機(jī)作為執(zhí)行元件,是機(jī)電一體化的關(guān)鍵產(chǎn)品之一, 廣泛應(yīng)用在各種自動化控制系統(tǒng)中。隨著微電子和計算機(jī)技術(shù)的發(fā)展,步進(jìn)電機(jī)的需求量與日俱增,在各個國民經(jīng)濟(jì)領(lǐng)域都有應(yīng)用。步進(jìn)電機(jī)是一種將電脈沖轉(zhuǎn)化為角位移的執(zhí)行機(jī)構(gòu)。當(dāng)步進(jìn)驅(qū)動器接收到一個脈沖信號,它就驅(qū)動步進(jìn)電機(jī)按設(shè)定的方向轉(zhuǎn)動一個固定的角度(稱為“步距角”),它的旋轉(zhuǎn)是以固定的角度一步一步運(yùn)行的。可以通過控制脈沖個數(shù)來控制角位移量,從而達(dá)到準(zhǔn)確定位的目的;同時可以通過控制脈沖頻率來控制電機(jī)轉(zhuǎn)動的速度和加速度,從而達(dá)到調(diào)速的目的。步進(jìn)電機(jī)可以作為一種控制用的特種電機(jī),利用其沒有積累誤差(精度為100%)的特點(diǎn),廣泛應(yīng)用于各種開環(huán)控制?,F(xiàn)在比較常用的步進(jìn)電機(jī)包括反應(yīng)式步進(jìn)電機(jī)(vr)、永磁式步進(jìn)電機(jī)(pm)、混合式步進(jìn)電機(jī)(hb)和單相式步進(jìn)電機(jī)等。永磁式步進(jìn)電機(jī)一般為兩相,轉(zhuǎn)矩和體積較小,步進(jìn)角一般為7.5度 或15度;反應(yīng)式步進(jìn)電機(jī)一般為三相,可實(shí)現(xiàn)大轉(zhuǎn)矩輸出,步進(jìn)角一般為1.5度,但噪聲和振動都很大。反應(yīng)式步進(jìn)電機(jī)的轉(zhuǎn)子磁路由軟磁材料制成,定子上有多相勵磁繞組,利用磁導(dǎo)的變化產(chǎn)生轉(zhuǎn)矩?;旌鲜讲竭M(jìn)電機(jī)是指混合了永磁式和反應(yīng)式的優(yōu)點(diǎn)。它又分為兩相和五相:兩相步進(jìn)角一般為1.8度而五相步進(jìn)角一般為 0.72度。這種步進(jìn)電機(jī)的應(yīng)用最為廣泛,也是本次細(xì)分驅(qū)動方案所選用的步進(jìn)電機(jī)。我們的步進(jìn)電機(jī)使用的驅(qū)動芯片是lm2003。步進(jìn)電機(jī)驅(qū)動芯片LM2003實(shí)物圖LM2003芯片原理圖步進(jìn)電機(jī)實(shí)物圖LM2003步進(jìn)電機(jī)驅(qū)動相圖二相六線步進(jìn)電機(jī)接線圖5、 尋找光源。當(dāng)光敏二極管正對光源時,電阻變小,經(jīng)過電壓比較器向單片機(jī)輸入信號。尋找光源用的光敏對管,為了防止干擾,用筆筒套上光敏電阻。6、 電路板。我們通過Protel dxp繪制電路圖后,采用熱轉(zhuǎn)印方法制成PCB雙面板。蜂鳴器與發(fā)光二極管,輸出聲光信號74hc373作為光電對管信號輸入鎖存器,PO分時讀取外部鎖存器,實(shí)現(xiàn)單片機(jī)的輸出口和輸入口擴(kuò)展主控電路AT89S52輸出鎖存器74hc573,作為單片機(jī)分時存出的輸出口。主板穩(wěn)壓電路1602lcd插口主電路板實(shí)物圖(正面)主電路板實(shí)物圖(反面)主電路板pcb圖主電路板各部分原理圖如下:6智能小車程序框圖。初始化前進(jìn)定時器T2定時中斷,中斷子程序輸入光電對管信號,判斷是否遇到黑色信號或白色信號。白鐵黑鐵判斷遇到黑鐵或白鐵或邊界尋找左光源,返回A停車區(qū)。尋找右光源,返回B停車區(qū)。否向前對齊,繼續(xù)掃描是否取完3塊鐵片返回停車區(qū),結(jié)束。7、 智能小車源程序。#include<at89x52.h>unsigned int minute=0;second=0,sum=0;unsigned char idata minute1=0,second1=0;sum1=0;unsigned char idata recordminute1=0,recordsecond1=0,recordsum1=0;unsigned char idata recordminute2=0,recordsecond2=0,recordsum2=0;unsigned char bdata status=0;unsigned char bdata status1=0;unsigned char bdata status2=0;unsigned char bdata prpflagd;unsigned char bdata prpflage;unsigned int idata time0=0;unsigned long int idata time2=0;unsigned long int idata time2_1;unsigned int idata time2_2;unsigned char data motor=0;unsigned char bdata d=0;unsigned char bdata e=0;unsigned char bdata d1=0;unsigned char bdata e1=0;unsigned char lightcount=0;unsigned char v0;unsigned char vb;sbit prp5_0=d16;sbit prp5_1=d17;sbit prp1_0=d14;sbit prp1_1=d15;sbit prp6_0=d12;sbit prp6_1=d13;sbit prp2_0=d10;sbit prp2_1=d11;sbit prp7_0=e16;sbit prp7_1=e17;sbit prp3_0=e14;sbit prp3_1=e15;sbit prp8_0=e12;sbit prp8_1=e13;sbit prp4_0=e10;sbit prp4_1=e11;sbit prp5_000=prpflagd6;sbit prp5_001=prpflagd7;sbit prp1_000=prpflagd4;sbit prp1_001=prpflagd5;sbit prp6_000=prpflagd2;sbit prp6_001=prpflagd3;sbit prp2_000=prpflagd0;sbit prp2_001=prpflagd1;sbit prp7_000=prpflage6;sbit prp7_001=prpflage7;sbit prp3_000=prpflage4;sbit prp3_001=prpflage5;sbit prp8_000=prpflage2;sbit prp8_001=prpflage3;sbit prp4_000=prpflage0;sbit prp4_001=prpflage1;sbit prp5_00=d6;sbit prp5_01=d7;sbit prp1_00=d4;sbit prp1_01=d5;sbit prp6_00=d2;sbit prp6_01=d3;sbit prp2_00=d0;sbit prp2_01=d1;sbit prp7_00=e6;sbit prp7_01=e7;sbit prp3_00=e4;sbit prp3_01=e5;sbit prp8_00=e2;sbit prp8_01=e3;sbit prp4_00=e0;sbit prp4_01=e1;sbit forward=status0;sbit backward=status1;sbit turnleft=status3;sbit turnright=status2;sbit rightforward=status5;sbit rightbackward=status4;sbit leftforward=status6;sbit leftbackward=status7;sbit flag=status15; sbit whiteiron=status16;sbit blackiron=status20;sbit searchiron=status10;sbit searchrightlight=status11;sbit seachleftlight=status12;unsigned char interfere;unsigned char uninterfere;sbit rightorleft=status14;sbit unflag=status23;sbit foundblack=status24;sbit foundwhite=status25;sbit foundboundary=status26;unsigned char whiteironcount=0;unsigned char blackironcount=0;unsigned char ironcount=0;void timer0initializtion();void timer2initializtion();void turnright90degree();void turnleft90degree();void putdown();void goforwardaccelerat();void gobackwardaccelerat();void putup();void foundblackiron();void foundwhiteiron();void turnright180degree();void backwardalign();void forwardalign();void estimate();void boundaryturnright90degree();void boundaryturnright180degree();void boundaryturnleft180degree();void searchlightblackiron();void oneturnleft80degree();void oneturnright80degree();void oneturnright180degree();void oneturnleft80degree();void searchlightwhiteiron();void searchlightwhiteiron();void scan();void main()timer0initializtion();timer2initializtion();time2=0;while(time2<=50);rightorleft=0;status=0;goforwardaccelerat();flag=0;while(flag=0);estimate();if(foundboundary=1)boundaryturnright90degree();scan();estimate();if(foundwhite=1)putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();scan();estimate();if(foundwhite=1)putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();scan();estimate();if(foundwhite=1)putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();scan();estimate();if(foundwhite=1) putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();goto end0200;elseif(foundblack=1)putdown();searchlightblackiron();scan();estimate();if(foundwhite=1) putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();scan();estimate();if(foundwhite=1)putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();scan();estimate();if(foundwhite=1) putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();goto end0200;elseif(foundwhite=1)putdown();searchlightwhiteiron();scan();estimate();if(foundwhite=1)putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();scan();estimate();if(foundwhite=1) putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();scan();estimate();if(foundwhite=1) putdown();searchlightwhiteiron();elseputdown();searchlightblackiron();end0200:while(1);void goforwardaccelerat()status=0;forward=1;vb=5;time2=0;while(time2<=8);vb=4;time2=0;while(time2<=8);vb=3;time2=0;while(time2<=8);vb=2;time2=0;while(time2<=8);vb=1;void gobackwardaccelerat()status=0;backward=1;vb=5;time2=0;while(time2<=8);vb=4;time2=0;while(time2<=8);vb=3;time2=0;while(time2<=8);vb=2;time2=0;while(time2<=8);vb=1;void scan()status=0;while(foundblack!=1)&&(foundwhite!=1)goforwardaccelerat();flag=0;while(flag=0);status=0;estimate();if(foundboundary=1)foundboundary=0;if(rightorleft=1)rightorleft=0;boundaryturnleft180degree();time2=0;while(time2<=8);status=0;elserightorleft=1;boundaryturnright180degree();time2=0;while(time2<=8);status=0;void searchlightblackiron()unsigned long int lightdalign;rightorleft=0;vb=4;turnright=1;while(prp8_01=1);status=0;time2=0;while(time2<=20);turnright=1;time2=0;while(time2<=30);time2=0;while(prp8_01=1);status=0;if(time2<=180)goto b0173; status=0;turnright=1;time2=0;while(time2<=20);while(prp8_01=1);time2=0;while(time2<=10);status=0;time2=0;while(time2<=20);b0173:time2_1=0;goforwardaccelerat();time2=0;while(time2<=40);flag=0;while(flag=0);time2=0;while(time2<=40);status=0;putup();time2=0;while(time2<=8);turnright180degree();goforwardaccelerat();time2=0;while(time2<=90);b0294:status=0;forward=1;flag=0;while(flag=0);estimate();if(foundboundary=0)goto b0294;status=0;time2=0;while(time2<=8);gobackwardaccelerat();forwardalign();status=0;vb=4;turnright=1;time2=0;while(prp8_01=1);status=0;lightdalign=time2;if(lightdalign<=150)turnleft=1;time2=0;while(time2<=lightdalign);status=0;turnleft90degree();turnleft=1;time2=0;while(time2<=20);status=0;time2=0;while(time2<=8);b0621:vb=1;forward=1;flag=0;while(flag=0);status=0;estimate();if(foundboundary=1)forwardalign();boundaryturnright90degree();elsegoto b0621;elsetime2=0;while(time2<=8);turnleft=1;time2=0;while(time2<=lightdalign);status=0;forwardalign();boundaryturnright90degree();void searchlightwhiteiron()unsigned long int lightdalign;rightorleft=0;vb=4;turnleft=1;while(prp8_01=1);status=0;time2=0;while(time2<=20);turnleft=1;time2=0;while(time2<=30);time2=0;while(prp8_01=1);status=0;if(time2<=180)goto b0374; status=0;turnleft=1;time2=0;while(time2<=20);while(prp8_01=1);time2=0;while(time2<=10);status=0;time2=0;while(time2<=20);b0374:time2_1=0;goforwardaccelerat();time2=0;while(time2<=40);flag=0;while(flag=0);time2=0;while(time2<=40);status=0;putup();time2=0;while(time2<=8);turnright180degree();goforwardaccelerat();time2=0;while(time2<=90);b0410:forward=1;flag=0;while(flag=0);estimate();if(foundboundary=0)goto b0410;status=0;time2=0;while(time2<=8);gobackwardaccelerat();forwardalign();status=0;vb=4;turnleft=1;time2=0;while(prp8_01=1);status=0;lightdalign=time2;if(lightdalign<=150)turnright=1;time2=0;while(time2<=lightdalign);status=0;turnright90degree();turnright=1;time2=0;while(time2<=20);status=0;time2=0;while(time2<=8);b0431:vb=1;forward=1;flag=0;while(flag=0);status=0;estimate();if(foundboundary=1)forwardalign();boundaryturnright90degree();elsegoto b0431;elsetime2=0;while(time2<=8);turnright=1;time2=0;while(time2<=lightdalign);status=0;forwardalign();boundaryturnright90degree();void boundaryturnright90degree()status=0;vb=3;backward=1;time2=0;while(time2<=30);vb=4;status=0;turnright=1;time2=0;while(time2<=122);status=0;time2=0;while(time2<=10);void oneturnright80degree()status=0;vb=5;leftforward=1;time2=0;while(time2<=215);status=0;time2=0;while(time2<=8);void oneturnleft180degree()status=0;vb=5;rightforward=1;time2=0;while(time2<=505);status=0;time2=0;while(time2<=8);void oneturnright180degree()status=0;vb=5;leftforward=1;time2=0;while(time2<=505);status=0;time2=0;while(time2<=8);void oneturnleft80degree()status=0;vb=5;rightforward=1;time2=0;while(time2<=225);status=0;time2=0;while(time2<=8);void boundaryturnleft180degree()status=0;forwardalign();vb=3;status=0;backward=1;time2=0;while(time2<=68);status=0;oneturnleft180degree();time2=0;while(time2<=10);backwardalign();time2=0;while(time2<=8);void boundaryturnright180degree()status=0;forwardalign();vb=3;status=0;backward=1;time2=0;while(time2<=68);status=0;oneturnright180degree();time2=0;while(time2<=10);backwardalign();time2=0;while(time2<=8);void forwardalign()vb=4;status=0;backward=1;time2=0;while(time2<=15);unflag=0; while(unflag=0)time2=0;if(time2>=50)break;status=0;time2=0;while(time2<=10);forward=1;while(prp4_000=0);status=0;time2=0;while(time2<=10);if(prp7_000=1)&&(prp1_000=0)status=0;turnright=1;while(prp1_000=0);status=0;time2=0;while(time2<=10);if(prp7_000=1)rightbackward=1;while(prp7_000=1);elserightforward=1;while(prp7_000=0);elseif(prp7_000=0)&&(prp1_000=1)status=0;turnleft=1;while(prp7_000=0);status=0;time2=0;while(time2<=10);if(prp1_000=1)leftbackward=1;while(prp1_000=1);elseleftforward=1;while(prp1_000=0);status=0;time2=0;while(time2<=18); void backwardalign()unsigned char backwardaligncount=0;b0353:backwardaligncount+;status=0;vb=4;forward=1;time2=0;while(time2<=15);unflag=0; while(unflag=0)time2=0;if(time2>=50)break;status=0;time2=0;while(time2<=10);backward=1;while(prp4_000=0);status=0;time2=0;while(time2<=10);if(prp6_000=1)&&(prp1_000=0)turnleft=1;while(prp1_000=0);status=0;time2=0;while(time2<=10);if(prp6_000=1)rightforward=1;while(prp6_000=1);elserightbackward=1;while(prp6_000=0);elseif(prp6_000=0)&&(prp1_000=1)turnright=1;while(prp6_000=0);status=0;time2=0;while(time2<=10);if(prp1_000=1)leftforward=1;while(prp6_000=1);elseleftbackward=1;while(prp6_000=0);status=0;time2=0;while(time2<=18);if(backwardaligncount<=3)goto b0353; status=0;void turnleft90degree()vb=4;status=0;turnleft=1;time2=0;while(time2<=110);status=0; time2=0;while(time2<=10);void turnright90degree()vb=4;status=0;turnright=1;time2=0;while(time2<=115);status=0;time2=0;while(time2<=10);void turnright180degree()vb=4;status=0;turnright=1; time2=0;while(time2<=230); turnright=0;time2=0;while(time2<=15);vb=3;void putup()status=0;time2=0;while(time2<=80)status=0;P1=0x05;P1=0xff;time2=0;while(time2<=30);time2=0;while(time2<=80)status=0;P1=0x05;P1=0xff;time2=0;while(time2<=30);time2=0;while(time2<=80)status=0;P1=0x05; P1=0xff;void putdown()status=0;forward=1;time2=0;while(time2<=3);status=0;time2=0;while(time2<=150)P1=0x03;P1=0xff;time2=0;while(time2<=8);vb=3;status=0;forward=1;time2=0;while(time2<=16);status=0;time2=0;while(time2<=8);vb=3;status=0;backward=1;time2=0;while(time2<=32);status=0;time2=0;while(time2<=8);forward=1;time2=0;while(time2<=16);status=0;time2=0;while(time2<=8); void estimate()unsigned char bj1=0;unsigned char bj2=0;unsigned char bj3=0;unsigned char bj4=0; unsigned char bj5=0;foundblack=0;foundboundary=0;foundwhite=0;e1=e;d1=d;vb=2;forward=1;time2=0;while(time2<=50)if(prp1_000=1)bj1=1;if(prp3_000=1)bj2=1;if(prp5_000=1)bj5=1;if(prp7_000=1)bj4=1;if(prp1_001=0)|(prp2_001=0)|(prp3_001=0)|(prp4_001=0)|(prp5_001=0)|(prp6_001=0)|(prp7_001=0)bj3=1;status=0;backward=1;time2=0;while(time2<=50);status=0;if(bj5=1)&&(bj1=1)|(bj2=1)&&(bj4=1)foundboundary=1;elseif(bj3=1)foundwhite=1;WR=0;time2=0;while(time2<=18);WR=1;elsefoundblack=1;WR=0;time2=0;while(time2<=18);WR=1;time2=0;while(time2<=18);WR=0;time2=0;while(time2<=18);WR=1;time2=0;while(time2<=18);WR=0;time2=0;while(time2<=18);WR=1;time2=0;while(time2<=18);void timer0initializtion()TMOD=0X01;TH0=0xd8;TL0=0xef;EA=1;ET0=1;PT0=0;TR0=1; void timer2initializtion() /50MSET2=1;TCLK=0;RCLK=0;CP_RL2=0;T2MOD=0x0;C_T2=0;RCAP2H=0x3c;RCAP2L=0xb0;PT2=1;TR2=1; void T2interrupt() interrupt 5 unsigned char idata i;time2+;time2_1+;time2_2+;sum=sum+1;sum1=sum1+1;if(sum=20)sum=0;second=second+1; if(second=60) second=0; minute=minute+1; if(minute=60) minute=0; if(sum1=20)sum1=0;second1=second1+1;if(second1=60) second1=0; minute1=minute1+1; RD=0;P2=0x8c;P0=0xff;for(i=0;i<=2;i+);d=P0;d=P0;P2=0x84;P0=0xff;for(i=0;i<=2;i+);e=P0;e=P0;RD=1;P2=0xff;if(d!=0xaa)|(e&0xf3)!=0xa2)if(interfere<=2)interfere+;if(interfere=3)flag=1;prpflagd=d;prpflage=e;interfere=0;elseinterfere=0; if(d=0xaa)&&(e&0xf3)=0xa2)if(uninterfere<=3)uninterfere+;if(uninterfere=4)unflag=1;flag=0;prpflagd=d;prpflage=e;uninterfere=0;elseuninterfere=0; TF2=0;void tO() interrupt 1 /V=9cm/s interrupt time=13msTH0=0xcd;TL0=0x38;time0+;v0+;P2=0x9c;if(status=0x01) /V=9cm/sif(v0>=vb)v0=0;if(motor=0x18)motor=0x42;else if(motor=0x42) motor=0x24; else if(motor=0x24) motor=0x81; else if(motor=0x81) motor=0x18; else motor=0x18; if(status=0x02) / V=9cm/sif(v0>=vb)v0=0;if(motor=0x81)motor=0x24;else if(motor=0x24) motor=0x42; else if(motor=0x42) motor=0x18; else if(motor=0x18) motor=0x81; else motor=0x18; if(status=0x04)if(v0>=vb)v0=0;time0=0;if(motor=0x11)motor=0x44;else if(motor=0x44) motor=0x22; else if(motor=0x22) motor=0x88; else if(motor=0x88) motor=0x11; else motor=0x11; if(status=0x08)if(v0>=vb)v0=0;time0=0;if(motor=0x88)motor=0x22;else if(motor=0x22) motor=0x44; else if(motor=0x44) motor=0x11; else if(motor=0x11) motor=0x88; else motor=0x11;