Abstract
Data acquisition (DAQ) technology plays an important role in a variety of disciplines including health monitoring in medical treatment and research, factory infrastructure monitoring, off-vehicle testing of transmission controls, etc. At the lowest level of detail, these applications typically require sampling of the continuously moving input analog signal which for example may be cardiac condition of a patient or simply sound generated by a machine on a factory floor. The acquired samples are stored on to non-volatile storage device like disk or flash memory for further offline analysis. The frequency at which the samples are collected i.e, the sampling frequency determines the quality of the reproduced analog signals and the subsequent offline analysis. Performing deterministic, accurate and sharp sampling will require a hard real-time operating system in place. In this paper, we present the details for application development in RTLinux for a specific DAQ board. We also demonstrate how RTLinux [1] excels in accomplishing the required data acquisition performance and compare it with the performance of bare Linux through a series of experiments.
1 Introduction
A DAQ system typically consists of a data acquisition hardware board, a host processor, a storage device, an operating system driving the host processor and a driver software to interact with the DAQ hardware board. In this paper, we use the PowerDAQ PD2-MFS data acquisition board. The PowerDAQ board in turn consists of three major subsystems namely, Analog Input (AIN) subsystem, Analog Output (AOUT) subsystem and the Digital Input-Output (DIO) subsystem. Each component performs its own functionality and each can be operated by different independent applications without affecting the other. The following is a brief description for each of the subsystems:
AIN is the most important subsystem for typical DAQ applications. We take a closer look at its interaction with the applications. As soon as the AIN subsystem writes the samples into its FIFO buffer, it is up to the sampling application to read out the values from the FIFO before the data is overwritten by the subsequent samples. The sampling application invokes the PowerDAQ driver to get the samples from the FIFO to the host’s memory so that samples can be used for further offline signal reconstruction and analysis. In order to be able to perform offline reconstruction of the input analog signal, the sampling application makes several such invocations periodically. The frequency of these invocations is the sampling frequency and it determines the quality of the reconstructed signal.
For a given input analog signal, there is a minimum sampling frequency defined by the sampling theorem. In its simplest sense the sampling theorem states that, in order to sample and reproduce an analog signal of highest frequency f, the sampling frequency should be at least 2f. For example, in order to reproduce a square waveform of frequency 1KHz, the sampling frequency should be at least 2KHz. In other words, a sample should be collected for at least in every 500 microseconds. We call this as inter-sample period in the rest of the paper.
Given the sampling theorem, in order to achieve good sampling quality the operating system should support short and deterministic timing facilities of the order of few microseconds depending on the input signal. Our experiments show that RTLinux can support an inter-sample period as small as 35 microseconds while the bare Linux fails to get any closer to that. Before getting into the details of the experiments, we present the application development details in RTLinux using the PowerDAQ board.
The rest of the paper is organized as follows: in section 2, we present applications using the AIN and AOUT subsystems. In section 3, we present the details of our experimental setup and the results comparing the quality of digitization in RTLinx versus Linux. We present our conclusions in section 4.
2 Applications
Applications over the PowerDAQ in RTLinux use one or more of the PowerDAQ subsystems described in section 1. The general structure of an application program using a subsystem SA is as follows:
Where SA could be one of the three PowerDAQ subsystems. We present the details of the exact interfaces through two specific applications using AIN and AOUT subsystems. A typical RTLinux application may insert the code for the above five steps in the real-time thread’s code area.
The following subsection presents the SingleAI application details which uses the AIN subsystem to perform a single scan of the PowerDAQ FIFO periodically. We present an application (SingleAIAO) using both the AIN and AOUT subsystems in section 2.2.
2.1 Using the AIN subsystem
The goal of the SingleAI application is to trigger sampling on the AIN subsystem and acquire the samples stored in the FIFO periodically and store them on to the memory possibly for offline signal reconstruction.
The following are the necessary PowerDAQ board specific calls involved in the SingleAI application in that order.
2.2 Using the AOUT subsystem
The AOUT subsystem of the PowerDAQ board can be used for writing digital values of a signal to generate an analog signal on the output lines. In this section we present an application called SingleAIAO which uses both the AIN and AOUT subsystems. The goal of the SingleAIAO application is to digitize an analog input signal using AIN subsystem and reproduce the analog signal onto the analog output lines using the AOUT subsystem. Since we discussed the details of handling the AIN subsystem, in this section, we assume the digitized values are available in an array variable called buffer.
The following are the necessary PowerDAQ board specific calls involved in the part of the SingleAIAO application which writes the values available in the buffer to the analog output lines.
3 Experimental setup
Figure 1 shows the schematic of our experimental setup. It consists of the following components: signal generator, PowerDAQ data acquisition hardware board, AMD Opteron host processor and an oscilloscope to check the input signal. We present a brief description of the components in the following:
Using the above experimental setup, we conducted several experiments to demonstrate the sampling quality offered by RTLinux as compared to that of Linux. We present our results in the following section.
4 Quality of Digitization: RTLinux vs Linux
In order to compare the sampling quality offered by the two operating systems, we conducted four experiments. In each experiment, a square waveform of different frequency was generated by the signal generator and routed to the PowerDAQ board. Figures 2, 3, 4 and 5 show the reconstructed signals for different input frequencies.
In figure 2, the input square waveform is of 50Hz frequency, according to the sampling theorem the required inter-sample period is 20 milliseconds. RTLinux generates a very accurate reconstruction of the input signal. On the other hand, Linux cannot produce such an accurate reconstruction, although the signal can be reconstruced with a tolerable distortion. Similar observations can be made when the input frequency is increased to 100Hz as shown in figure 3.
However, when the input frequency is further increased to 1KHz Linux completely fails to perform any reasonable sampling and the reconstructed signal completely misses out the input signal as shown in figure 4. According to the sampling theorem, the required inter-sample period is 1 millisecond and Linux cannot provide such sharp timing. On the other hand, RTLinux can provide short, deterministic timing guarantees and hence it could still reproduce the input waveform accurately. Similar observations can be made with 2KHz input square waveform signal as shown in figure 5.
5 Conclusions
In this paper, we gave a tutorial of how to develop RTLinux applications using the data acquisition PowerDAQ hardware board. We also demonstrated the quality of digitization offered by the RTLinux and compared with that of the Linux. Our experiments show that the RTLinux with its hard real-time characteristics excels in achieving the excellent digitization of the input signal while the bare Linux fails to reconstruct the signal for frequencies higher than 1KHz.
6 Figures

Figure 1. Experimental setup

Figure 2. Digitization of the input analog square waveform of frequency 50Hz

Figure 3. Digitization of the input analog square waveform of frequency 100Hz

Figure 4. Digitization of the input analog square waveform of frequency 1KHz

Figure 5. Digitization of the input analog square waveform of frequency 2KHz