【正文】
P 0 . 5P 0 . 6P 0 . 7/ E AA L E/ P S E NP 2 . 7P 2 . 6P 2 . 5P 2 . 4P 2 . 3P 2 . 2P 2 . 1P 2 . 01234567891 01 11 21 31 41 51 61 71 81 92 0P 1 . 0P 1 . 1P 1 . 2P 1 . 3P 1 . 4P 1 . 5P 1 . 6P 1 . 7R E S E TP 3 . 0P 3 . 1P 3 . 2P 3 . 3P 3 . 4P 3 . 5P 3 . 6P 3 . 7X T A L 2X T A L 1V s s 對(duì)于單片機(jī)的晶振電 路和復(fù)位電路的設(shè)計(jì)如下圖 7: 13 30pf3 0 p fC1C 2G N D1 1 . 0 5 9 2 mX T A L 1 X T A L 2 晶振電路 2 0 01 k1 0 u f+R S T 復(fù)位電路 循跡 電路 本文采用的 CMOS 攝像頭是一種以 CMOS 感光器件為主的高分辨率、低功耗圖像傳感器,為了減少硬件系統(tǒng)開(kāi)銷(xiāo),選用數(shù)據(jù)量較少的黑白攝像頭也可滿足要求。 循跡模塊采用 CMOS 圖像傳感器作為采集視頻信號(hào)的主控芯片。OV7620 是一款 CMOS 攝像頭器件,是一款彩色 CMOS 型圖像采集集成芯片,提供高性能的單一小體積封裝,該器件分辨率可以達(dá)到 640X480,傳輸速率可以達(dá)到 30 幀。5V 電源供電 ,工作時(shí)功耗 120mW,待機(jī)時(shí)功耗 10μW。 SCCB 是簡(jiǎn)化的 I2C協(xié)議, SIOI 是串行時(shí)鐘輸入線, SIOO 是串行雙向數(shù)據(jù)線,分別相當(dāng)于 I2C 協(xié)議的 SCL 和 SDA。 OV7620 功能寄存器的地址為 0x00~ 0x7C(其中,不少是保留寄存器 )。當(dāng)采用連續(xù)掃描方式時(shí),只使用 VSYNC 和 HSYNC、 PCLK 三個(gè)同步信號(hào),還引入了 HREF 水平參考信號(hào)。若是,則在主程序的循環(huán)體中進(jìn)行數(shù)據(jù)處理;若不是,則使能 HSYNC 對(duì)應(yīng)的中斷,并將 y 置為 O。當(dāng) OV7620 使用 27 MHz的系統(tǒng)時(shí)鐘時(shí),默認(rèn)的 PCLK 的周期為 74 ns。通過(guò)設(shè)置時(shí)鐘頻率控制寄存器,可將 PCLK 的周期設(shè)為 4us 左右。 表 1 ov7620 16 位輸出格式 R C 1 2 3 4 …… 通道 1 …… UV B11 G12 B13 G14 …… Y 2 G21 R22 G23 R24 …… UV B11 G12 B13 G14 …… Y 16 3 G21 R22 G23 R24 …… UV B31 G32 B33 G34 …… Y CMOS 圖像傳感器的工作原理圖如圖 9 所示: 光 敏 單 元 陣 列 行 選 擇模 擬 數(shù) 字 轉(zhuǎn) 換 電 路模 擬 信 號(hào) 處 理 電 路列 選 及 放 大視 頻 時(shí) 序 產(chǎn) 生 電 路 曝 光 、 白 平 衡 等 控 制 I I C 總 線 借 口數(shù) 字 視 頻 輸 出 OV7620 支持一幀圖象讀取模式 , 采用此模式則 OV7620 開(kāi)始 傳輸后 , 以 PCLK 為頻率自動(dòng)傳輸完一幀圖象后停止。當(dāng)給 AGCEN引腳發(fā)送一初始信號(hào)后 ,VSYNC會(huì)產(chǎn)生電平跳變 ,CPLD監(jiān)測(cè) VSYNC 的變化。所以用來(lái)存儲(chǔ)圖像的 RAM 的使能信號(hào) CE,和寫(xiě)信號(hào) WE 及讀信號(hào) RE 以及地址信號(hào) ADDRESS 都是由 CPLD 來(lái)產(chǎn)生。 攝像頭與單片機(jī)相連的管腳如下表 2所示 圖像采集模塊 電源 /地 VSYNC HREF PLCK Y0Y7 單片機(jī) 電源 /地 數(shù)據(jù)線 數(shù)據(jù)線 數(shù)據(jù)線 數(shù)據(jù)線 表 2:管腳連接 攝像頭的工作原理是:按一定的分辨率,以隔行掃描的方式采集圖像上的點(diǎn),當(dāng)掃描到某點(diǎn)時(shí),就通過(guò)圖像傳感器芯片將該點(diǎn)處圖像的灰度轉(zhuǎn)換成與灰度一一對(duì)應(yīng)的電壓值,然后將次電壓值通過(guò)視頻信號(hào)端輸出。然后,跳過(guò)一行后(因?yàn)閿z像頭是隔行掃描),開(kāi)始掃描新的一行,如此下去,直到掃描完該場(chǎng)的視頻信號(hào),接著會(huì)出現(xiàn)一段場(chǎng)消隱區(qū),該區(qū)中有若干個(gè)復(fù)合消隱脈沖,其中有個(gè)遠(yuǎn)寬于(即持續(xù)時(shí)間遠(yuǎn)長(zhǎng)于)其它的消隱脈沖,稱為場(chǎng)同步脈沖,它是掃描換場(chǎng)的標(biāo)志。 圖像信號(hào)的組成如圖 10所示 攝像頭有兩個(gè)重要的指標(biāo):分辨率和有效像素。 邊緣檢測(cè) 電路 在攝像頭采集完視頻信號(hào)后,要圖像進(jìn)行一定的處理,我們采用邊緣檢測(cè)的算法對(duì)圖像進(jìn)行處理。則判定其下的像素點(diǎn)對(duì)應(yīng)的是黑色引導(dǎo)線的上邊緣,以此像點(diǎn)作為該列的特征點(diǎn),記錄下此像素點(diǎn)的縱坐標(biāo)值(即為相應(yīng)的上邊緣坐標(biāo) ),作為該列上目標(biāo)引導(dǎo)線的縱坐標(biāo)。解決單片機(jī) A/D 轉(zhuǎn)換速度慢的問(wèn)題,一種方法是對(duì)單片機(jī)進(jìn)行超頻處理 。 采用兩片 BTS7970 H橋驅(qū)動(dòng)電路,具有強(qiáng)勁的驅(qū)動(dòng)和剎車(chē)效果,有效隔離單片機(jī)與電機(jī)驅(qū)動(dòng),即便出現(xiàn)問(wèn)題,也不會(huì)對(duì)單片機(jī)造成危險(xiǎn)。 PWM 是一種對(duì)模擬信號(hào)電平進(jìn)行數(shù)字編碼的方法,通過(guò)高分辨率計(jì)數(shù)器的使用,方波的占空比被調(diào)制用來(lái)對(duì)一個(gè)具體模擬信號(hào)的電平進(jìn)行編碼。只要帶寬足夠,任何模擬值都可以使用 PWM 進(jìn)行編碼。Ug1=Ug4 為正的時(shí)間長(zhǎng)于 Ug2=Ug3 為正的時(shí)間時(shí) , UAB 的平均值 0,電機(jī)正轉(zhuǎn) UAB 的值越大 ,轉(zhuǎn)速越高 。它接收一定的控制信號(hào),輸出一定的角度,適用于那些需要角度不斷變化并可以保持的控制系統(tǒng)。當(dāng)電機(jī)轉(zhuǎn)速一定時(shí),通過(guò)級(jí)聯(lián)減速齒輪帶動(dòng)電位器旋轉(zhuǎn), 直到電壓差為 0,電機(jī)停止轉(zhuǎn)動(dòng)。 舵機(jī)的控制一般需要一個(gè) 20ms 左右的時(shí)基脈沖,該脈沖的高電平部分一般為 ~ 范圍內(nèi)的角度控制脈沖部分。位置程序后舵機(jī)運(yùn)動(dòng)到 45176。到 45176。) 具體動(dòng)作關(guān)系如下圖 14 所示 : 黑線: GND ;紅線 :VCC ; 白 線 : PWM 信號(hào) 利用信號(hào)脈寬進(jìn)行轉(zhuǎn)向調(diào)節(jié) 調(diào)節(jié)角度為 +60176。測(cè)量出攝像頭能夠檢測(cè)到的黑線位置,并測(cè)量車(chē)距(假設(shè)為 b),測(cè)量車(chē)正中間和黑線的橫向距離(假設(shè)為 a),那么轉(zhuǎn)角的正切就等于 b/a,可以使用這個(gè)方法,把黑線從視野的最左端移動(dòng)到最右端,分別測(cè)量出轉(zhuǎn)角。 24 程 序 開(kāi) 始關(guān) 閉 中 斷變 量 初 始 化設(shè) 置 主 頻P W M 初 始 化I R Q 初 始 化圖 像 數(shù) 組 初 始 化開(kāi) 啟 中 斷開(kāi) 始 循 環(huán)輸 入 捕 捉 初 始 化 OV7620 工作 流程圖 OV7620 工作 流程圖如圖 17 所示。 intelligent vehicles could also enhance transportation services , save lives , and bolster the petitiveness of . industries . However , intelligent vehicles aren’t quite here . Instead , the ponents that make vehicles smarter – new information , safety , and automation technologies – are arriving on the market as piecemeal accessories , offered either as optional equipment by new vehicle manufacturers or as special ponents by aftermarket suppliers . There technologies are being developed and marketed to increase drive safety , performance , and convenience . These individual technologies , however , have yet to being integrated to create a fully intelligent vehicle that works cooperatively with the drive . The automotive industry is already aware of and addressing potential problems associated with the uncoordinated influx of technology . But their progress is hampered by technical and economic obstacles , uncertain consumer interest , and insufficient standards and guidelines . Also , neither original vehicle manufacturers or government regulators ( unless safety problems are clearly proven ) have control over aftermarket products , especially their use in trucks and buses . However , without a “humancentered” design approach for the intelligent vehicle that attempts to integrator and coordinate various technologies , we may not only lose the opportunity to realize the benefits offered by new invehicle technologies , but we could inadvertently degrade safety and performance . Recognizing the importance of smart vehicles and the potential for unintended consequences if human factors are not placed at the center of their design , Dot launched the Intelligent Vehicle Initiative (IVI) in 1997 . This initiative aims to accelerate the development , availability , and use of integrated invehicle systems that help drivers of cars , trucks , and buses operate more safety and effectively . The 1980s television series “Knight Rider “ featured an intelligent vehicle that could leap moderately tall buildings , drive itself at seemingly supersonic speeds , spy 30 on bad guys , and had the diction and personality of an English butler . The car was not only smart , but smartalecky . Although intelligent vehicles in the real world will not be able to fly over standing traffic , they will have formidable capabilities . As envisioned by IVI , smart vehicles will be able to give route directions , sense objects , warn drivers of impending collisions , automatically signal for help in emergencies , keep drivers alert , and may ultimately be able to take over driving . The use of information and puterbased technologies in motor vehicles , however , is not new . Wide scale puterization of motor vehicles began in the 1980s with technologies designed to enh