【正文】
............. 18 參 考 文 獻 ......................................................................................................................... 20 蚌埠學院本科畢業(yè)設計(論文) 1 基于 AVR 單片機的 485 通信系統(tǒng)設計 摘 要 : 現(xiàn)在的社會是一個數(shù)字化的時代,多機通信系統(tǒng)的應用已經(jīng)廣泛滲透到人們生活的方方面面,在科學研究的軍事技術(shù)領(lǐng)域、文化藝術(shù)領(lǐng)域、工程設計領(lǐng)域都有它的應用。通過通訊方式交換信息、資源共享已經(jīng)成為了一種必然的趨勢。為了使系統(tǒng)中的多個計算機之間的數(shù)據(jù)通信都可以實現(xiàn),它們必須根據(jù)實際需要并且按照某種形式的網(wǎng)絡來進行,工程中經(jīng)常用的是使一個完整的主站發(fā)送,然后正確的從多機通信模式接收的信號,同時要防止總線上的信號沖突。本文討論了用 AT mega16 AVR 單片機來控制 RS485 串行接口與主機系統(tǒng)進行數(shù)據(jù)交換 ,ATmega16 為核心芯片,它與 MAX485 轉(zhuǎn)換器連接實現(xiàn)遠距離傳輸,同時 ATmega16 作為主控芯片控制按鍵電路與數(shù)據(jù)顯示電路 ,系統(tǒng)主要由主機控制模塊、通信模塊、數(shù)據(jù)輸入模塊、數(shù)據(jù)顯示模塊和模數(shù)轉(zhuǎn)換模塊五個部分組成,實現(xiàn)了利用 RS485 實現(xiàn)單片機通信,通過鍵盤實現(xiàn)從機的選擇、發(fā)送數(shù)據(jù),從機顯示發(fā)送的數(shù)據(jù)。該系統(tǒng)是一個單片機發(fā)送另一個單片機接收的單向、平衡傳輸標準,具有強抗干擾能力,易于 使用,易于維護,操作簡單等優(yōu)點,在現(xiàn)實生活中也擁有廣泛的應用。 關(guān)鍵字: 多機通信、 RS485 接口、 AVR 單片機 張?zhí)O蘋:基于 AVR 單片機的 485 通信系統(tǒng)設計 2 Design of 485 Communication System based on AVR Microcontroller Abstract: Today39。s society is a digital era, the application of muchmachine munication systems have been widely seeped into the scientific research in all fields , such as: military technology, culture and the arts, engineering and people39。s daily life. By means of munication to exchange information, share resources has bee an inevitable trend. To make the system in data munication between multiple puter are met, they must be posed according to the actual needs some form of work engineering is often used to make a plete master sends and receives signals from the muchmachine munication mode, correct and prevent the signal collision on the bus is guaranteed。 This article discusses the use ATmega16 AVR microcontroller to control RS485 serial interface with the host system for data exchange, ATmega16 core chip, which is connected make remote distance transmission truth and MAX485 converters, while ATmega16 as the main chip circuit control buttons and data display circuit, system is mainly controlled by the host module, munication module, data input module, data display ponent modules, and analogdigital conversion module five parts, we can use the RS485 munication between SCM, realized through the keyboard to select the machine from sending data, the host display sending data. The system is a singlechip microcontroller receiving sending another way, balanced transmission standard, has a strong antijamming capability 、 is easy to use、 easy to maintain、 operate and simple, in real life, also has a wide range of applications. Keywords: muchmachine munication、 RS485 protocol、 AVR microcontroller 蚌埠學院本科畢業(yè)設計(論文) 3 基于 AVR 單片機的 485 通信系統(tǒng)設計 1 引 言 在 一個基于單片機的數(shù)據(jù)采集和實時控制系統(tǒng)的微控制器系統(tǒng)中,通過計算機接口的 RS232 接口與計算機之間命令和數(shù)據(jù)傳送,我們可以檢測和控制生產(chǎn)現(xiàn)場。由于計算機發(fā)送的 RS232的距離很短,不超過 30m,所以如果需要進行遠距離的數(shù)據(jù)傳輸和控制時,這個時候我們就可以選擇使用 MAX485 的接口轉(zhuǎn)換芯片使 RS232 協(xié)議轉(zhuǎn)換為RS485 協(xié)議,進行遠距離傳輸。 RS232 不能在多點通信系統(tǒng)中使用,而只能在通信系統(tǒng)之間的點對點中使用,并且這些限制所有使用 RS232 的系統(tǒng)都必須滿足。 而 RS485 的通信協(xié)議通常是半雙工的、雙向的,該協(xié)議的特別之處在于,允許不止一個驅(qū)動器和接收器同時連接在總線上,其中每個驅(qū)動器都可脫離總線。 張?zhí)O蘋:基于 AVR 單片機的 485 通信系統(tǒng)設計 4 2 系統(tǒng)總體方案確定 設計方案選擇 方案一:基于 AVR 單片機的 485 通信系統(tǒng),使用的電路是:利用端口轉(zhuǎn)發(fā)形式的網(wǎng)絡接口電路并且同時使用總線型的系統(tǒng)網(wǎng)絡拓撲結(jié)構(gòu)等進行單片機通信系統(tǒng)的設計。RS485 構(gòu)成的多機通信系統(tǒng)采用主從配置;主機控制從機,從機不采取從微控制器主動發(fā)送命令或數(shù)據(jù),全部由主機 MCU 控制 。并在多機 系統(tǒng)中,只有一個主機,從機之間的各站不能彼此通信,如果有需要被交換的信息的話,也必須由主機轉(zhuǎn)發(fā)。 方案二:基于單片機的 485 通信系統(tǒng)的設計,我們利用的是單片機的串行通訊端口,以完成兩個終端之間相互通信的功能。 經(jīng)比較:方案一