|
|
October 2002
Data Acquisition Software Part 2: Application Programming Interfaces, ActiveX, Program Timing Control, and Other Hardware-Related Topics Software is the engine that's driving data acquisition systems. The trick is to squeeze as much juice as possible out of this resource.
Mark Cejer, Keithley Instruments, Inc. The replacement of DOS by Windows, plus today’s increasingly complex test systems, have placed greater demands on data acquisition (DA) software and its development. Under DOS, programming a DA device was relatively easy. Multitasking didn’t exist. Typically, only one program at a time could take control of the computer, and it could engage in just one task at a time. DA equipment vendors usually provided extensions to popular programming languages (e.g., C, Pascal, and Basic) that added commands to control hardware and deal with data. Where this support wasn’t provided, you could still access the corresponding memory and I/O addresses with relatively simple commands, such as inp and outp in C, or peek and poke in Basic. Users sometimes resorted to simple for-next counters for timing that, although sensitive to processor speed, could provide reasonably consistent results on a given computer because the program didn’t share any system resources. One big disadvantage was that each DOS application not only had to include DA drivers but also specialized drivers for the peripherals it might be used with (e.g., printer, mouse, and video). So, programmers and developers had to write drivers for a variety of hardware—not just their own products. With the multitasking paradigm of Windows, Microsoft had to establish a new set of rules for managing communications with peripheral devices, as well as the timing of program execution. In most cases, programmers no longer need to develop drivers for peripherals and other generic system resources because they’re included in Windows or supplied by the hardware and software manufacturers. This lets programmers concentrate on the development of drivers for their own test hardware. A Windows driver is no longer a single .exe file that’s loaded in memory or copied to a special directory. Rather, a typical Windows application consists of many files—such as .inf, .sys, .vxd, .exe, and .lib files—that require a specific installation process. Such installations might also include modification of the Windows registry, implementation of plug and play, alteration of the power management setup, or specialized resource management. The installation process isn’t just a matter of copying files to a hard drive; it’s performed according to an algorithm that must be tailored to each version of Windows. Moreover, when Windows is upgraded from one version to another, the upgrade can easily create compatibility problems with previously installed device drivers. While everyone expects developers to upgrade these drivers, the process sometimes lags behind the introduction of new Windows versions. Furthermore, developers may fail to plan for all possible contingencies among all user machines and be faced with additional updates as problems are uncovered. Under Windows, a test and measurement application might simultaneously acquire data from multiple devices, control a time-sensitive process, graph data, save data to a database, and make them available on the Internet. Windows is a message-driven, event-polling system with nonpreemptive scheduling, which means that it can’t guarantee interrupt response times. A time-critical application that encounters long or unpredictable delays might fail. Tests such as the one described above impose more demands on device drivers and other system resources and can make it increasingly difficult to achieve precise timing.
The Application Programming Interface Typically, the API is part of the driver package and should be designed first when a device driver is developed. The ActiveX control interface is an example of an API that plays a significant role in simplifying development of test programs for DA and other applications. Other types of APIs include Component Object Model (COM) objects, dynamic link libraries, and support modules for Visual Basic, Visual C/C++, and other programming languages. The API can be an important component in obtaining results from a test application. For example, streaming digital data to disk at 100,000 sps requires high-speed DA hardware and API tools that can transfer data quickly and efficiently to disk. Similarly, accurate logging of temperature data requires not only good measurement techniques and cold junction sensors but also a cold junction compensation algorithm in the API. Ideally, the driver software will automatically support all necessary hardware features. However, developers and end users should pay close attention to the features and limitations offered by a given API.
Hardware Independence For example, consider how quickly the transition from RS-232 to USB and FireWire is occurring. The degree of portability of an API helps determine whether the software will have to be rewritten with every hardware upgrade.
ActiveX Controls ActiveX is a set of rules governing how different applications or software components interact and share information in the Windows environment. Developers have been shifting rapidly to component-based software architectures, so ActiveX controls are among the most important features in an API. An ActiveX control (formerly known as an OLE or OCX control) is a user interface element that takes advantage of the standards for information exchange and functional modularity among Windows-based applications. ActiveX controls are based on COM technology, a software architecture that allows applications to be built from software components. This technology provides many benefits, including easier integration, scalability, and reusability, as well as language independence, cross-platform compatibility, and context-sensitive help. A major benefit of ActiveX is its use of a single, simple object to replace many lines of code for common functions. This lets programmers create reusable software components that can be interchanged without the need to rewrite entire applications. Interchangeability reduces development cost and extends the life of an application.
The code shows the simplicity of programming with ActiveX controls. In this component-based open architecture model, each of the ActiveX controls is an independent entity, which could be supplied by more than one vendor. Test and measurement manufacturers and third parties have developed thousands of ActiveX controls, which strongly support and benefit open architecture software systems. These properties of ActiveX and its underlying model protect your software investment by making applications more portable and by simplifying hardware upgrades. While it’s natural for a given test and measurement vendor to maintain the same driver interface and syntax across all its hardware and languages, software reusability is particularly challenging when using multiple vendors.
FIFO Buffer Overruns
The Role of DMA During a DMA transfer, the CPU can perform other tasks without affecting data transfer speed. Typically, the DA device transfers a complete set of data to the computer by initiating multiple 64 KB DMA transactions. At the end of each transaction, the device driver generates an ISR and handles the ensuing process. The DA device can chain multiple DMA transactions, making the process even more efficient by reducing the number of ISRs. There are two styles of DMA design. Bus master DMA is used with the PCI bus, and system DMA is used with the ISA bus. With bus master DMA, the PCI board contains all the control circuitry necessary to initiate a DMA transfer. With system DMA, the support circuitry resides on the motherboard and is shared among all ISA peripherals. Bus master DMA is more efficient than system DMA, and the PCI bus operates at a higher data transfer rate than the older ISA bus. In either case, DMA requires critical coordination between hardware and software. The hardware must have the proper circuitry, and the software must implement the proper procedures for successful DMA operation.
Polled vs. Event-Driven Control By way of comparison, a deterministic DA system is one that collects data having discrete values and direct cause-and-effect relationships with the physical phenomena they represent. This implies a strong time relationship between the data and the underlying phenomena. Typically, DA running in the background, using DMA- and ISR-driven operations, is under the control of the DA hardware. The hardware notifies the user’s application when the task is complete. The time between background readings is clocked by the DA hardware and is independent of Windows timing. During a background data transfer, the DA hardware interrupts the CPU. The driver handles the interrupts by transferring data into application memory space. When the requested background operation is finished, the driver posts a Windows message or event to the application, which responds to the event and manipulates the data. Windows uses events and messaging to distribute information to applications and processes within an application, thereby managing its multitasking system. Event-driven programs result in a more deterministic system. It’s easy to program an application that uses polling. Polling can be appropriate with slower, non-time-sensitive operations, such as programming discrete steps in a power supply’s output or reading precise voltages from a nanovoltmeter. Trying to squeeze high speed out of a polled application will probably lead to unacceptable results. In applications that use high-speed DA boards for faster sampling rates, event-driven programming is advised. Event-driven programming schemes are less dependent on operating system timing, reducing latency problems.
Tight Control This tight coordination between data availability and CPU execution also makes event-driven applications more robust and portable across computers of vastly different CPU speeds. The hardware deployed for real-time applications in Windows is important. Event-driven programming may be necessary but is not necessarily sufficient for some real-time applications. Contrary to what the words might indicate, real time tends to be a relative term, the meaning of which varies with the application and user requirements. In some applications, users consider a response time of 100 ms to be a real-time response. In a different setting, a 1 ms response might be needed. The Windows operating system—whether it’s Windows 95, 98, Me, NT, or 2000—isn’t well suited for fast, real-time applications. Real-time applications tend to work better with dedicated operating systems running on embedded processors. This implies instrument or DA hardware equipped with a digital signal processor (DSP) or microprocessor. The DSP or onboard processor performs many of the functions that would otherwise be performed by the computer’s CPU. The dedicated-DSP or -CPU approach eliminates problems associated with Windows running tasks in the background that aren’t under a user’s control. These background tasks use up CPU clocks and interrupt requests, so the test application must share system resources. Some applications actually perform better when programmed and run on a DOS system, particularly if the hardware and software are designed around the operating system. The design of every operating system (e.g., Windows, DOS, and Linux) attempts to balance conflicting demands but tends to be optimized for certain types of tasks. A test system developer must weigh these tradeoffs. The ultimate selection will invariably involve compromises between flexibility, functionality, ease of use, robustness, and reliability.
Managing Speed and Accuracy Tradeoffs In a typical production calibration system, the application program commands the calibrator to apply a certain voltage stimulus to the device under test (DUT) before measuring its response. Both the calibrator and DUT need a certain amount of time, often seconds, to settle to the required state (stimulus or response) before the program commands a measurement. If that amount of time isn’t accounted for in the program, the calibration process will be inaccurate.
Typically, programmers hard-code wait times, so this isn’t an issue. But in production tests where throughput is critical, there’s a downside: the wait time can be longer than is actually needed. Rather than hard-coding a specific wait time, the programmer can create an algorithm that uses feedback from a calibrator (an instrument-ready bit) to acknowledge that the stimulus voltage level has been reached. This means the program can proceed to the DUT response measurement. The measuring instrument can provide a similar signal after it’s acquired the data following a delay, based on its own internal program. This type of programming approach results in higher production rates. Mark Cejer is Test and Measurement Marketing Manager, Keithley Instruments, Inc., 28775 Aurora Rd., Cleveland, OH 44139; 440-248-0400, fax 440-248-6168, mcejer@keithley.com.
|
|
|
|
|