|
Using USB 2.0 in speedy DAQ systems
By Thorsten Beierle
Data Translation Inc.
Because the USB was originally developed to replace low-speed peripheral cabling, many engineers fail to see its potential as a high-performance data-acquisition channel. Properly implemented, however, a USB 2.0 data-acquisition system can pump data into a PC as fast as PCI-based cards. The keys to achieving this performance are a hardware interface and optimized driver software.
While the original USB specification had only a modest bit rate, high-speed USB 2.0 performs at 480Mbps, fast enough to handle 60MBps data streams. The protocol does reserve some bandwidth for interrupts and control transfers, and data packets have overhead bytes. But even with these reductions, the bus can easily sustain more than 10MBps of continual data transfer.
USB has many advantages for data acquisition (DAQ). The plug-and-play installation of USB peripherals means users do not have to set up and configure the hardware to use it; it sets itself up upon installation. Also, USB handles data streams in logical channels called "pipes." Pipes automatically form a logical connection from a hardware channel to an application, further simplifying system setup and ensuring that data automatically travels to the right destination.
USB also has electronic advantages. The bus can power the peripheral (within limits), so the DAQ system does not need its own power source. This further eases system installation and use. USB also has the benefit of distancing the sensitive A/D converters and amplifiers from the electrically noisy environment inside the PC's housing. Thus, unlike PCI plug-in cards, a USB-based DAQ is easily shielded for high-resolution applications.
Bulk transfers The proper mode to use for DAQ on USB is bulk transfer. That allows for the resending of corrupted packets, ensuring data accuracy, and allows fairly large 512-byte blocks, keeping overhead effects down. The drawback is that bulk transfers do not have guaranteed timing. The USB host controller assigns bandwidth for bulk transfers but reserves priority for interrupt and control transfers. So the bandwidth for bulk transfers is an average, not a sustained data rate.
To handle this situation, the DAQ system needs FIFO buffering to hold data while waiting for the bus to become available. This buffering also supports the retransmission of data when noise corrupts a transfer packet. In addition, the software drivers should allocate buffer space in the host system at the receiving end. This decouples the host system's data-processing activity from the data acquisition so that neither activity can delay or impede the other's performance.
But buffering alone is not enough. The USB interface hardware and the host controller software can seriously constrain achievable USB data rates if not implemented with high performance in mind. As the interface hardware, for instance, the use of a USB microcontroller to handle the transfers can result in lower-than-optimal performance because of its software implementation. A much faster interface can be achieved by using a state-machine hardware controller optimized for 512-byte transfers.
On the host side, the traditional Windows drivers can exhibit significant latency as they allocate buffer space in response to an incoming USB transfer. By creating drivers that preallocate buffer spaces of the right size, developers can decrease host latency by an order of magnitude. These are not simply theoretical suggestions; they have been proven in practice.
Data Translation has achieved a sample speed of 2MSps on two simultaneous channels over a USB link with the DT9832A data-acquisition module. Because there are more than analog input channels in any DAQ system, the module also allows analog outputs, high-speed digital I/O and even quadrature decoders to share its USB data path. All these I/O channels can be clocked or triggered synchronously to better correlate measurement readings.
Our experience shows that we can create USB modules that can sustain reliable data rates as great as 10.9MBps, corresponding to sample rates of 5.45MSps. We also see a potential to take USB-based data acquisition to even higher levels with additional buffering and driver optimization. Far from being a low-speed peripheral bus, the USB 2.0 has a proven capability for supporting high-speed data acquisition.
About the author
Thorsten Beierle is a senior application engineer at Data Translation Inc. Comments may be sent to tbeierle@datx.com.
|