基于USB总线的家庭监护数据采集系统的设计
详细信息    本馆镜像全文|  推荐本文 |  |   获取CNKI官网全文
摘要
本文提出了一种基于PC机上Microsoft Windows98/2000平台的USB总线接口方式家庭监护数据采集系统的设计与实现,其目的主要是将其应用在家庭监护系统中,使家庭监护系统更易于操作,经济实用。通用串行总线(USB)作为一种崭新的微机总线接口规范,其特点使其非常适合作为主机与医学仪器之间的通讯接口。本系统充分利用了现代PC机所具备的通用串行总线的数据传输功能,可与带USB接口的各种台式计算机,笔记本机连接构成高性能的数据采集测量设备,且具有USB设备体积小巧,连接方便,无需外接电源,即插即用,支持热插拔(PNP),动态加载驱动程序,方便使用等特有优点,在主机和家庭监护系统之间,可以实现简单、快捷、可靠的连接和通讯。所以基于USB总线的数据采集方式非常适用于家庭监护系统。
     本系统包括硬件设计、FirmWare(固件)程序设计、基于Windows98/2000驱动程序模型(WDM)的设备驱动程序设计。最多支持8个通道的数据采集,采样频率可调(20~1KHz),采样精度为8bit。
     本数据采集系统的硬件构成主要有三部分。第一部分为A/D转换芯片,我们采用八位逐次逼近式A/D转换器ADC0809。它包括8通道多路转换器、8位模/数转换器和与微处理器兼容的控制逻辑;第二部分为数据缓冲存储器,采用8K×9先进先出(FIFO)缓冲存储器IDT7205,其读和写操作可同时进行,可实现数据块的连续采集;第三部分为USB接口芯片,主要负责与主机间的USB通讯。接口芯片采用PHILIPS公司的并行USB接口芯片PDIUSBD12,符合USB1.1版本规范,支持12Mbps全速传输,支持四种传输方式,提供3个端点(Endpoint),除端点0外,每个端点的传输类型、传输方向均可自由配置。另外,它还具有320字节
    
    FIFO数据缓冲区。设备的工作原理是:8路模拟输人信号由
    89C52控制将其中的某一路信号接人 ADC0809并启动 A/D,A/D
    转换的结果自动写人 FIFO存储器 ID’17205,89C52将数据从 FIFO
    存储器中读出并通过PDIUSBD12送到主机。
     Firmware固件程序设计采用CSI语言编写。89C52单片机
    的固件程序主要完成两个方面的工作:一是控制A/D以要求的采
    样频率进行采样,并控制采样通道的选择;二是控制仍B接口芯
    片与主机间进行通讯。对于89C52单片机控制A/D采样的工作,
    我们采用定时器TI定时中断的方法,将定时器TI设置为模式2,
    其中断优先级为高。每次定时中断产生时,89 C52将采样通道更
    新,并触发A/D开始采样。对于 89C52单片机控制 USB接口芯
    片与主机间的通讯的固件程序设计成完全的中断驱动方式。当
    CPU处理前台任务时,USB的传输可在后台运行,这就确保了最
    佳的传输速率和更好的软件结构,同时简化了编程和调试。后台
    中断服务程序(IS)和前台主循环之间的数据交换通过事件标志
    和数据缓冲区来实现。由于这种结构,主程序不关心数据是来自
    USB、串口还是并口,它只检查循环缓冲区内需要处理的新数据,
    这样主循环程序专注于数据的处理,而ISR能够以最大可能的速
    度进行数据的传输。控制端点在数据包处理时采用了同样的概
    念,ISR接收和保存数据缓冲区中的控制传输并设置相应的标志
    寄存器,主循环向协议处理程序发出请求,由于所有的标准设备。
    接口和厂商请求都是在协议处理程序中进行处理,ISR得以保持
    它的效率。而且一旦增加新的请求,只需要在协议层进行修改。
     设备驱动程序的设计采用 WDM模型(Windows Driver Mod-
    el人 WDM是微软公司为当前主流操作系统 Win98和 Win 2000
    的驱动程序设计的一种构架。WDM采用分层驱动程序模型,对
    于USB设备来说,可分为USB总线驱动程序(USBD)和USB功能
    驱动程序。USB总线驱动程序由操作系统提供,他位于USB功能
     ·2·
    
    驱动程序的下面,负责与实际的硬件打交道,实现烦琐的低层通
    讯。USB功能驱动程序由设备开发者编写,位于USB总线驱动程
    序的上面,不与实际的硬件打交道,而是通过向USB总线驱动程
    序发送包含URB(USB Request Block,USB请求块)的IRP(I/O
    ReqUest Packet人O请求包X来实现对 USB设备信息的发送和接
    收。当应用程序想对设备进行I/O操作时,它便使用Wi叫OOS
    API函数对hN32子系统进行WIN32调用。此调用由I/O管理
    器将此请求构造成一个合适的Ign并把它传递给USB功能驱动
    程序。USB功能驱动程序接收到这个IRP后,根据Ign中包含的
    具体操作代码,构造相应的URB并把它放到一个新的IRP中,然
    后把此 IRP传递到 USB总线驱动程序,USB总线驱动程序根据
    Iny中所包含的URB执行相应的操作,并把操作结果通过IRP返
    还给USB功能驱动程序。USB功能驱动程序接收到此IRP后,将
    操作结果通过IRP返还给I/O管理器,最后I/O管理器将此Igy
    中操作结果返还给应用程序,至此应用程序对USB设备的一次l/
    O操作完成。驱动程序的入口函数是DriverEnny(厂所有对各种
    IRP的处理例程都在此人口函数中做出定义。本系统的驱动程序
    采用Numega公司的DriverstudioZ.5开发工具通用内核模式的开
    发包 Driverworks 和Mc。soft,公司的 2
The article introduces one home monitor data acquisition system, designed over USB bus interface based on Microsoft Windows98/2000 platform of personal computer. The main goal makes home monitor system more economical, practical and easy to operate. As a kind of novel PC bus interface specification, Universal Serial Bus is perfectly adapted to become communication interface in the middle of host and medical instrument. This system takes full advantage of Universal Serial Bus data - transmission capability. It can connect with all kind of desk PC, pocket PC and constitute high performance data acquisition measure instrument. This instrument has advantages of elaborated, easy to link, none of external power, plus and play, PnP, dynamic loading driver of USB instrument. Link and communication of host and household ward system become simple, fast and reliable. Data acquisition mode based on USB is very suited as home monitor system.
    This system includes hardware design, Firm Ware program design and device driver program design based on WDM. It can most support 8 channels data acquisition. Sampling frequency is 20 ~ 1 KHz per one channel and sampling precision is 8 bits.
    The hardware of this Data acquisition system has three parts. Fist part, A/D conversi6n chip (8 - bit A/D converter - ADC0809 uses successive approximation as conversion technique) has 8 - channel multiplexer and microprocessor compatible control logic; Second part, data buffers is IDT7205 ( 8K x 9) , which is dual - port buffers with internal pointers that load and empty data on first - in/first - out basis. Data is toggled in and out of the device through the Write ( W) and Read (R) pins. The Write -operating and Read -operating is inde-
    
    
    pendent each other. IDT7205 enable the data - hulk continually acquired. Third part, USB interface chip is PDIUSBD12( parallel interface) manufactured by PHILIPS. Its mostly responsible for communication between data acquisition system and host. PDIUSBD12 follows Universal Serial Bus specification revision 1.1, supporting 12Mbps full speed transfer and four kinds of transfer types. It has three end-points. Except for endpoint 0, every endpoint can be configured freely transfer type and transfer direction. In addition, it integrates 320 bytes of multi - configuration FIFO memory and offers two sets of FIFO data buffers for every endpoint. The theory of operation; under the control of 89C52(MCU) , 8 -channel multiplexer in ADC0809 switch one channel. The results of A/D conversion will be automatically written into IDT7205. The 89C52 will read data from IDT7205 and send it to host through PDIUSBD12.
    Firm Ware program is designed with C51 programming language. The firmware mainly performs two tasks. One is to control A/D sampling with desired sampling speed, the other is to control communication between PDIUSBD12 and host. For the first task, we use the timer Tl to time interruption. Set Tl to mode 2 and interrupt priority level to high. When the timing interruption happens, the 89C52 will update the sampling channel arid trigger ADC0809 sampling. For the second work, the firmware of PDIUSBD12 is designed to be fully interrupt - driven. While CPU is doing its foreground task, the USB transfer is being handled in the background. This assures best transfer rate and better software structure and also simplifies programming and debugging. The data exchange between the background ISR (Interrupt Service Routine) and the foreground Main Loop is achieved by event flags and data buffers. With this structure, the Main Loop does not
    
    
    care whether the data source is from USB, serial port, or parallel port. The Main Loop only checks the circular buffer for new data to be processed. This concept is very important. Thus, the Main Loop program can target on data processing and the ISR can do the job of data transfer at the fastest speed possible. Similarly, the control endpoint uses the same concept in data packet handling. The ISR receives and stores control transfers in data buffers and sets the corresponding flag reg
引文
1. USB1.1, Universal Serial Bus Specification. http://www.usb.org/develop
    2.范东华,USB总线简化数据采集,电子测试.1998,(11),(10).-34-35
    3.李勇,Windows98/95心电信号数据采集系统的设计,硕士研究生论文,中国医科大学
    4.刘彤、周功业,USB接口技术在外置式采样系统中的应用,今日电子.2000,(7).-18-20
    5.刘丁、王云飞,USB在数据采集系统中的应用,电子技术应用.2000,(26),(4).-37-39
    6.徐有青、余胜生,通用串行总线设备接口的设计,电子计算机与外部设备.1998,(22),(5).-28-32
    7.赵莉、白智涛,基于USB总线的多路同步数据采集系统,半导体技术.2000,(6).-57-59
    8.周洪建、吴小玲,心电监护系统的设计,医疗卫生装备.2000,(21),(6).-3-5
    9.泰旭 戴倜,通用串行总线(USB)在自动测试中的开发应用,电测与仪表.2000,(37),(10).-39-42
    10.通用串行总线(USB)用于测试和测量仪器,国外电子测量技术.2000,(3).-27-29
    11.罗智勇、李在铭,多通道心电图监控处理PC系统,电子测量与仪器学报,2000,(12)
    12. IDT7205, Data sheet, Integrated Device Technology Inc,5/2001
    13. PDIUSBD12, Data sheet, PHILIPS, Rev. 08-20 12/2001
    14.李华编著《MCS-51系列单片机实用接口技术》北京航空航天大学出版社
    
    
    15.徐有青、余生生,通用串行总线设备固件的设计,计算机工程与应用.2000,(36),(1).-77-79
    16.Firmware Programming Guide for PDIUSBD12,PHILIP,Ver1.0
    17.徐爱钧、彭秀华编著《单片机高级语言C51 Windows环境编程与应用》电子工业出版社
    18.张念淮、江浩编著《USB总线接口开发指南》国防工业出版社
    19.Walter Oney《Programming the Microsoft Windows Driver Model》
    20.Chris Cant编著,孙义译《Windows WDM设备驱动程序开发指南》机械工业出版社
    21.David J. Kruglinski, Scot Wingo, George Shepherd编著《Programming Visual C++6.0技术内幕》北京希望电子出版社
    22.杨亮、万玉丹、魏晋鹏著《Windows 深入剖析—内核篇》清华大学出版社。
    23.David Bennett等著《Visual C++5.0开发人员指南》机械工业出版社。
    24.李清,Windows98下的数据采集,国外电子测量技术.1999,(5).-26-28
    25.DriverWork的帮助文件
    26.Microsoft. Microsoft Windows 2000 DDK Document, 2000
    27.USB-IF,http://www.usb.org/develop
    28.孙立敏,“远程ECG家庭诊断系统”,硕士研究生论文,中国医科大学。

© 2004-2018 中国地质图书馆版权所有 京ICP备05064691号 京公网安备11010802017129号

地址:北京市海淀区学院路29号 邮编:100083

电话:办公室:(+86 10)66554848;文献借阅、咨询服务、科技查新:66554700