Вы находитесь на странице: 1из 4

2010 WASE International Conference on Information Engineering

A Portable USB Data Acquisition System


Yanpeng Wang, Mingming Fu
Institute of Information Science and Engineering
Hebei University of Science and Technology
Shijiazhuang, China
fmm_hello@163.com

USB bus

AbstractIn order to realize high-speed and real-time


collection of data and facilitate data analysis and processing, a
USB data acquisition system with acquisition, display and
storage function was designed in this paper. The hardware of
the system consists mainly of AT89S51 as the local processor
and PDIUSBD12 as the USB interface device, and the
underlying data communication is operated by the firmware
and drivers. The application program is developed with
LabVIEW under Windows platform. The experimental result
shows that the system can work stably and effectively. The
USB data acquisition system is easy to operate and portable. In
many situations, the system will be a powerful tool for data
acquisition and analysis.
Keywords- Data acquisition; LabVIEW; PDIUSBD12; USB

I.

Figure 1. USB data acquisition system diagram

INTRODUCTION

In general, there are three communication methods used


in modern data acquisition systems between computer and
peripherals: traditional RS232 serial port, parallel port, and
universal high-speed data acquisition card [1]. But not all
these methods are ideal. Here are some examples, the
transmission speed of RS232 serial port is too low to meet
the requirements of real-time, the connection of parallel port
is complicated, and high-speed data acquisition card based
on ISA or PCI is complex and expensive. As a standard
universal serial interface, the best advantages of USB
interface is its high speed, feasibility, support for Plug and
Play, and automatic configuration. In this paper, a USB data
acquisition system is designed. The card can be connected to
a portable computer to acquire data at any time in areas such
as laboratories, construction sites, workshops and other
places.
At the same time, in order to shorten the development
cycle, NI (National Instrument) LabVIEW is used to develop
the application. The user interface of the application is
friendly, and intuitive.
II.

III.

The hardware of the system as shown in Fig. 2 is made


up of signal condition module, 8-bit A/D module, MCU
control module, and USB interface module.
Signal
condition

8-bit ADC

AT89S51

PDIUSBD12

Host

Figure 2. USB data acquisition card hardware framework

The output analog signal from the front-end sensor will


be interfered inevitably. So to recover the original analog
signal as far as possible, it is necessary to condition the
signal through low pass filter and high pass filter. And then
transmit the signal to the ADC [2].
The followed processes are controlled by the host
computer. The host sends commands to the PDIUSBD12,
informing the MCU what kind of operation should be carried
out. If the host reads the current data, the MCU will start data
conversion. The ADC according to the MCU will convert the

BRIEF INTRODUCTION OF SYSTEM

As shown in Fig. 1, the USB data acquisition system is


constructed by several parts: data conversion and procession,
data communication, and computer software. The sensor
module varies in different situation. Our main work is to
realize real-time data acquisition, display, storage and other
functions.

978-0-7695-4080-1/10 $26.00 2010 IEEE


DOI 10.1109/ICIE.2010.331

SYSTEM HARDWARE

169

analog signal to digital signal and output the data. After


receiving the data, the MCU will transmit them to
PDIUSBD12. And then the data will be transmitted to the
host.

B. Circuit between MCU and PDIUSBD12


The PDIUSBD12 is a cost and feature optimized USB
device. It is normally used in microcontroller based systems
and communicates with the system microcontroller over the
high-speed general purpose parallel interface. It also supports
local DMA transfer. The PDIUSBD12 fully conforms to the
USB specification Rev.2.0 (basic speed) [4]. It is also
designed to be compliant with most device class
specifications: Imaging Class, Mass Storage Devices,
Communication Devices, Printing Devices, and Human
Interface Devices.
The circuit between MCU and PDIUSBD12 is shown in
Fig. 5. In the circuit, the A0 pin is permanently tied low. The
ALE pin of the PDIUSBD12 connects to the ALE pin of the
AT89S51. These signify a multiplexed address and data bus
configuration. The multiplexed address and data bus of the
AT89S51 is then connected directly to the data bus of the
PDIUSBD12. The clock input signal of the AT89S51 (pin
XTAL1) can be provided by output CLKOUT of the
PDIUSBD12.

A. Circuit between MCU and ADC


The ADC used in the design is ADC0820 from Maxim.
The ADC0820 is a high speed, microprocessor compatible, 8
bit analog-to-digital converter which uses a half-flash
technique to achieve a conversion time of 1.4 us. The
converter has a 0V to +5V analog input range and uses a
single +5V supply [3]. It has two work modes, which is
controlled by MODE pin. When MODE is high, ADC0820
works in WR-RD mode; when MODE is low or open, it
works in RD mode. The WR-RD mode (using the internal
delay) is used in the system, as shown in Fig. 3. And the
work timing is shown in Fig. 4.

VCC

47uF

VCC

20

C6
C5

12
3
8
6
7

VDD

VrefVref+
CS
RD
WR/RDY
MODE

INT
OFL
DB0
DB1
DB2
DB3
DB4
DB5
DB6
DB7

9
18
2
3
4
5
14
15
16
17

P1.0

R8
10K

P0[7..0

P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7

89S51

PDIUSBD12
INT_N
ALE
DATA[7..0]
WR_N

INT0
ALE
P0[7..0]
WR

RD_N

10

P2.2
RD
WR

Vin

ADC0820

1
11

GND

Vin
R5
1K

0.1uF

RD

CLKOUT

XTAL1

CS_N
A0

Figure 3. Circuit between MCU and ADC0820

P2.3

R9
10K

In this operating mode, the processor waits for INT to


go low before reading data. INT typically goes low 600 ns
after the rising edge of WR , indicating that the conversion
is complete. With CS low, DB0-DB7 are read by pulling

Figure 5. Circuit between MCU and PDIUSBD12

The INT_N pin connects to +5V through a resistorand


VOUT3.3 connects to 1uF capacitor (electrolytic capacitor) and
two 0.1uF decoupling capacitors.
What needs to pay attention, although USB can provide
power, but it can provide only 500mA current. In order to
ensure that the system is stable and reliable, it is necessary to
provide +5 V external power supply in the system.

RD low. INT is then reset on the rising edge of CS or


RD .

IV.

SYSTEM SOFTWARE

The software of the system is made up of the design of


firmware, the design of USB driver and the design of PC
application program. Only when the above three fully
coordinate with each other, can the system complete high
speed data acquisition and transmission reliably.
A. Firmware Design
The firmware generally consists of three parts: First,
initializing MCU and all the peripheral circuits (including the
PDIUSBD12) part; second, the main loop part. This part can

Figure 4. ADC0820 work timingusing the internal delay

170

transmission will be also affected by using different type of


transmission, different group size, the DMA mode, and the
transmission buffer size. There are lots of rules when carry
out timeout processing at high-speed condition.

be interrupted; third, the interrupt service routine part. This


part is time-sensitive, and must be Executed immediately [5].
Each USB data transfer is initiated by the host. After
completing the initialization work, the MCU will work in the
main loop, waiting for interrupts. The host firstly send token
package to the USB device (the PDIUSBD12 chip). After
PDIUSBD12 receives token package, it requests interrupt to
the MCU. Then the MCU enters the interrupt service routine.
The MCU firstly reads the interrupt register of PDIUSBD12,
then determines the type of the USB token package and
perform the appropriate action. It can be said that the
designing of the interrupt service routine is mainly the
designing of MCU firmware. The program frame of
firmware is shown in Fig. 6.

B. Driver Design
The equipment designed in this paper should realize the
self-defined read and write operation. Then new device class
is needed. So it is necessary to design the corresponding
driver. Driver Studio tools is used to write driver, under the
rules of WDM (Windows Drivers Model). When the
application needs to read data from the hardware, it calls the
standard Win32 API functions to achieve, such as
ReadFile(). While the Win32 subsystem modules (such as
KERNEL32.DLL) implement the API by calling the
platform-related system service interface, and the platformrelated service will call kernel mode to support routines.
All the kernel-mode I/O operations use a common data
structure (IRP, I/O request packet). The kernel sends each
kind of IRP to the WDM driver.
C. Application Design
LabVIEW is developed by NI (National Instruments) in
America. LabVIEW is a graphical programming
environment used by many engineers and scientists to
develop measurement, test, and control systems using
intuitive graphical icons and wires that resemble a flowchart.
LabVIEW offers unrivaled integration with lots of hardware
devices and provides lots of built-in libraries for advanced
analysis and data visualization. It includes lots of procedures
for data acquisition, data and signal analysis, and system
control. It is easy to design program by using this software.
And the program designed by it is easy to debug and
maintain. So it is used in the portable USB data acquisition
system to develop application.
LabVIEW is highly flexible. It provides powerful ability
in communicating with external programs, such as DLL, C
language, ActiveX, .NET, DDE, and Matlab [6]. In order to
speed up program development, DLLs can be called by using
the LabVIEW Call Library Function node. It is worth
mentioning that the data storage format of LabVIEW follows
the data storage format of C language, so users can pass any
kind of data structures to CINs. In addition, CIN has higher
efficiency than the graphical language in implementation.
The program frame using LabVIEW is shown in Fig. 7.

Figure 6. Program flow chart of the firmware

The firmware is programmed by C programming


language. It is useful to write some functions for facilitating
the design of the firmware. Below is some code of MCU
firmware about operating PDIUSBD12:
void outportb(unsigned short Port, unsigned char Val) //
operation of writing PDIUSBD12;
{
unsigned char xdata *ext_address;
MCU_HOSTDACK =1; // Set the flag variable;
ext_address=0xf700 + Port; //Set the port that will be
written;
*ext_address = Val; //Write command or data;
MCU_HOSTDACK =0; //Clean the flag variable;
};
When the MCU firmware is programmed, it is necessary
to pay attention to coordinating the operation level and
timing of both MCU and PDIUSBD12. Only in this way, can
the system implement the functions and work well.
Firmware programming is a very important part in
developing USB peripheral. It has a direct effect on product
design and the speed of data transmission. The speed of data

Figure 7. Program flow chart of the application designed using LabVIEW

Based on the above, the application designed using


LabVIEW is shown in Fig. 8.

171

In the figure the original signal is generated by sine wave


generator. It is can be seen that the system realize data
acquisition, display, storage and other basic functions. The
signal acquired is visualized and can be stored for further
analysis.

Thanks to my colleagues in the laboratory for helping me


when I am in trouble. Without their help, I could not
accomplish my design and paper in such a short time.
Thanks to all the people that support me. Thanks them for
giving me spiritual encouragement.
REFERENCES
[1]

[2]

[3]
[4]
[5]
Figure 8. Interface of application program using LabVIEW
[6]

ACKNOWLEDGMENT

172

X.F. Han and S.Q. Zhou, Design and Implementation of


Temperature Data Collection System Based on USB, Journal of
Logistical Engineering University, vol.25, pp.60-63, 2009.
N.Q. Fan, G.H. Wang, and Y.R. Lu, Design and Implementation of
Computerized Logging Ground Data Acquisition System Based on
USB, Instrument Technique and Sensor, vol.1, pp.59-61, 2009.
Maxim Integrated Products, Inc., ADC0820 Data Book, Rev.1,
1996.
Philips Semiconductors, Inc., PDIUSBD12 Data Book, Rev.08,
2001.
J.W. Xu and S.X. Qian, Design of High-speed Data Acquisition
Board Based on USB Bus, Electrical Measurement &
Instrumentation, vol.44, No.504, pp.44-47, 2007.
Y. Wei and S.P. Sun, Interface Design of Virtual Instrument Based
on LabVIEW and USB, Modern Electronics Technique, vol.8,
pp.163-169, 2009.

Вам также может понравиться