智能小車設(shè)計(jì)報(bào)告智能小車設(shè)計(jì)報(bào)告_第1頁(yè)
智能小車設(shè)計(jì)報(bào)告智能小車設(shè)計(jì)報(bào)告_第2頁(yè)
智能小車設(shè)計(jì)報(bào)告智能小車設(shè)計(jì)報(bào)告_第3頁(yè)
智能小車設(shè)計(jì)報(bào)告智能小車設(shè)計(jì)報(bào)告_第4頁(yè)
智能小車設(shè)計(jì)報(bào)告智能小車設(shè)計(jì)報(bào)告_第5頁(yè)
已閱讀5頁(yè),還剩23頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

電子設(shè)計(jì)大賽設(shè)計(jì)報(bào)告題目名稱_____智能搬運(yùn)小車__學(xué)生學(xué)院___物理和光電工程學(xué)院_隊(duì)員莊偉林林鑒杰陳奕利2009年5月1日裝配圖(正面)裝配圖(正面)智能搬運(yùn)小車設(shè)計(jì)報(bào)告總體框架(1)、本搬動(dòng)小車通過(guò)單片機(jī)AT89S52,用三個(gè)373分時(shí)輸入外部信號(hào),通過(guò)分析處理,再用一個(gè)573芯片輸出步進(jìn)電機(jī)驅(qū)動(dòng)信號(hào),成功地實(shí)現(xiàn)了取放黑鐵,尋找右光源和左光源的功能。(2)、電路方框圖。步進(jìn)電機(jī)運(yùn)轉(zhuǎn)直流電機(jī)驅(qū)動(dòng)取放鐵片步進(jìn)電機(jī)運(yùn)轉(zhuǎn)直流電機(jī)驅(qū)動(dòng)取放鐵片普通光敏電阻控測(cè)光源普通光敏電阻控測(cè)光源光敏對(duì)管PRP光敏對(duì)管PRP控測(cè)黑鐵片輸出聲光信號(hào)輸出聲光信號(hào)(3)系統(tǒng)總框圖。四相六線步進(jìn)電機(jī)LM2003主控芯片AT89S52四相六線步進(jìn)電機(jī)LM2003主控芯片AT89S52系統(tǒng)總框圖二、硬件實(shí)現(xiàn)及單元電路設(shè)計(jì)。1、主控芯片AT89S52。AT89S52主要性能;和MCS-51單片機(jī)產(chǎn)品兼容、8K字節(jié)在系統(tǒng)可編程Flash存儲(chǔ)器、1000次擦寫(xiě)周期、全靜態(tài)操作:0Hz~33Hz、三級(jí)加密程序存儲(chǔ)器、32個(gè)可編程I/O口線、三個(gè)16位定時(shí)器/計(jì)數(shù)器八個(gè)中斷源、全雙工UART串行通道、低功耗空閑和掉電模式、掉電后中斷可喚醒、看門狗定時(shí)器、雙數(shù)據(jù)指針、掉電標(biāo)識(shí)符。功能特性描述At89s52是一種低功耗、高性能CMOS8位微控制器,具有8K在系統(tǒng)可編程Flash存儲(chǔ)器。使用Atmel公司高密度非易失性存儲(chǔ)器技術(shù)制造,和工業(yè)80C51產(chǎn)品指令和引腳完全兼容。片上Flash允許程序存儲(chǔ)器在系統(tǒng)可編程,亦適于常規(guī)編程器。在單芯片上,擁有靈巧的8位CPU和在系統(tǒng)可編程Flash,使得AT89S52為眾多嵌入式控制使用系統(tǒng)提供高靈活、超有效的解決方案。AT89S52具有以下標(biāo)準(zhǔn)功能:8k字節(jié)Flash,256字節(jié)RAM,32位I/O口線,看門狗定時(shí)器,2個(gè)數(shù)據(jù)指針,三個(gè)16位定時(shí)器/計(jì)數(shù)器,一個(gè)6向量2級(jí)中斷結(jié)構(gòu),全雙工串行口,片內(nèi)晶振及時(shí)鐘電路。另外,AT89S52可降至0Hz靜態(tài)邏輯操作,支持2種軟件可選擇節(jié)電模式??臻e模式下,CPU停止工作,允許RAM、定時(shí)器/計(jì)數(shù)器、串口、中斷繼續(xù)工作。掉電保護(hù)方式下,RAM內(nèi)容被保存,振蕩器被凍結(jié),單片機(jī)一切工作停止,直到下一個(gè)中斷或硬件復(fù)位為止。8位微控制器8K字節(jié)在系統(tǒng)可編程FlashAT89S52。2、直流電機(jī)驅(qū)動(dòng)取放鐵片??紤]到電磁鐵耗電很大,所以我們選擇用直流電機(jī)機(jī)械方式實(shí)現(xiàn)鐵片的取放。通過(guò)L298芯片驅(qū)動(dòng),用直流電機(jī)實(shí)現(xiàn)磁鐵的磁鐵上升(放下鐵塊)或下降(吸上鐵片)。我們考慮了幾種方案實(shí)現(xiàn)直流電機(jī)的驅(qū)動(dòng);L298電路圖如下。直流電機(jī)驅(qū)動(dòng)電路圖直流電機(jī)驅(qū)動(dòng)電路圖L298電路圖升上磁鐵,放下鐵片升上磁鐵,放下鐵片天然磁鐵天然磁鐵平衡臂步進(jìn)電機(jī)直流電機(jī)平衡臂步進(jìn)電機(jī)直流電機(jī)鐵片鐵片萬(wàn)向輪放下鐵片萬(wàn)向輪放下鐵片放鐵片原理圖直流電機(jī)天然磁鐵直流電機(jī)天然磁鐵平衡臂平衡臂步進(jìn)電機(jī)放下磁鐵,吸上鐵片步進(jìn)電機(jī)放下磁鐵,吸上鐵片鐵片鐵片萬(wàn)向輪萬(wàn)向輪取鐵片原理圖探測(cè)黑白鐵片和邊界。以下為我們考慮的方案;我們使用PRP光電對(duì)管實(shí)現(xiàn)對(duì)黑白鐵以及邊界的探測(cè)。光電對(duì)管實(shí)物圖電壓比較器TL084電壓比較器TL084信號(hào)處理實(shí)物圖PRP光電一體化對(duì)管原理圖R21M光電對(duì)管檢測(cè)電路圖R21M步進(jìn)電機(jī)和驅(qū)動(dòng)。方案選擇;由于本系統(tǒng)為智能電動(dòng)車,其驅(qū)動(dòng)輪的驅(qū)動(dòng)電機(jī)的選擇就顯得十分重要。由于小車要實(shí)現(xiàn)對(duì)路徑的準(zhǔn)確定位和精確測(cè)量,我們綜合考慮了一下兩種方案:方案1;采用步進(jìn)電機(jī)作為該系統(tǒng)的驅(qū)動(dòng)電機(jī)。由于其轉(zhuǎn)過(guò)的角度可以精確地定位,可以實(shí)現(xiàn)小車前進(jìn)路程和位置的精確確定位。方案2:采用直流減速電機(jī)。直流減速電機(jī)轉(zhuǎn)動(dòng)力矩大,體積小,重量輕,裝配方便,但是不能做到很好的定位。權(quán)衡利弊,我們選擇了第一方案。小車驅(qū)動(dòng)部份我們選擇用二相六線步進(jìn)電機(jī)。因?yàn)椴竭M(jìn)電機(jī)可以很好地實(shí)現(xiàn)同步和精確控制功能,但是缺點(diǎn)是耗電大,震動(dòng)大。但權(quán)衡利弊,和直流電機(jī)相雙,步進(jìn)電機(jī)驅(qū)動(dòng)力強(qiáng)大,所以我們選擇用步進(jìn)電機(jī)。步進(jìn)電機(jī)作為執(zhí)行元件,是機(jī)電一體化的關(guān)鍵產(chǎn)品之一,廣泛使用在各種自動(dòng)化控制系統(tǒng)中。隨著微電子和計(jì)算機(jī)技術(shù)的發(fā)展,步進(jìn)電機(jī)的需求量和日俱增,在各個(gè)國(guó)民經(jīng)濟(jì)領(lǐng)域都有使用。步進(jìn)電機(jī)是一種將電脈沖轉(zhuǎn)化為角位移的執(zhí)行機(jī)構(gòu)。當(dāng)步進(jìn)驅(qū)動(dòng)器接收到一個(gè)脈沖信號(hào),它就驅(qū)動(dòng)步進(jìn)電機(jī)按設(shè)定的方向轉(zhuǎn)動(dòng)一個(gè)固定的角度(稱為“步距角”),它的旋轉(zhuǎn)是以固定的角度一步一步運(yùn)行的。可以通過(guò)控制脈沖個(gè)數(shù)來(lái)控制角位移量,從而達(dá)到準(zhǔn)確定位的目的;同時(shí)可以通過(guò)控制脈沖頻率來(lái)控制電機(jī)轉(zhuǎn)動(dòng)的速度和加速度,從而達(dá)到調(diào)速的目的。步進(jìn)電機(jī)可以作為一種控制用的特種電機(jī),利用其沒(méi)有積累誤差(精度為100%)的特點(diǎn),廣泛使用于各種開(kāi)環(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度,但噪聲和振動(dòng)都很大。反應(yīng)式步進(jìn)電機(jī)的轉(zhuǎn)子磁路由軟磁材料制成,定子上有多相勵(lì)磁繞組,利用磁導(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ī)的使用最為廣泛,也是本次細(xì)分驅(qū)動(dòng)方案所選用的步進(jìn)電機(jī)。我們的步進(jìn)電機(jī)使用的驅(qū)動(dòng)芯片是lm2003。步進(jìn)電機(jī)驅(qū)動(dòng)芯片LM2003實(shí)物圖LM2003芯片原理圖步進(jìn)電機(jī)實(shí)物圖LM2003LM2003步進(jìn)電機(jī)驅(qū)動(dòng)相圖二相六線步進(jìn)電機(jī)接線圖尋找光源。當(dāng)光敏二極管正對(duì)光源時(shí),電阻變小,經(jīng)過(guò)電壓比較器向單片機(jī)輸入信號(hào)。尋找光源用的光敏對(duì)管,為了防止干擾,用筆筒套上光敏電阻。尋找光源用的光敏對(duì)管,為了防止干擾,用筆筒套上光敏電阻。電路板。我們通過(guò)Proteldxp繪制電路圖后,采用熱轉(zhuǎn)印方法制成PCB雙面板。蜂鳴器和發(fā)光二極管,輸出聲光信號(hào)74hc373蜂鳴器和發(fā)光二極管,輸出聲光信號(hào)74hc373作為光電對(duì)管信號(hào)輸入鎖存器,PO分時(shí)讀取外部鎖存器,實(shí)現(xiàn)單片機(jī)的輸出口和輸入口擴(kuò)展主控電路AT89S52輸出鎖存器74hc573,作為單片機(jī)分時(shí)存出的輸出口。主板穩(wěn)壓電路1602lcd插口主控電路AT89S52輸出鎖存器74hc573,作為單片機(jī)分時(shí)存出的輸出口。主板穩(wěn)壓電路1602lcd插口主電路板實(shí)物圖(正面)主電路板實(shí)物圖(反面)主電路板pcb圖主電路板各部分原理圖如下:6智能小車程序框圖。初始化初始化前進(jìn)前進(jìn)定時(shí)器定時(shí)器T2定時(shí)中斷,中斷子程序輸入光電對(duì)管信號(hào),判斷是否遇到黑色信號(hào)或白色信號(hào)。白鐵白鐵黑鐵黑鐵判斷遇到黑鐵或白鐵或邊界判斷遇到黑鐵或白鐵或邊界尋找左光源,返回尋找左光源,返回A停車區(qū)。尋找右光源尋找右光源,返回B停車區(qū)。否向前對(duì)齊,繼續(xù)掃描否向前對(duì)齊,繼續(xù)掃描是否取完3塊鐵片是否取完3塊鐵片返回停車區(qū),結(jié)束。返回停車區(qū),結(jié)束。智能小車源程序。#include<at89x52.h>unsignedintminute=0;second=0,sum=0;unsignedcharidataminute1=0,second1=0;sum1=0;unsignedcharidatarecordminute1=0,recordsecond1=0,recordsum1=0;unsignedcharidatarecordminute2=0,recordsecond2=0,recordsum2=0;unsignedcharbdatastatus=0;unsignedcharbdatastatus1=0;unsignedcharbdatastatus2=0;unsignedcharbdataprpflagd;unsignedcharbdataprpflage;unsignedintidatatime0=0;unsignedlongintidatatime2=0;unsignedlongintidatatime2_1;unsignedintidatatime2_2;unsignedchardatamotor=0;unsignedcharbdatad=0;unsignedcharbdatae=0;unsignedcharbdatad1=0;unsignedcharbdatae1=0;unsignedcharlightcount=0;unsignedcharv0;unsignedcharvb;sbitprp5_0=d1^6;sbitprp5_1=d1^7;sbitprp1_0=d1^4;sbitprp1_1=d1^5;sbitprp6_0=d1^2;sbitprp6_1=d1^3;sbitprp2_0=d1^0;sbitprp2_1=d1^1;sbitprp7_0=e1^6;sbitprp7_1=e1^7;sbitprp3_0=e1^4;sbitprp3_1=e1^5;sbitprp8_0=e1^2;sbitprp8_1=e1^3;sbitprp4_0=e1^0;sbitprp4_1=e1^1;sbitprp5_000=prpflagd^6;sbitprp5_001=prpflagd^7;sbitprp1_000=prpflagd^4;sbitprp1_001=prpflagd^5;sbitprp6_000=prpflagd^2;sbitprp6_001=prpflagd^3;sbitprp2_000=prpflagd^0;sbitprp2_001=prpflagd^1;sbitprp7_000=prpflage^6;sbitprp7_001=prpflage^7;sbitprp3_000=prpflage^4;sbitprp3_001=prpflage^5;sbitprp8_000=prpflage^2;sbitprp8_001=prpflage^3;sbitprp4_000=prpflage^0;sbitprp4_001=prpflage^1;sbitprp5_00=d^6;sbitprp5_01=d^7;sbitprp1_00=d^4;sbitprp1_01=d^5;sbitprp6_00=d^2;sbitprp6_01=d^3;sbitprp2_00=d^0;sbitprp2_01=d^1;sbitprp7_00=e^6;sbitprp7_01=e^7;sbitprp3_00=e^4;sbitprp3_01=e^5;sbitprp8_00=e^2;sbitprp8_01=e^3;sbitprp4_00=e^0;sbitprp4_01=e^1;sbitforward=status^0;sbitbackward=status^1;sbitturnleft=status^3;sbitturnright=status^2;sbitrightforward=status^5;sbitrightbackward=status^4;sbitleftforward=status^6;sbitleftbackward=status^7;sbitflag=status1^5;sbitwhiteiron=status1^6;sbitblackiron=status2^0;sbitsearchiron=status1^0;sbitsearchrightlight=status1^1;sbitseachleftlight=status1^2;unsignedcharinterfere;unsignedcharuninterfere;sbitrightorleft=status1^4;sbitunflag=status2^3;sbitfoundblack=status2^4;sbitfoundwhite=status2^5;sbitfoundboundary=status2^6;unsignedcharwhiteironcount=0;unsignedcharblackironcount=0;unsignedcharironcount=0;voidtimer0initializtion();voidtimer2initializtion();voidturnright90degree();voidturnleft90degree();voidputdown();voidgoforwardaccelerat();voidgobackwardaccelerat();voidputup();voidfoundblackiron();voidfoundwhiteiron();voidturnright180degree();voidbackwardalign();voidforwardalign();voidestimate();voidboundaryturnright90degree();voidboundaryturnright180degree();voidboundaryturnleft180degree();voidsearchlightblackiron();voidoneturnleft80degree();voidoneturnright80degree();voidoneturnright180degree();voidoneturnleft80degree();voidsearchlightwhiteiron();voidsearchlightwhiteiron();voidscan();voidmain(){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();}else{putdown();searchlightblackiron();}scan();estimate();if(foundwhite==1){putdown();searchlightwhiteiron();}else{putdown();searchlightblackiron();}scan();estimate();if(foundwhite==1){putdown();searchlightwhiteiron();}else{putdown();searchlightblackiron();}scan();estimate();if(foundwhite==1){putdown();searchlightwhiteiron();}else{putdown();searchlightblackiron();}gotoend0200;}else{if(foundblack==1){putdown();searchlightblackiron();scan();estimate();if(foundwhite==1){putdown();searchlightwhiteiron();}else{putdown();searchlightblackiron();}scan();estimate();if(foundwhite==1){putdown();searchlightwhiteiron();}else{putdown();searchlightblackiron();}scan();estimate();if(foundwhite==1){putdown();searchlightwhiteiron();}else{putdown();searchlightblackiron();}gotoend0200;}else{if(foundwhite==1){putdown();searchlightwhiteiron();scan();estimate();if(foundwhite==1){putdown();searchlightwhiteiron();}else{putdown();searchlightblackiron();}scan();estimate();if(foundwhite==1){putdown();searchlightwhiteiron();}else{putdown();searchlightblackiron();}scan();estimate();if(foundwhite==1){putdown();searchlightwhiteiron();}else{putdown();searchlightblackiron();}}}}end0200:while(1);}voidgoforwardaccelerat(){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;}voidgobackwardaccelerat(){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;}voidscan(){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;}else{rightorleft=1;boundaryturnright180degree();time2=0;while(time2<=8);status=0;}}}}voidsearchlightblackiron(){unsignedlongintlightdalign;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)gotob0173; 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)gotob0294;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();}elsegotob0621;}else{time2=0;while(time2<=8);turnleft=1;time2=0;while(time2<=lightdalign);status=0;forwardalign();boundaryturnright90degree();}}voidsearchlightwhiteiron(){unsignedlongintlightdalign;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)gotob0374; 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)gotob0410;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();}elsegotob0431;}else{time2=0;while(time2<=8);turnright=1;time2=0;while(time2<=lightdalign);status=0;forwardalign();boundaryturnright90degree();}}voidboundaryturnright90degree(){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);}voidoneturnright80degree(){status=0;vb=5;leftforward=1;time2=0;while(time2<=215);status=0;time2=0;while(time2<=8);}voidoneturnleft180degree(){status=0;vb=5;rightforward=1;time2=0;while(time2<=505);status=0;time2=0;while(time2<=8);}voidoneturnright180degree(){status=0;vb=5;leftforward=1;time2=0;while(time2<=505);status=0;time2=0;while(time2<=8);}voidoneturnleft80degree(){status=0;vb=5;rightforward=1;time2=0;while(time2<=225);status=0;time2=0;while(time2<=8);}voidboundaryturnleft180degree(){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);}voidboundaryturnright180degree(){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);}voidforwardalign(){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);}else{rightforward=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);}else{leftforward=1;while(prp1_000==0);}}status=0;time2=0;while(time2<=18);}voidbackwardalign(){unsignedcharbackwardaligncount=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);}else{rightbackward=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);}else{leftbackward=1;while(prp6_000==0);}}status=0;time2=0;while(time2<=18);if(backwardaligncount<=3)gotob0353;status=0;}voidturnleft90degree(){vb=4;status=0;turnleft=1;time2=0;while(time2<=110);status=0;time2=0;while(time2<=10);}voidturnright90degree(){vb=4;status=0;turnright=1;time2=0;while(time2<=115);status=0;time2=0;while(time2<=10);}voidturnright180degree(){vb=4;status=0;turnright=1;time2=0;while(time2<=230);turnright=0;time2=0;while(time2<=15);vb=3;}voidputup(){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;}voidputdown(){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);}voidestimate(){unsignedcharbj1=0;unsignedcharbj2=0;unsignedcharbj3=0;unsignedcharbj4=0;unsignedcharbj5=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;}else{if(bj3==1){foundwhite=1;WR=0;time2=0;while(time2<=18);WR=1;}else{foundblack=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);}}}voidtimer0initializtion(){TMOD=0X01;TH0=0xd8;TL0=0xef;EA=1;ET0=1;PT0=0;TR0=1;}voidtimer2initializtion()//50MS{ET2=1;TCLK=0;RCLK=0;CP_RL2=0;T2MOD=0x0;C_T2=0;RCAP2H=0x3c;RCAP2L=0xb0;PT2=1;TR2=1;}voidT2interrupt()interrupt5{unsignedcharidatai;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;}voidtO()interrupt1//V=9cm/sinterrupttime=13ms{TH0=0xcd;TL0=0x38;time0++;v0++;P2=0x9c;if(status==0x01)//V=9cm/s{if(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;elsemotor=0x18;}}}}}if(status==0x02)//V=9cm/s{if(v0>=vb){v0=0;if(motor==0x81)motor=0x24;else{if(motor==0x24)motor=0x42;else{

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論