The DAQ-ness MonsterPosted: June 26, 2011
I spent a nice chunk of time last week playing with different combinations of hardware and software to look at Data Acquisition (DAQ) options for my Advanced Laboratory course (the name given to standalone upper-division physics laboratory courses). I will first talk about the two main hardware devices I was trying out (National Instruments USB-6009 Multifunction DAQ and an Arduino Uno microcontroller) and then look at some combinations of software and hardware that I played with, or at least wanted to play with.
In the end using one of the National Instruments USB DAQ devices with LabVIEW is probably the easiest thing to do thanks to the variety of ways that LabVIEW allows you to quickly create DAQ software on the computer side. But thanks to the huge number of software options that you have to talk to the Arduino and how cheap it is, it is very reasonable to use an Arduino as your general purpose DAQ device.
An example DAQ task
In case you are reading along at home, but not too sure what I’m talking about, I will give you an example DAQ task that uses some of the functionality that is discussed in this post. Let’s say you want to do an (admittedly boring experiment) of trying to figure out which colour of coffee cup keeps your coffee warm the longest. This is a tedious experiment because it takes a long time for the coffee to cool, you want to do multiple runs for each coffee cup and you don’t want to have to just sit there and heat the coffee up over and over again. So you build a circuit with a little heater that can be turned on and off by sending a digital signal to it. You have a thermocouple with which you will measure temperature. And you will have the computer record your data every 10 seconds and write your data sets to file.
So you hook your thermocouple up to a thermocouple amp and that output goes to one of your analog input channels. One of your digital out channels is used to turn the little heater on an off. And you will have some software that does a few different things:
- Requests the temperature of the coffee every 10 seconds from the thermocouple (amp);
- Once the coffee gets down to 50 degrees, it turns on the heater until the coffee is back at 90 degrees;
- It writes all the collected data to a file.
So to run this experiment you just stick the thermocouple and heater in the coffee cup, press go and wander off for a while. You come back every once in a while to make sure everything is running smoothly and to change to a different coffee cup once you feel you have enough runs. With fairly simple software running on the computer, all the hardware/software DAQ combos I mention below will work just fine.
National Instruments USB-6009 Multifunction DAQ
This (and its cheaper cousin the USB-6008) seem like they have been the standard low-cost USB DAQ devices for a little while, and are used most often with LabVIEW. The analog inputs are 14-bit and 48k samples/second. It has 5V out and a bunch of digital Input/Output channels.
Arduino Uno Microcontroller
Arduinos are teeny computers with a bunch of analog and digital Input/Output channels. You write programs for them and send them via USB to the device. With the appropriate program (firmware) you can have your Arduino duplicate the functionality of the USB-600x, but with much less impressive resolution and sample rate. The Arduino analog inputs are only 10-bit and my best estimate of the sample rate is roughly 100 samples per second (edit: you should be able to do better than this if you temporarily store data in Arduino’s memory and then send it to the computer in chunks). Keep in mind that the Arduinos only cost $30 compared to >$200 for the USB-600x (and in my example DAQ task I only needed 1 sample every 10 seconds). That resolution and sample rate are also more than adequate for monitoring and controlling a lot of experiments. You can also use the Arduino as a remote data logger and controller with the help of wireless/bluetooth chips, SD card readers and all sorts of other fun things.
The hardware/software DAQ combos
National Instruments USB-6009 and LabVIEW
This combination seems to be a very common DAQ solution in recent times. I think the standard is about to become LabVIEW + NI MyDAQ, where the MyDAQ is also a Multifunction USB DAQ device. It has fewer channels than a USB-6009 but has 16-bit analog channels, 200k samples/second and an output voltage of 15V as opposed to the 5V of the USB-6009. It also has some neat ready-to-go functionality as a Digital Multimeter and only costs about $200. I think that my pros and cons below for the USB-6009 + LabVIEW combination also applies equally well to the MyDAQ + LabVIEW combination.
- LabVIEW has a lot of built-in and quick-to-get-up-and-running functionality. Graphing, writing to file, signal processing and Input/Output tasks are all quite easy to do once you learn how to do them. As I mention in the cons, you still have to get used to the visual programming environment which is a huge shift in paradigm for many.
- LabVIEW has a DAQ assistant that helps you build DAQ software quickly. They (National Instruments) also have a program called LabVIEW SignalExpress that is meant to make DAQ (and control, like turning on the heater) tasks without having to do any actual LabVIEW programming. I have not actually tried it, but it comes bundled with a $60 suite version of the student edition of LabVIEW.
- LabVIEW is crazy expensive, but the student edition of LabVIEW is only $20 (or $60 for the suite) so if you can get the students to buy their own copies to put on their laptops the cost becomes pretty negligible.
- The USB devices (USB-6008/9 or MyDAQ) are quite reasonably priced ($200-$300), but not as cheap as a $30 arduino.
- LabVIEW has a steepish learning curve. It takes a few weeks to become fluent using it and I still can’t remember how to do half the things I want to do (I am probably at the “few weeks” mark). Visual programming (in this case LabVIEW) is quite a different paradigm than text-based programming.
Arduino and free software
Let’s assume for this discussion that you want to duplicate the hardware functionality of the National Instruments multifunction DAQ devices with the Arduino instead of programming the DAQ task directly onto the Arduino. To do this you write your own Arduino sketch (the name for a program/firmware that you write to the Arduino’s memory) that can read the Arduino’s analog line-ins and send out a digital output signal when told to. There are some existing firmwares (is that the plural of firmware?) such as Firmata (which comes bundled with the Arduino software) and a firmware that comes with the Python Arduino Prototyping API. You can then use Python (for either firmware) or Processing (for Firmata) to collect data and send control signals to the Arduino.
I did not have great luck getting a DAQ task up and running using Python and Firmata, but was delightfully successful doing so using the Python Arduino Prototyping API. With a little vPython in tow I’m sure you could figure out some pretty fun stuff to do with the data coming in through the Arduino.
I don’t know too much about Processing, but it is a computer language and it seems to be quite easy to use it to make graphs based on the examples I played with that come included with the Arduino software. There are some libraries that (I understand) make it very easy to talk to an Arduino with the Firmata firmware using Processing.
- This is the cheapest solution. Python and processing are both free and the Arduino is $30.
- For my example DAQ task, the sample rate and resolution of the Arduino is more than adequate, but the National Instruments USB DAQ devices are really much higher performance which might be needed for experiments more exciting than watching coffee cool.
- I didn’t do more than try to read something in and send out a signal with the Python Arduino Prototyping API so live-graphing the data (easy in LabVIEW) may be simple to get done using matplotlib or it may be quite tedious. I’m really not to sure.
- Similarly for Processing I only graphed some data coming in and sent out some signals (to turn on LEDs), but since it is a programming language it should be very straightforward to do things like write data to file or tell the Arduino to turn on the heater once the temperature being read drops below some certain value.
Note: there are a bunch of other software interfacing options for Arduino but I just mention the ones that seemed easiest for me. Mathematica (which is not free) is discussed below.
Arduino and LabVIEW
Early in May this year the LabVIEW Interface for Arduino was released. I found it easy to install everything needed and the examples that I tried worked on my first try. It comes with a custom firmware that you put on the Arduino and then you can get input and output signals just like you would with the National Instruments multifunction DAQ devices.
- Easy to install everything needed.
- Cheap if you are using the student edition of LabVIEW.
- There’s a nice tutorial and lots of examples.
- You can’t build tasks for interfacing with Arduino using things like LabVIEW SignalExpress or DAQ assistant, but you can build your own VIs and the included examples can serve as a good template.
Arduino and Mathematica
For those that are already familiar with Mathematica (and perhaps not familiar with some of the software solutions above), you just need the M$ .NET framework installed and then you can chat with the Arduino via serial I/O commands from within Mathematica. I’m not sure if you can get Mathematica to play nice with a pre-existing firmware like Firmata. I haven’t used Mathematica much since early in grad school so I am very much at a novice level and can pretty much only do things that require modification of existing code. I did have some trouble getting this whole thing up and running even though Andy Rundquist basically gave me all the code I needed. This was probably mostly due to my novice skill-level using Mathematica.
- Mathematica is very good at displaying data (and then doing fun stuff with it after).
- For those already familiar with Mathematica, there is very little learning curve.
- For this purpose there are much better (and cheaper) software options out there.
Other interesting stuff
- Vernier Sensor DAQ: This thing costs about the same as a USB-6009 with similar performance, but less analog and digital I/O channels. What it does have instead is 3 analog and 1 digital connections for Vernier sensors and probes. I am interested in getting one of these to play around with.
- LabPro toolkit for LabVIEW: Vernier probes usually connect to the computer via a LabPro which has a bunch of connections for the probes and then interfaces with the computer via USB. The computer runs Vernier LoggerPro to read the probes and record the data. The LabPro toolkit allows you to use your probes, attached to your LabPro, directly in LabVIEW. I couldn’t get all of this to work, but I didn’t really try that hard either.
- Pasco ScienceWorkshop Probeware and LabVIEW: This seems to work with only the older ScienceWorkshop probes and not the newer Passport probes. There is an adapter, but I don’t know if that will then let the Passport probes work with LabVIEW.
- NXT Sensor Adaptor: This lets you use Vernier analog probes with Lego Mindstorms. The first thing that comes to mind is to use a force plate as a gas pedal for a Mindstorm RC car. That would be very fun