【正文】
s horizontal field a digital pass must be able to measure this field with lesser influence from other nearby magnetic sources or disturbances.The amount of disturbance depends on the material content of the platform and connectors as well as ferrous objects moving nearby. When a ferrous object is placed in a uniform magnetic field it will exert an influence. This object could be a steel bolt or bracket near the pass or an iron door latch close to the pass. The net result is a characteristic distortion, or anomaly to the earth’s magnetic field that is unique to the shape of the object. Magnetic distortions can be categorized as two types—hard iron and soft iron effects. Hard iron distortions arise from permanent magnets and magnetized iron or steel on the pass platform. These distortions will remain constant and in a fixed location relative to the pass for all heading orientations. Hard iron effects add a constant magnitude field ponent along each axes of the sensor output. To pensate for hard iron distortion is usually done by rotating the pass and platform (your car) in a circle and measure enough points on the circle to determine this offset. Once found, the (X,Y) offset can be stored in memory and subtracted from every reading. The net result will be to eliminate the hard iron disturbance from the heading calculation.The soft iron distortion arises from the interaction of the earth’s magnetic field and any magnetically soft material surrounding the pass. Like the hard iron materials, the soft metals also distort the earth’s magnetic field lines. The difference is the。 for example, disturbances generated by the motion of magnetic metals, or unpredictable electrical current in a nearby power lines. Magnetic shielding can be used for large field disturbances from motors or audio speakers. The best way to reduce disturbances is distance. Also, never enclose the pass in a magnetically shielded metallic housing.Compass Tilt ErrorsHeading errors due to a tilt depend somewhat on geographic location. At the equator, tilt errors are less critical since the earth39。 //一定時(shí)間的延時(shí) } //end while}附錄2英文文獻(xiàn):How Does a Digital Compass Work? An electronic pass such as the Wayfinder uses a patented magnetic sensor technology that was first developed by PNI, Inc. for the . military. This technology is called magnetoinductive and is the largest advancement in pass technology since the fulxgate was invented 60 years ago. The magnetoinductive technology is able to electronically sense the difference in the earth39。 //按鍵檢測(cè) display()。 ReadKey()。 //延時(shí) read_rtc()。 //接收數(shù)據(jù)的累計(jì)值 SeriPushSend(0X31)。 //初始化口// set_rtc()。 init()。 //將使能端置0以完成高脈沖}4. 主程序://************主程序************void main(){ delay(50)。 //給使能端一高電平,將數(shù)據(jù)送入液晶 delay(5)。 //將要寫的數(shù)據(jù)送到數(shù)據(jù)總線上 delay(5)。 //選擇寫數(shù)據(jù)模式/* lcden=0。 lcden=0。 lcden=1。 //液晶使能端賦初值 */ P0=。 //校驗(yàn)和} }3. LCD1602液晶模塊子程序//**********寫命令至LCD***********************void write_(uchar ){ lcdrs=0。amp。 }//*********數(shù)據(jù)校驗(yàn)****************void Chare(){ delay(5)。 while(!TI)。 //開(kāi)串口中斷 EA=1。 ET0=1。 //串口中斷設(shè)為高優(yōu)先級(jí)別 TR0=1。 SCON=0x50。 TH1=0xfd。i++) { time_date[i]=read_ds1302(read_add[i])。 for(i=0。 return (value)。 sck=1。 sck=0。 } rst=0。 if(io) value=value|0x80。i++) { value=value1。 //寫入讀時(shí)間命令 for(i=0。 _nop_()。 _nop_()。 _nop_()。 io=1。 sck=1。 _nop_()。 //寫入寫時(shí)間命令 write_ds1302_byte(dat)。 _nop_()。 _nop_()。 _nop_()。 sck=1。0x01。i++) { sck=0。 for(i=0。 感謝我的父母,焉得諼草,言樹(shù)之背,養(yǎng)育之恩,無(wú)以回報(bào),你們永遠(yuǎn)健康快樂(lè)是我最大的心愿。愿離開(kāi)寢室的我們開(kāi)開(kāi)心心。在此對(duì)學(xué)校表示感謝,祝愿學(xué)校的明天更加美好!感謝我的室友們,從遙遠(yuǎn)的家來(lái)到同一個(gè)城市里。四年來(lái)的學(xué)習(xí)不但使我學(xué)到了知識(shí),更讓我學(xué)會(huì)了如何與人相處。對(duì)姜老師的感激之情是無(wú)法用言語(yǔ)表達(dá)的。姜老師多次詢問(wèn)研究進(jìn)程,并為我指點(diǎn)迷津,幫助我開(kāi)拓研究思路,精心點(diǎn)撥、熱忱鼓勵(lì)。因?yàn)閭€(gè)人在知識(shí)面和能力方面還有限,再加上條件的限制,電子指南針的采樣精度和抗干擾能力等各項(xiàng)技術(shù)指標(biāo)的提高、諸多功能的完善還需要進(jìn)一步的研究和開(kāi)發(fā),此外在完成基本功能的基礎(chǔ)上,還需要努力提高軟件的效率、硬件系統(tǒng)的穩(wěn)定性、進(jìn)一步降低系統(tǒng)功耗等。該指南針系統(tǒng)用于方位指示實(shí)測(cè)精度可以達(dá)到1176。圖56 LCD1602工作流程圖37結(jié) 論本次畢業(yè)設(shè)計(jì)的電子指南針系統(tǒng)包含了磁場(chǎng)傳感器、微控制器、顯示部件、輸入部件和實(shí)時(shí)時(shí)鐘等部分,微控制器通過(guò)對(duì)磁場(chǎng)傳感器配套的ASIC進(jìn)行讀取獲得當(dāng)前方向地磁場(chǎng)的強(qiáng)度,通過(guò)一定的運(yùn)算后由直觀的液晶界面顯示出來(lái),并可通過(guò)微控制器的串口和獨(dú)立按鍵進(jìn)行數(shù)據(jù)的交互。LCD1602有兩行每行16個(gè)單元共32個(gè)單元的顯示單位。本次設(shè)計(jì)采用了LCD1602點(diǎn)陣的液晶模塊。當(dāng)檢測(cè)到按鍵釋放后,也要給5ms~10ms的延時(shí),待后沿抖動(dòng)消失后才能轉(zhuǎn)入該鍵的處理程序圖55 按鍵檢測(cè)流程圖 液晶模塊驅(qū)動(dòng)液晶顯示驅(qū)動(dòng)處于系統(tǒng)的最后端,屬于人機(jī)交互界面。當(dāng)檢測(cè)到按鍵釋放后,也要給5ms~10ms的延時(shí),待后沿抖動(dòng)消失后才能轉(zhuǎn)入該鍵的處理程序。圖54指南針?lè)较蛴?jì)算示意圖 鍵盤驅(qū)動(dòng)系統(tǒng)中將按鍵電路中各個(gè)獨(dú)立按鍵分別與單片機(jī)的P1P1P1P1PP21引腳進(jìn)行連接,此按鍵是低電平有效,當(dāng)有鍵按下時(shí),與按鍵相連接的單片機(jī)引腳檢測(cè)到這個(gè)信號(hào),然后進(jìn)行相應(yīng)的處理后再輸出。校正時(shí)主要調(diào)整的系數(shù)就是本地的磁偏角。保持模塊水平,緩慢旋轉(zhuǎn)1周(旋轉(zhuǎn)1周時(shí)間大約1分鐘)。均勻轉(zhuǎn)動(dòng)指南針模塊得到的地磁場(chǎng)強(qiáng)度分布,未經(jīng)處理的地磁場(chǎng)強(qiáng)度在不同方向上的分布是不同的,經(jīng)過(guò)歸一化后,可以很好的將其歸一化為圓,使得在各個(gè)方向上的磁場(chǎng)強(qiáng)度均勻,這樣既可以方便進(jìn)行角度計(jì)算又可以提高測(cè)量精度。程序的流程如圖53所示。模塊采用SPI接口與MCU進(jìn)行數(shù)據(jù)交換。整個(gè)驅(qū)動(dòng)流程如圖52所示。圖51 主監(jiān)控程序流程圖 實(shí)時(shí)時(shí)鐘驅(qū)動(dòng)實(shí)時(shí)時(shí)鐘為整個(gè)系統(tǒng)的運(yùn)行提供實(shí)時(shí)數(shù)據(jù)。系統(tǒng)初始化完成時(shí)對(duì)指南針模塊進(jìn)行讀取,此時(shí)指南針模塊將讀取RXD端口的命令進(jìn)行方向測(cè)量,其后將得到的數(shù)據(jù)發(fā)送至微單片機(jī),單片機(jī)根據(jù)得到的數(shù)據(jù)驅(qū)動(dòng)LCD進(jìn)行相應(yīng)的顯示,隨后單片機(jī)將對(duì)系統(tǒng)鍵盤端口進(jìn)行掃描,并根據(jù)掃描得到的鍵值進(jìn)行相應(yīng)的處理。整個(gè)監(jiān)控程序主要由指南針模塊驅(qū)動(dòng)、液晶驅(qū)動(dòng)、實(shí)時(shí)時(shí)鐘驅(qū)動(dòng)和串口驅(qū)動(dòng)組成。系統(tǒng)的總體電路采用Protel99SE設(shè)計(jì),如圖410所示。圖49 獨(dú)立按鍵電路圖以上是系統(tǒng)各個(gè)硬件部分的闡述,以下是整個(gè)系統(tǒng)的總電路。電路的中的幾個(gè)電阻屬于上拉電阻,保證在沒(méi)有輸入的情況下端口電平穩(wěn)定為高,同時(shí)也可以達(dá)到省電的目的。圖48 LCD1602讀寫時(shí)序圖 系統(tǒng)輸入電路系統(tǒng)采用了6鍵輸入以實(shí)現(xiàn)系統(tǒng)功能的設(shè)定,如系統(tǒng)時(shí)間的調(diào)整、磁場(chǎng)的校準(zhǔn)和磁偏角的補(bǔ)償?shù)?。微控制器只需要按照KS0066給定的指令格式進(jìn)行相應(yīng)的操作即可。模塊內(nèi)部原理如圖47所示。圖46 時(shí)鐘讀寫時(shí)序圖 液晶顯示電路本次設(shè)計(jì)采用了單色液晶顯示屏(LCD)作為系統(tǒng)的顯示界面,具體的型號(hào)為L(zhǎng)CD1602,該LCD采用了KS0066控制芯片作為顯示控制核心。在開(kāi)始8個(gè)時(shí)鐘周期把命令字裝入移位寄存器之后,另外的時(shí)鐘在讀操作時(shí)輸出數(shù)據(jù),在寫操作時(shí)輸入數(shù)據(jù)。數(shù)據(jù)在SCLK的上升沿串行輸入。圖45 時(shí)鐘電路圖DS1302是一款穿行時(shí)鐘芯片,主要由移位寄存器、控制邏輯、振蕩器、實(shí)時(shí)時(shí)鐘以及RAM組成。采用三線接口與CPU進(jìn)行同步通信,并可采用突發(fā)方式一次傳送多個(gè)字節(jié)的時(shí)鐘信號(hào)或RAM數(shù)據(jù)。ASCII碼 換行Byte20x30~0x33角度百位ASCII碼 0~3Byte30x30~0x39角度十位ASCII碼 0