【正文】
........................... 39 圖 設(shè)置配置請求處理程序流程圖 ................................................................................... 40 圖 獲得配置請求處理程序流程圖 ................................................................................... 41 圖 讀取 A/D 轉(zhuǎn)換數(shù)據(jù)程序流程圖 .................................................................................. 43 圖 數(shù)據(jù)發(fā)送程序流程圖 ................................................................................................. 44 圖 WDM 驅(qū)動程序和設(shè)備對象的層次結(jié)構(gòu) .................................................................. 45 圖 USBDI 與 USB 驅(qū)動程序棧 ....................................................................................... 46 圖 找到新硬件 (未知 USB 設(shè)備 ) ..................................................................................... 49 圖 指定 INF 安裝文件的保存路徑 ................................................................................. 49 圖 驅(qū)動程序安裝完成 ..................................................................................................... 50 圖 找到 LJSB 設(shè)備 .......................................................................................................... 50 圖 數(shù)據(jù)采集界面 ............................................................................................................. 52 李彥君: 基于 USB 接口的數(shù)據(jù)采集器設(shè)計 4 表格清單 表 USB 標準請求類型 ......................................................................................................... 8 表 標準 USB 描述符數(shù)值 ................................................................................................... 9 表 端點配置和 USB 寄存器對應(yīng)關(guān)系 ............................................................................. 17 表 USB 中斷優(yōu)先級設(shè)置 ................................................................................................... 19 表 地址碼與輸入通道對應(yīng)關(guān)系 ....................................................................................... 21 表 引腳說明 ........................................................................................................ 23 表 典型分頻值設(shè)置 ........................................................................................................... 25 表 設(shè)備描述符格式 ........................................................................................................... 29 表 配置描述符格式 ........................................................................................................... 30 表 接口描述符格式 ........................................................................................................... 30 表 端點描述符格式 ........................................................................................................... 30 表 PLLCON 寄存器( PLL 控制寄存器,地址 A3H) ................................................... 33 表 PLLDIV寄存器( PLL 分頻寄存器,地址 A4H) .................................................... 33 安徽工程大學(xué)本科生畢業(yè)論文 1 引 言 隨著計算機技術(shù)的迅速發(fā)展對外部總線速度的要求越來越高。實踐證明,本設(shè)計已初步取得成功,可以實現(xiàn) USB數(shù)據(jù)采集功能。 PC 機上的應(yīng)用程序利用 VC++開發(fā),使用 MFC 設(shè)計了 PC 機上的 USB 數(shù)據(jù)采集界面,可實現(xiàn)采 集數(shù)據(jù)的波形圖顯示功能。 本設(shè)計的主要工作難點是軟件的設(shè)計,包括固件程序、 USB 驅(qū)動程序和應(yīng)用程序的設(shè)計三部分。 本文針對高速數(shù)據(jù)采集器的需要,設(shè)計了基于 USB 的數(shù)據(jù)采集器。安徽工程大學(xué)本科生畢業(yè)論文 I 基于 USB 接口的數(shù)據(jù)采集器設(shè)計 摘 要 隨著現(xiàn)代工業(yè)領(lǐng)域?qū)?shù)據(jù)采集的要求越來越高,傳統(tǒng)的以采用數(shù)據(jù)采集卡為主的方法由于傳輸速度慢、安裝麻煩、抗干擾能力弱等諸多問題已難以適應(yīng)如今數(shù)據(jù)采集的要求。通用串行總線 USB 具有速度快、支持熱插拔及傳輸線少等優(yōu)點,因此將 USB 應(yīng)用于數(shù)據(jù)采集可以很好的解決傳統(tǒng)數(shù)據(jù)采集的不足,具有廣泛的應(yīng)用價值。設(shè)計工作包括硬件設(shè)計和軟件設(shè)計兩部分,硬件部分本系統(tǒng)選用了 ATMEL 公司的單片機 AT89C5131 作為微控制器,負 責接收由 A/D轉(zhuǎn)換得到的數(shù)字量數(shù)據(jù),并通過其內(nèi)置的 USB 控制器實現(xiàn)單片機和 PC 機之間的 USB 數(shù)據(jù)通信。其中,固件程序利用 Keil C 軟件開發(fā),而 USB 驅(qū)動程序則通過 DriverWorks自動生成并適當修改而成;通過固件程序和 USB 驅(qū)動程序的設(shè)計使得單片機可作為 USB設(shè)備被 PC 機識別,從而可以將采集的數(shù)據(jù)通過 USB 數(shù)據(jù)線傳輸給 PC 機。 本文最后通過對采集器的測試,在設(shè)計的數(shù)據(jù)采集界面上顯示出了輸入隨機信號的波形圖。 關(guān)鍵詞 :數(shù)據(jù)采集 USB 單片 機固件 李彥君: 基于 USB 接口的數(shù)據(jù)采集器設(shè)計 II Abstract As the demand to data acquisition is more and more high in modern industry field, the traditional method which mainly makes use of data acquisition card has not adapted to the high requirement of modern data acquisition because of the low transmission speed、incovenient installation、 weak ability of antijamming and other problems. USB(Universal Serial Bus) has many advantages, such as high transmission speed、 sustaining hot plug and few transmission lines. So the application of USB in data acquisition can be the solution of the deficiency of traditional data acquisition, and it will has widely application value. Aiming to the need of high speed data acquisition, we design a data acquisition based on USB in this paper. The design work of this system consists of hardware design and software hardware design, the AT89C5131 MCU of ATMEL pany is apllied as microcontrollers to receive digital datas converted from A/D. Meanwhile,the USB controller in the MCU can realize the USB data munication between MCU and PC. The main difficulty in the design work is the software design. The design of firmware program、 USB drive program and user program are included in the software design. The firmware program is developed through the software of Keil C, and the USB diver program is generated automatically by DriverWorks and modified appropriately。通用串行總線(Universal Serial Bus,即 USB 總線 )憑借其即插即用、熱插拔以及較高的傳輸速率等優(yōu)點,成為 PC 機與外設(shè)連接的普遍標準。迄今為止,常用的 USB 總線標準有 1998 年發(fā)布的 版本和 2020 年發(fā)布的 版本。在實際應(yīng)用中,通常會遇到一些突發(fā)信號,需要對其進行高 速采集,對數(shù)據(jù)進行高速傳輸,所以 USB2. 0 標準自然成為首選。設(shè)計工作包括硬件設(shè)計和軟件設(shè)計兩部分,硬件部分本系統(tǒng)選用了 ATMEL 公司的單片機 AT89C5131 作為微控制器,負責接收由 A/D轉(zhuǎn)換得到的數(shù)字量數(shù)據(jù),并通過其內(nèi)置的 USB 控制器實現(xiàn)單片機和 PC 機之間的 USB 數(shù)據(jù)通信 。有較快的處理速度和較大的存儲容量 ,有在系統(tǒng)可編程的功能 ,是 USB 接口設(shè)計的理想選擇。隨著科技的發(fā)展特別是計算機技術(shù)的逐漸成熟,數(shù)據(jù)采集器的應(yīng)用已經(jīng)非常廣泛,同時對于數(shù)據(jù)采集的要求也越來越高,特別是在一些高實時性要求(如動態(tài)圖像數(shù)據(jù)實時傳輸)的場合,往往需要進行高速數(shù)據(jù)采集才能保證數(shù)據(jù)傳輸?shù)臏蚀_性。其中常用的是安裝數(shù)據(jù)采集板卡的方法,其缺點在于:安裝麻煩,每次都需要關(guān)機后打開機箱 才能插入板卡;受到計算機插槽數(shù)量和地址、中斷資源的限制,不能外接很多設(shè)備;機箱環(huán)境的干擾可能導(dǎo)致通訊過程中產(chǎn)生錯誤。 USB(通用串行總線, Universal Serial Bus)近年來開始在計算機外設(shè)中得到普及,并逐漸成為計算機標準外設(shè),它的出現(xiàn)使傳統(tǒng)數(shù)據(jù)采集的問題可以得到很好的解決。 USB 設(shè)備在 PC 領(lǐng)域的應(yīng)用目前已經(jīng)非常普遍,如 USB 數(shù)碼照相機、 USB 攝像頭、 USB 打印機等;而考慮到 USB 的各種優(yōu)勢,基于 USB 總線的數(shù)據(jù)采集器也正逐漸成為工控領(lǐng)域的應(yīng)用熱點。 課題背景 目前市場上雖然已經(jīng)有許多針對不同應(yīng)用場合的 USB 數(shù)據(jù)采集