Simplifying Data Acquisition
Depending on your needs, free, shareware or a commercial application may get you to your goal
![]() The RELACS gui from their Web site displaying the system’s four main widgets |
In the not-so-distant past, we discussed the need to interface analytical instruments with various types of data systems, such as chromatography data systems (CDS) and laboratory information management systems (LIMS).1 Others have discussed some of the advances made in data acquisition systems.2,3 However, there are times when you want to acquire data from systems on more of an ad hoc basis.
At times like this, things can get a little dicier, depending on exactly what you are trying to do with the data and the format in which it is being presented. If it’s coming out of the instrument as a simple ASCII string, this may not be a big deal; you can probably capture it with a terminal emulator or a simple Perl or Ruby script. However, if the information coming out is binary data, perhaps even with a required transaction handshake, things can quickly become much more complicated.
While it is always possible to write your own data acquisition system from scratch, it generally requires you to know details regarding the protocol used by the specific data acquisition cards (DAQ) you have. This can create issues if you don’t have this information, or need to potentially support multiple cards with different interfaces. Fortunately, there are some alternate approaches that you can take to reach your goal which, after all, is to actually capture data (it’s all too easy to lose site of the actual target when you get immersed in a software development project).
In many cases, you can go to the Web site of the vendor that manufactured the DAQ card used in the system and download some basic data acquisition software from there. Many vendors have at least a basic data acquisition package available for free, others charge for it, though even they usually have a trial version that you might be able to use to acquire the data you need. Examples of these include DataqSDK 1.0 (beta) the data acquisition Linux package4 from DATAQ Instruments and Windmill Standard Software Suite5 from Windmill Software. One of the downsides to these applications is that they generally only support the DAQ cards from that manufacturer. If you have cards from different manufacturers, you will likely need to have separate data acquisition programs as well.
For those willing to raise the banner of open source software, there are a few notable exceptions to this rule. The most prominent of these is Comedi project (control measurement device interface), launched in 1996 by David Schleef.6 This is not a data acquisition application itself, but could better be described as a library of drivers providing a common application program interface (API) to a range of DAQ cards for use under Linux. Technically, these drivers are implemented as a core Linux kernel module. For the moment, this means that you will have to compile the Comedi source code with the kernel source, as I have yet to locate a Linux distribution that already has Comedi installed in it.
Because of the way that Linux is designed, programs fall into two classes regarding the system resources they can access. Privileged processes are allowed full access to the system kernel, its data structures and the system hardware. Non-privileged processes, which are said to run in user space, are not allowed direct access to the hardware, nor can they directly modify the kernel or each other. As a result of this partitioning, device drivers, or at least a component of them, must run as privileged processes, as they normally do need to access the system hardware to perform their function. As the actual data acquisition application normally runs in user space, an interface between these two zones is required. Within the Comedi project, the privileged driver package in kernel space is called Comedi, while access from user space is handled by comedilib. There is an additional project component called Kcomedilib that can also be installed in the kernel that provides the same functionality as comedilib for those instances where real-time functionality is required.7 Currently, there are over 400 different device drivers available under the Comedi project, though not all of them are for monitoring analog signals.
For data acquisition projects where real-time data acquisition is required, you also need to modify the Linux kernel you are using to include support for real-time processing by patching it with something similar to the community developed real-time application interface (RTAI) for Linux from the Dipartimento di Ingegneria Aerospaziale, Politecnico di Milano (DIAPM).8 This software provides a hardware abstraction layer and various tools to simplify the handling of the strict timing constraints involved in real-time programming. While both the Comedi and RTAI sites include installation instructions, you can find additional support and tutorials on the Web.9
Of course, once you have the required software packages installed, you still need to have an application to actually take advantage of them and acquire the data. Your options here depend in part on exactly what you want to do with the data. Saving it to a file or database is one thing, applying any highly complex filtering to it as it is captured is quite another. For the later, you may need to write your own set of applications. This would most commonly be done using either C or C++, however, bindings allowing you to take advantage of Comedi using Perl or Python, and perhaps other programming languages, also exist.
If your real-time data processing needs are not as severe, or if you can deal with applying post processing, then you might be able to take advantage of some of the data collection applications that have been built on top of Comedi. While it was actually designed to capture closed loop electrophysiological data, an excellent example of an application using Comedi is the open-source relaxed electrophysiological data acquisition, control and stimulation (Relacs – pronounced “relax!”).10 This application can both generate an electrical stimulus and monitor for the response, but it can be configured to just monitor as well and appears to be highly flexible. You can find a list of some of the other projects that incorporate Comedi on the Comedi Web site.
Depending on your exact needs, you may well find an exact match for what you are attempting to do on the Web, whether free, shareware or a commercial application. However, in terms of the flexibility of the DAQ cards you can use, it would be very hard to beat Comedi if you end up having to build something yourself.
References
1. Joyce, J.R. “Instrument Interfacing: Some Observations and Reflections.” Scientific Computing (2010). www.scientificcomputing.com/articles-IN-Instrument-Interfacing-Some-Observations-and-Reflections041610.aspx
2. Lutz, T. “Interfacing laboratory instruments to a TCP-IP network.” Scientific Computing (2008).
www.scientificcomputing.com/interfacing-laboratory-instruments.aspx
3. Lutz, T. “How to Set Up a Wireless Connection.” Scientific Computing (2008). wwwscientificcomputing.com/how-to-set-up-a-wireless-connection.aspx4. “Data Acquisition for Linux.” DATAQ Instruments www.dataq.com/products/software/linux
5. Windmill 4.3 Data Acquisition Software Catalogue. www.windmillsoft.com/acatalog/A000_0.html#acquisition
6. Tennis, C. “Data Acquisition with Comedi.” Linux Journal 6 (2004). www.linuxjournal.com/article/7332
7. Comedi – Control and Measurement Interface. www.comedi.org
8. RTAI – Official Website. www.rtai.org/index.php?&MMN_position=1:1
9. How to install RTAI, ComediLib in Ubuntu 8.10, Ubuntu 9.04. www.ngohaibac.com/how-to-install-rtai-comedi-in-ubuntu-8-10-ubuntu-9-04
10. RELACS … Relaxed Electrophysiological Data Acquisition, Control, and Stimulation. RELACS … enjoy your recodings (2010). relacs.sourceforge.net/index.html
John Joyce is the LIMS manager for Virginia’s State Division of Consolidated Laboratory Services. He may be contacted at [email protected].