Global TMW:
Login  |  Register          Free Newsletter Subscription
Subscribe
Email
Print
Reprint
Learn RSS

USB Proves Ready for T&M Tasks

Our hands-on tests prove that true plug-and-play instruments have finally arrived.

Martin Rowe, Senior Technical Editor -- Test & Measurement World, 1/1/1999

Over the past year, I’ve read many articles and heard many people proclaim the Universal Serial Bus (USB) as the next instrument bus. As with all new technologies, you hear the hype for years before you get to see if the technology actually works. Being a technology skeptic, I decided to try the USB for myself.

I used the USB port to communicate with two data-acquisition modules, a USB hub, and a USB debug tool. The successful experiments have convinced me that the USB is a viable communications bus for instrument control. It finally brings true plug-and-play and hot-swap instruments to PCs. You simply load software, connect your USB peripheral, and begin using it.

I ran my tests on a 300-MHz Pentium PC with 64 Mbytes of RAM running Windows 98. The original release of Windows 95 didn’t support USB. Windows 95 service release 2.1 and Windows 98 support USB, but I suggest using Windows 98 because instrument makers are writing USB drivers that will work with Windows 98 but won’t work with Windows 95. The two operating systems have different calls to the USB ports.

For my tests, IOtech (Cleveland, OH) supplied a Personal Daq/56 and National Instruments (Austin, TX) supplied a DAQPad-4350. IOtech also supplied a USB hub from ADS Technologies (Cerritos, CA). First, I tested the USB instruments with software supplied by the manufacturers. Then, I wrote an application in Visual Basic (VB) to control both devices.

Whenever you install a new plug-and-play peripheral (USB or not), install the software before connecting any hardware. With USB peripherals, you need not turn off the PC to install USB hardware.

IOtech’s Personal Daq/56 comes with five floppy disks (or a CD-ROM) containing the Personal DaqView datalogging software, PostView waveform analysis software, instrument drivers, and language support that you select during installation. I selected VB support. Then, I connected the Personal Daq to one of my PC’s two USB ports. Windows 98 found the new device and configured the driver. Next, I started the Personal DaqView software, set up analog input channel 1, connected a voltage source to channel 1, and read the voltage on my screen. I also captured the 1-Hz triangle wave in Figure 1 with the Personal Daq.

Figure 1. IOtech's PostView display captured data files after acquisition.

To test the Personal Daq’s two 8-bit digital IO ports, I built a test circuit containing numeric LED displays. Each display contains seven segments and a decimal point—ideal for testing an 8-bit port. I used three displays, two of which correspond to the Personal Daq’s two digital ports. (I reserved the third display for the DAQPad 4350’s single 8-bit digital port.) Personal DaqView lets you control the digital I/O ports, so I tested the Personal Daq’s ports by lighting the display’s segments under software control. Later, I used these digital readouts for the first tests of my VB application.

Fully Equipped
National Instruments’ DAQPad-4350 comes with a copy of VirtualBench, which contains several instrument software panels. To operate the DAQPad you need NI-DAQ, a set of drivers that National Instruments supplies with its data-acquisition products. I installed NI-DAQ and the VirtualBench Logger program, then connected the DAQPad to the computer’s unused USB port.

Windows 98 detected the DAQPad and configured the driver—or so I thought. VirtualBench couldn’t find the DAQPad, so I retreated to NI-DAQ and opened its test panels. The test panels also couldn’t find the DAQPad, and a window instructed me to run the NI-DAQ configuration utility. I opened the utility, which should display the National Instruments’ products that are available to NI-DAQ. The DAQPad should have shown up as device DAQ 1, but the utility displayed no National Instruments devices.

A quick call to National Instruments revealed the problem. I had the wrong version of NI-DAQ. NI-DAQ 6.1 works with USB devices under Windows 95 service release 2.1, but it won’t work with Windows 98. While developing Windows 98, Microsoft changed some function calls to its USB device drivers. National Instruments sent me a prerelease copy of NI-DAQ 6.5—which is now available. I installed the new version, and NI-DAQ found the DAQPad. I then used the test panels to measure a voltage and to control the digital I/O port, which illuminated the third LED display. After that, I used VirtualBench Logger to capture the waveform in Figure 2.

Figure 2. National Instruments' VirtualBench contains a datalogger program.

If you currently have a USB DAQPad running under Windows 95 and you want to move to Windows 98, then you’ll need NI-DAQ 6.5. You can request it from National Instruments or download it from www.natinst.com. If you’re happy with your USB DAQPad running under Windows 95, then stay with Windows 95 and with NI-DAQ 6.1—NI-DAQ 6.5 USB support won’t work with Windows 95. If you’re going to add more USB peripherals to your system, then I suggest you use Windows 98 and upgrade to NI-DAQ 6.5.

With the DAQPad running, I used VirtualBench Logger to control the analog inputs and digital I/O port with the third LED display. I fed the 1-Hz triangle wave to one channel on each instrument. Using IOtech’s Personal DaqView and VirtualBench programs, I captured and stored 5 min of data to disk. I could then view the Personal Daq’s data using IOtech’s PostView software or import the DAQPad’s data file into VirtualBench.

Why did I use a 1-Hz signal? Both instruments are designed for low-speed, high-resolution measurements. The Personal Daq samples at a maximum 80 samples/s while the DAQPad samples at a maximum 60 samples/s. Neither instrument came close to stressing the USB. According to IOtech, the Personal Daq sends 48 bits per sample to the host computer. That’s just 3840 bps at top speed. The DAQPad also sends 48 bits per sample, which is 2880 bps. So, I needed just 6720 bps to capture the waveform with both instruments.

My VB Application
So far, I had performed datalogging and digital I/O tests with manufacturer-supplied software. But the software wouldn’t let me do everything I wanted, such as continuously and silmultaneously run the analog inputs and digital outputs. So, I wrote a VB application to control the digital and analog functions of both instruments.

Figure 3 shows the control panel I designed. The initialize button in the center runs code that sets both instruments to known states. Separate buttons initiate the analog input and digital output ports of each device. A stop button suspends all I/O operations.

Figure 3.The user interface I designed in Visual Basic controls the analog and digital I/O ports of both the Personal Daq/56 and the DAQ-Pad-4350.

Programming is like playing a musical instrument—you must constantly practice to keep your techniques fresh. I don’t program often, so I appreciated having some example code. Both IOtech and National Instruments provide programming examples for their USB products. With sample programs, you can copy and paste working code into your application, then modify the code to meet your needs.

When programming a data-acquisition device, I like to start with the digital outputs because they require one-way communication only. You send a command and see the results. If you start with inputs, you have to send a command, read the data, and transfer it to the computer. I started my digital I/O port tests by writing a simple 0–9 loop. From a look-up table, I sent a hex code to the I/O ports that illuminated the segments and displayed the count. I knew the program was working when I saw the LEDs display the digits 0 to 9. I set the decimal point on even numbers only.

Convinced that my program could control an instrument, I tried acquiring data. Most data-acquisition products give you several ways to collect data. Some commands will configure the channel’s gain, set up a trigger, and acquire the data. Other commands perform just one of these functions, so you need more code to acquire data. The separate commands, when properly used, give you more speed and flexibility than a single command. Still, I prefer to start with the easiest commands until I’m sure I’m acquiring data.

Table 1 contains the VB function calls I used to acquire data. VbdaqAdcRdN performs multiple scans on a single channel. Ni435X_Getting_Started scans one or more channels where the scan table resides in an array called channelString. See "How USB Drivers Work," below, for an explanation of how an instrument driver’s function calls interact with USB device drivers.

Table 1. Visual Basic analog-input programming commands

IOtech Personal Daq/56
VbdaqAdcRdN (DeviceNumber, Channel buffer!(), scanCount, triggerSource, edgeType, level, freq, gain, flags)

National Instruments’ DAQ/Pad-4350
NI435X_Getting_Started (deviceName, channelString[],mode, lowLimit, highLimit, numberOfScans, Data)

Prepare for a Crash
Whenever you write code under Windows to communicate with I/O drivers, check your code every time you add a new call to a device driver. If you miss one parameter, you can cause VB to shut down or your entire system may freeze. Also, save your code changes before running the code.

Visual Basic crashed numerous times, appearing to have shut down without Windows 98 or Norton Crash Guard informing me of the crash. When I reopened VB and tried to open my VB form, I received a message box telling me the VB form was already open. I had to restart the computer to open my form. When I neglected to save changes prior to a crash, I’d lose them. At times during my code development, Windows would freeze and force me to use the PC’s reset button to reboot the system. Part of my troubles may have come because I was using an unreleased version of NI-DAQ.

Know Your Ports
Because I had just two USB devices, I could control both through the two USB ports on my PC. In USB lingo, the host PC is called the root hub, which typically has two ports. The USB lets you control up to 127 devices from a root hub, but if you have more than two devices, you’ll need to add hubs. USB hubs let you build a network of peripherals controlled by your PC.

I wanted to try the ADS Technologies $69 USB hub, so I removed both instruments from the PC’s USB ports and connected the hub to one of the PC’s ports. As soon as I connected the hub, Windows 98 found the device and configured its driver. The hub’s instructions said I might need the Windows 98 CD-ROM to load the hub driver, but I didn’t. I connected both instruments to the hub, and both worked properly.

With the hub installed, I had the beginnings of a USB network. If you’re currently using USB instruments, you probably have no other USB devices on the bus. Future PCs, however, will likely use the USB to connect a keyboard, a mouse, a monitor, a printer, a modem, and even speakers to your system.

Each time you add a USB peripheral to your network, the host PC maps the device. The host also sets up data packets for communicating with each device. The mapping process is called enumeration.1

As you start to build a USB network, you may need debug tools. Start with Microsoft’s Windows 98 Resource Kit, which contains a program called USBView.2 I used USBView to show a Windows Explorer-like diagram of my USB network in Figure 4. USBView also provides information about the peripheral you select.

Figure 4. USBView.exe displays a map of your USB network along with information about each peripheral.

Other tools are available for troubleshooting USB systems and USB devices. Sycard Technology (Sunnyvale, CA) supplied a $189 USBDebug 700, which gives you information about and access to the USB. You simply insert the USBDebug module into any USB port. LEDs tell you if there’s any activity in that port and will give you indications of how much current(>500 mA or <100 mA) is flowing from the port. The USBDebug also has a series resistor that lets you measure the port’s current. You gain access to the data lines where you can connect an oscilloscope or logic analyzer. Sycard also offers USBTest 2000, which tests root hubs, for $595.

Today’s PCs have one root hub with two USB ports, and peripherals share the root hub’s bandwidth (12 Mbps with no device using more that 6 Mbps). If you need additional USB bandwidth, you can install a PCI bus card that adds another root hub to your PC. You can also use these $39 cards to add USB ports to PCs that lack the USB. A recent article in Windows magazine reports that these cards install easily and work well under Windows 98.3

Today’s new PCs have more available USB bandwidth for capturing data than future PC’s might have. Right now, your keyboard, mouse, monitor, printer, modem, and speakers use dedicated I/O ports. When they do connect to the USB, these devices will consume USB capacity. You’ll have to calculate how much bandwidth each will use to be sure you have enough capacity for digitized signals. To do that, ask your instrument manufacturers how much of the USB capacity their product uses at the speed you’ll run it. If you lose data, you may find that you’re using too much USB capacity.

USB for Test Systems
The USB’s 12-Mbps bandwidth is comparable to that of the IEEE 488 bus. I doubt USB will ever replace IEEE 488 because of the older bus’s large installed base. You can, however, use USB to build small test stations or data-acquisition systems. USB-based instrumentation will certainly have an appeal when you need flexibility or when you’re assembling a temporary test system. T&MW

Acknowledgements
I wish to thank Bakul Damle, staff engineer at National Instruments, and David Schraff, applications engineer at IOtech, for their technical help.

FOOTNOTES
1. McDowell, Steven, and Martin D. Seyer, USB Explained, Prentice-Hall PTR, Upper Saddle River, NJ, ISBN 0-13-081153-X, 1998, p. 86. www.phptr.com
2. Microsoft distributes USBView.exe in the Windows 98 Resource Kit. Microsoft, Redmond, WA, ISBN 1-57231-644-6, www.microsoft.com/msvs/title/doc/dtlsht/1756_dtl.htm
3. Finnie, Scott, "Do-It-Yourself Kits Add USB to Older PCs," Windows magazine, November 1998, p. 48, www.winmag.com

USB Instruments Used for This Article
In this article, I used two competing USB-based data-acquisition products. I decided to write the article to report my experiences with using the USB, not to compare the instruments nor recommend one over the other. Still, you should know the features of each instrument and how they differ.

IOtech’s Personal Daq/56 ($995) has 20 single-ended analog inputs or 10 differential analog inputs, 16 digital I/O lines (two 8-bit ports), and 4 frequency or pulse input channels. You can get up to 80 single-ended (40 differential) analog inputs by adding expansion modules that connect directly to the Personal Daq/56. The instrument gives you up to 22 bits of resolution at 3 samples/s. At the other end, you get 15 bits at 80 samples/s. You can connect voltage or thermocouple inputs to any analog-input channel, and you connect your signals directly to the Personal Daq unit. The USB can supply power to peripherals, and you can power one Personal Daq/56 directly from the USB. If you add expansion modules, then you should use the Personal Daq’s external power supply.

All Personal Daq products come with Personal DaqView software, which lets you log data in real time using charts, meters, or level indicators. You can store data to disk and replay it using PostView, which also comes with the instrument. The instrument has programming support for Visual Basic, C, and C++. You select which language support you want when you install the Personal Daq software, which includes programming examples.

National Instruments’ DAQPad-4350 ($1095) requires an external terminal pad that connects to the DAQPad unit through a company-supplied cable. I used the TBX-68T terminal pad, which provides 14 differential analog inputs (voltage, thermocouple, thermistor, or RTD) plus 8 digital I/O channels. You can’t add expansion modules to the DAQPad. If you need more channels, you must use another unit. The DAQPad-4350 receives power from the USB only.

The DAQPad, with NI-DAQ and instrument drivers, supports Visual Basic, C, C++, LabWindows/CVI, and LabView. LabView comes with programming examples for the DAQPad and contains a DAQPad instrument driver. For C, C++, and Visual Basic, you can download programming examples from National Instruments’ Web site (www.natinst.com). The DAQPad comes with a copy of VirtualBench software.

Other companies have started to offer instruments with USB ports. National Instruments has introduced a 96-channel digital I/O module, the DAQPad-6507 ($695) and a general-purpose data-acquisition unit, the DAQPad-6020E (100 ksamples/s at 12 bits, $1195). Dataq Instruments offers the DI-730, a 16-bit data-acquisition module with a USB port. But so far, no company has offered bench instruments such as oscilloscopes and signal generators with USB ports.—Martin Rowe

How USB Drivers Work
Windows 95 service release 2.1 and Windows 98 contain the device drivers and other services that support USB. These drivers give applications programs access to USB ports. You can write an application that writes instructions directly to the USB device drivers, but instrument manufacturers provide an instrument driver. This driver, usually provided as a dynamic link library (DLL), lets you write applications using instrument-specific function calls. The DLL then translates your instructions into lower-level function calls to the USB device drivers. See the figure.

Instrument drivers contain function calls that speak the language of your instrument—channel, gain, scan rate, etc. Sometimes, as was the case in the functions I used, the instrument driver performs several functions with one call. To communicate with the instrument, the instrument driver sends commands to the USB device driver, which resides in Windows.

A USB device driver performs several functions. Besides sending and receiving messages from the peripherals, the USB driver detects when you connect or remove a USB device from the USB network. It also controls the data so no peripheral consumes too much bus bandwidth. The USB driver controls the amount of current a port supplies to each peripheral. If you use a USB hub, then each hub is responsible for controlling the data and power to the peripherals connected to it.—Martin Rowe

 

USB Product Suppliers

Data-Acquisition Products with USB Ports
Dataq Instruments
Akron, OH, 330-668-1444
www.dataq.com

IOtech
Cleveland, OH, 440-439-4091
www.iotech.com

National Instruments
Austin, TX, 512-794-0100
www.natinst.com

Test Equipment for USB Peripherals and Hosts
Sycard Technology
Sunnyvale, CA, 408-749-0130
www.sycard.com

USB Hub, USB Port Add-In Card
ADS Technologies
Cerritos, CA, 562-926-1928
www.adstech.com

 

Email
Print
Reprint
Learn RSS

Related Content

Related Content

 

By This Author

Sponsored Links



 
Advertisement
SPONSORED LINKS

More Content

  • Blogs
  • Podcasts

Blogs

  • Martin Rowe
    Rowe's and Columns

    May 28, 2008
    More on Bill and Dave
    In my January 11 posting, "Tell your Bill and Dave Stories," I asked if the HP Way still e...
    More
  • Rick Nelson
    Taking the Measure

    May 6, 2008
    LED bulbs not quite ready for consumer lighting
    Now that people are finally adopting compact fluorescent bulbs, is it time to throw them out and rep...
    More
  • » VIEW ALL BLOGS RSS

Podcasts

Advertisements





NEWSLETTERS
Click on a title below to learn more.

Test Industry News (3 Times Per Month)
Machine-Vision & Inspection (Monthly)
Communications Test (Monthly)
Design, Test & Yield (Monthly)
Automotive, Aerospace & Defense (Monthly)
Instrumentation (Monthly)
Resource Center E-Alert (Monthly)
©2008 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy
Please visit these other Reed Business sites