Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

ANN: NI-DAQmx Base library wrapper for Ruby language

The National Instruments NI-DAQmx Base C API for data acquisition supports most National Instruments data acquisition hardware. Although it's more limited than the full (i.e. non-Base) API, it also is more portable across operating systems.

I have written a library wrapper for the NI-DAQmx Base library. This lets you write applications in a scripting language (currently only Ruby) that talk to the library. I'm using it for general purpose work with my USB-6009 devices, but it should work with any supported device. The initial focus of this project is support for the NI USB-6008/6009 devices using the Ruby programming language. So some of the API that doesn't apply to the USB-6009 may not be wrapped yet (though I think I covered the whole API).

Library errors that are reported as error codes in C throw exceptions (complete with descriptive strings) in Ruby. You can use Ruby threads to make your life easier; for instance, I have one program at work where I use one thread for continuous analog input, another for analog output, and another for digital I/O. These are synchronized together. There is another thread accepting user input from the command line and performing various actions, and another thread doing data logging.

For an example of the flavor of a program using this wrapper, I have attached the source for an example program that continuously displays analog input voltages and lets you type in values for analog outputs. (Unfortunately, this board doesn't let me use the .rb extension, so I had to use .txt)

I have provided this work as Open Source (under the Apache LIcense 2.0).

I have written the wrapper using the SWIG wrapper generator; SWIG supports a number of languages besides Ruby. I'd love to extend the support to other scripting languages, but this is my first SWIG project and I don't know all the ins and outs of the language yet. As a result, my code is Ruby-specific in places (though it is easy to support other languages). If you'd prefer to have it support (say) Perl, you're welcome to help. (I moved from Perl to Ruby several years ago and haven't looked back.)

The NI-DAQmx Base library is available for Windows, Mac OS X, and Linux, as well as certain PDAs. I have tested the code in its current version with NI-DAQmx Base version 2.20f under Mac OS/X and Windows XP, as well as in an earlier version with Linux.

The code is hosted at Google Code. You can get the source at: http://code.google.com/p/daqmxbase-swig/

For Subversion checkout, do this:

svn co http://daqmxbase-swig.googlecode.com/svn/daqmx

Volunteers are welcome, as (of course) is feedback and bug reporting.

Ned Konz


Message Edited by ned_konz on 02-02-2008 10:14 AM
Message 1 of 1
(3,176 Views)