USB Eases Data Acquisition

-January 01, 1999

The engineers who developed the Universal Serial Bus (USB) probably didn’t consider industrial data acquisition as a potential application for the bus. Nevertheless, for all but the highest data rates, this bus can make collecting data with your PC easier than ever. While USB isn’t yet a mainstream data bus, it soon will be, so you should know how it works with data-acquisition instrumentation.
The USB embodies a rich set of convenient features -- in particular, the capacity for hot-swap, plug-and-play operation; a 30-m range; and an expansion capacity of 127 devices. No performance slouch, the USB has a theoretical 12-Mbps bandwidth. Moreover, the peripherals sit outside the PC box, speeding connections and obviating the need to remove a PC’s cover to install hardware.

Because of these appealing features, data-acquisition manufacturers have developed USB-based products. The USB’s biggest advantage is its plug-and-play capability. Many engineers echo this sentiment or point to related ease-of-use features such as the convenient access to the USB port.

Hardware Inside?

Unfortunately, to enjoy the benefits of USB, you may need to buy a new PC. Only the latest PCs — and not all of them — come equipped with working USB ports. To confuse matters, even machines that have a USB connector may not yet include complete hardware or the required version of
MS-Windows 95/98.


In addition to having the rectangular USB receptacle — roughly 20 @ 10 mm — with its identifying symbol (Fig. 1) and related controller hardware, PCs must run Windows 95 OEM Service Release (OSR) 2.1 or higher, identified as Windows 95 version 4.000.111 or higher. This release is offered only to OEMs and is not available to end users as an upgrade. Even if you could get OSR 2.1 as an upgrade, it likes to be installed on a newly formatted hard disk. The simplest thing to do is buy a new PC. The only other choice is to spend several thousand dollars for a USB driver development kit and then develop your own device drivers.
01ef3f1.gif (829 bytes)
Figure 1. A three-pronged icon identifies the USB port. The USB specification recommends that equipment makers place the icon on both the molded cable connector and near the mating receptacle.


To be sure, these hiccups will subside quickly as PC vendors complete the transition to the USB by moving to either Windows 98 or NT Version 5, each of which will support USB. But if you can’t wait, you’ll need to make sure your PC is equipped with both the necessary hardware and software. National Instruments suggests that you ask your computer manufacturer if Microsoft has qualified the PC as a functioning USB machine. Drivers such as National’s NI-DAQ 6.0 driver and data-acquisition software include a USB-detect utility that examines a system to make sure it has the right components.

PCs with Windows 98 or NT Version 5 will include the software drivers you need to control conventional USB peripherals such as the keyboard, mouse, printer, and scanner. What’s more, the drivers adopt what is called the Win32 driver model, or WDM, which lets you run the same drivers on either platform. Unfortunately, the bundle of supplied drivers isn’t likely to include any for data-acquisition peripherals. The USB development community has defined generic device classes but, as is typical in the PC world, data acquisition is not high on the list. Instead, these drivers will need to come from the instrument manufacturer.

The first time you plug your data-acquisition peripheral into the USB, the Windows operating system will display a message directing you to select a driver. Once you point to that driver, your installation should be a one- or two-click operation.

Figure 2 shows the software layers that reside between you and your hardware. An applications programming interface (API) is usually a DLL that lets an applications program pass control commands to an instrument through lower-level drivers. Typically, the instrument driver communicates with a device driver that controls the PC’s USB controller chip.
01ef3f2.gif (9422 bytes)
Figure 2. An application programming interface, an instrument driver, and a USB device driver reside between application programs and USB instruments.


Data Rate Details

The USB paves a 12-Mbps path to the PC, and it also has a 1.5-Mbps mode for specific low-speed, presumably low-cost, peripherals like a mouse (see “The ABCs of the USB,”). Applications that yield time-critical streaming data can take advantage of the USB’s isochronous transfer capability, guaranteeing a minimum specified data rate. Regardless, all peripherals on the bus share the top data rate, so the bandwidth available for acquiring any data depends on the number of other devices and their throughput demands. As a further limit, no one device can exceed a 6-Mbps transmission rate. So, even if you have just one USB instrument, its maximum data rate is 6 Mbps, and that is true only if all the other USB devices consume less than 6 Mbps.

To accommodate on-time data delivery — the bus designers had audio in mind — the USB performs isochronous data transfers. According to the USB specification, such transfers offer “guaranteed access to USB bandwidth with bounded latency”.1 If at any point the bus can’t deliver the requested bandwidth, you’ll get an error message.

Most applications for USB data-acquisition products are relatively slow, in the range of about 5 to 150 samples/s. Currently, the fastest application seen at National Instruments runs at 38 ksamples/s with a 12-bit instrument. Right now, users seem more attracted to USB’s ease of use rather than to its data throughput.

In many cases, factors other than the USB’s raw throughput will limit the maximum data-acquisition rate. Driver software, computer CPU speed, and set-up overhead are among the potential bandwidth bottlenecks. In one case, developers at National Instruments boosted the transfer rate of their DAQPad-6020E from 60 to 500 kbytes/s by switching to a stripped-down custom driver. In another case, architectural modifications yielded a 1-Mbyte/s streaming data rate.

The overhead incurred by hardware set-up operations can take a heavy toll in throughput because the USB sends data in packets organised around 1-ms framing periods. Although the exact figures depend on the number of functions the data-acquisition device has, a typical setup sequence might have to configure 15 registers to make just one measurement. With each operation performed by packets 1-ms long, it will take at least 15 ms to return the first data point.

Consequently, throughput will suffer if you need to frequently change your instrument’s set-up. To improve throughput, you should minimise the number of setting changes and apply each change to as many data points as possible. In that way, you can stream data back to the PC, cutting the overhead in proportion to the number of data points.

Some vendors believe you should not push the USB beyond rates of 100–200 ksamples/s, assuming 2-byte samples plus packet overhead bits and the fact that other peripherals may share the bus. It’s a soft number that depends on the efficiency of the product. Still, the USB is probably adequate for all except the fastest data-acquisition requirements.

Peripheral Power

In addition to carrying data, the USB cable can also supply power — albeit sparingly — to the peripherals that connect to it. The current available depends on whether you connect to a high- or low-power port, as defined in the specification. High-power ports let you draw up to 500 mA; low-power ports supply up to 100 mA. That’s the total current available to all peripherals that connect to the port. For some data-acquisition products, that’s not enough, so they require a separate supply.

Specifically, Intelligent Instruments’ UDAS-1001 family takes its power from the bus, as do IOtech’s Personal Daq/55 and -56 and National Instruments’ DAQPad-4350, -6507 and -6508. Because the DAQPad-5102 USB-based scope and DAQPad-6020E data-acquisition system offer more functions, they require an external power source, as does the Keithley USB-based SmartLink family.

The USB specification limits not just power but the maximum distance between a peripheral and the host PC or USB hub. In particular, the specification calls for cable lengths up to 5 m. The USB’s tiered-star topology, however, lets hubs stretch the bus across up to six cable lengths, or 30 m, from the host PC. With that, you can get across the lab and into the next room. The fact that hubs can act as fan-out devices as well as extenders lets you create a web-like expanse of data-acquisition points that you can bring back to one computer.

Footnote

1. Universal Serial Bus Specification, Revision 1.0, January 15, 1996. The specification is available on the USB Implementers Forum Web site, www.usb.org.

For Further Reading

The USB Implementers Forum sponsors two Web sites that contain technical information and product information: www.usb.org   and www.usbnews.com.

Gil Bassakis a technical journalist and a former test engineer. He has a BSEE from City College of New York
          
The ABCs of USB
01FEF3FA.gif (19752 bytes)
The USB’s physical interconnect topology forms a tiered star, with a hub at the centre of each star. Each wire segment makes a point-to-point connection between the host and a hub or peripheral, or between a hub and another hub. The maximum allowable distance from end to end is 30 m.

According to its formal specification, the Universal Serial Bus was developed to meet three interrelated requirements:

1. To achieve “ubiquitous and cheap connectivity” to accommodate the convergence of computing and communications, in particular, telephony;

2. To make the connection of peripheral devices “less confrontational and easier to configure”; and,

3. To make more low-cost, bidirectional ports available to the growing number of peripheral devices, including “telephone/fax/modem adapters, answer machines, personal digital assistants, keyboards, and mice”.

  The specification characterises the USB as a cable bus for exchanging data between a host computer and a range of simultaneously accessible peripherals. These peripherals share the bus’s theoretical 12-Mbps maximum data bandwidth through a host-scheduled token-based protocol. A key ease-of-use feature is that the bus lets you attach and remove peripherals while the host and other peripherals are operating — so-called dynamic attaching or hot swapping. In addition, its plug-and-play ability means the bus allocates the peripheral’s required bus bandwidth and host resources automatically.

  As the figure shows, the USB connects all peripheral devices with one host in a tiered-star topology. The hub, at the centre of each star, provides additional attachment points. Each wire segment, which can extend to 5 m, makes a point-to-point connection between the host and a hub or peripheral device, or between a hub and another hub or peripheral. The USB connects to the host computer through a host controller, which manufacturers can implement through combinations of hardware, firmware, and software.

  The USB’s cable contains four wires — two carry signals and two carry power. Differential signal levels swing below 0.3 V for a logic low and above 2.8 V for a logic high. The clock is combined with the data stream using nonreturn-to-zero-invert (NRZI) encoding. A host or hub delivers power from a 5-V (nominal) source. In addition, the USB accommodates power-management features, including suspend and resume commands, making it suitable for battery-powered computers.

  All bus transactions involve transmitting up to three packets, and a transaction begins when the host controller sends a token packet that includes the transaction’s type and direction, a device address, and an endpoint number. The addressed device decodes its address from the packet, and a data transfer takes place between the host and the device in the direction specified by the token packet. The transaction source then either sends a data packet or indicates that it has no data to transfer. The destination responds with a handshake packet to indicate whether the transfer was successful.

  The USB data transfer model between a source or destination on the host and an endpoint on a device that is called a pipe. The specification defines stream and message pipes — the former having no defined data structure where the latter does. Pipes come into existence when a USB device is configured, and they associate the device to a data bandwidth, transfer service type, and endpoint characteristics like data direction and buffer sizes.

  The USB architecture distinguishes four types of data transfers: control, bulk, interrupt, and isochronous. Control transfers configure a device and can be used for other functions specific to
the device. Bulk data transfers typically consist of large amounts of data, such as for printers and scanners. Error detection at the hardware level and, optionally, a limited hardware retry mechanism ensure reliable data exchanges. Small, spontaneous interrupt transfers are initiated by a device and typically perform event notification or, in the case of a keyboard or mouse, transmit characters or coordinates. Isochronous transfers handle continuous data, like voice, that are created, delivered, and consumed in real time. To ensure the timely delivery of isochronous data, the USB allocates a portion of its bandwidth to the transfer, and it doesn’t use hardware retries to correct data errors.—Gil Bassak


For Further Reading

Canosa, John, “Understanding Universal Serial Bus Part 1: USB Basics”, Embedded Systems Programming, Miller Freeman, San Francisco, California, USA, June 1997, p. 34.

Loading comments...

Write a Comment

To comment please Log In

FEATURED RESOURCES