11-18-2016 03:25 PM
I've developed a little routine to measure muscle twitches using a small triaxial accelerometer. We have a stimulator that produces an excitation pulse to start the recording, which consists of three voltage channels at 1KHz for 400 points.
Our prototype uses an NI USB-6009 Multifunction I/O device, with the TTL Pulse from the stimulator going to the PFI terminal on the 6009. Here is the code to set up the Triax Task:
When we are ready to record, we do a DAQmx Start Task, then do a DAQmx Read (Analog 2D Dbl NChan N Samp), which waits for the trigger pulse, then delivers us 400 data points.
This works fine, but I want to Have My VI and Demo It, Too. The Prototype, with both the 6009 and the pulse generator, is currently "in use", so I decided to take another 6009, hook it up to another accelerometer, and use LabVIEW to "fake" the pulse generator. I tried two things, and neither of them worked.
The first thing I tried was to use a "non-triggered" form of the Task. I modified the Task definition by removing the DAQmx Start Trigger function. I then started the Task, and in a For loop, waited 500 msec and did a DAQmx Read. When the For Loop was set to 1, I got an array of 3 channels, 400 points (as expected). But when the loop was set to 2, the second iteration generated Error -200278, Attempted to Read Sample: 400; Property: RelativeTo; Corresponding Value: Current Read Position; Property: Offset; Corresponding Value: 0.
I don't know what this means nor why it failed, but figured it had something to do with missing a "Restart" signal that had come in on the PFI line. OK, so I'll "add to the Task" by modifying it to include a Digital Out channel that I can toggle on and off to create a TTL pulse I can wire to the PFI line, since I know triggering works. Here's the code:
This, however, immediately generates Error -200559, complaining that I'm adding a DO channel to a task configured for AI lines. [I'd also tried creating a brand new task for DO only, and got yet another error that I figured meant I couldn't have two tasks running in a single USB-6009 -- not illustrated here.]
So I can't get the 6009 to trigger itself, and I can't do multiple Finite Reads without a trigger. Oooh, all this writing has given me an idea -- what if I go back to the Finite Read model, but put a Start Task and Stop Task "around" the DAQmx Read (i.e. inside the For loop) -- would that work?
I'm going to post this here, go do the test, and come back with the results. This will either be Success (and a Solution), or Failure, and a cry for help ...
Bob Schor
Solved! Go to Solution.
11-18-2016 03:34 PM
I have Good News and Bad News -- the Good News is that, indeed, putting the Start Task/Stop Task inside the loop (effectively making the task "Take a single Finite Sample" instead of "Take Multiple Finite Samples when I give you a Trigger") fixes it. I guess that the PFI Trigger "resets" something internally in the USB-6009 -- probably if I read the Manual thoroughly, this would have been all explained.
The Bad News is I've been struggling with this for several days (on and off). Live and Learn.
Bob Schor