I have a project that requires reading the following signals:
I have a NI USB-6218. I'm using LabVIEW 2017 SP1.
I'm trying to acquire all of these signals, align their timestamps, and log them to a TDMS file. Currently, I've been editing the "Continuous Measurement and Logging (NI-DAQmx)" project template to work with the different signal types. I have a task for each different data type (total of 3 tasks).
I need to read the analog signals at, about 5kS/s. I would like to align the other signal types to that speed (a total of 25kS/s, right?)
How do I go about aligning each signal to the same timestamps?
Or, maybe a better questions, how can I acquire "Continuous Samples" for the digital and counter tasks?
Solved! Go to Solution.
On your M-series device, neither the Digital task nor the Counter task can generate a sample clock for themselves internally. It needs to be supplied elsewhere.
That will work out fine for you because your Analog task can supply it. Just think of the Analog task as the master, configure Digital and Counter tasks to share the AI sample clock for their task, and then sequence the tasks to make sure you start Digital and Counter before you start Analog.
That takes care of alignment by syncing up your samples at a hardware level. As you save to TDMS, keep in mind that the t0 value for the tasks may not agree, and the Analog is most likely to be closest to the truth.
A few searches related to DAQmx and synchronization should yield quite a bit of detailed info.
Thanks for the advice, Kevin.
I tried what you said. I made the timing source for the digital and counter tasks to be the AI Sample clock (all of them use the same number of samples and sample rate). Then, I made a sequence structure where I started the digital and counter tasks before the analog tasks.
I'm getting the 200077 Error at the digital task timing block.
"Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property"
Requested Value: Sample Clock
Possible Values: On Demand
Is this digital task not compatible with the sample clock?
Also, I should mention, I'm using two tasks for the two digital lines. I was having trouble trying to get both lines into one task. Maybe that's an issue?
Dang! After checking the spec sheet, it appears your USB-6218 is an exception. And not the good kind of exceptional. Most M-series boards support "correlated DIO" the way I described. Yours is apparently a de-featured version that doesn't support it.
As the error text said, it only supports on-demand mode which means you have to poll it in a software loop. I don't know if you can get the speed or timing precision you want or not. But if you can live with it I have a tip for your TDMS storage. Because the timing is likely to be variable, store the DI values as one channel and then store the timing information as a separate channel DI_Time.
P.S. To put 2 DI lines in the same task, right click on the physical channel terminal and pick "Browse...". That'll give you a straightforward way to pick more than one line at a time. (There's also ways to do it with the text syntax of the channel. For example, "...port1/line0:4" designates the range of DI lines 0,1,2,3,4 on port 1. An additional line that wasn't consecutive would need the whole dev/port/line string after a comma delimiter.)
Is the "correlated DIO" explicitly state in the product specs as being disabled? I want to know how you found that, so I can look out for it in the future.
That's fine. I can work with the software loop that I have. I'm also probably going to switch to making a CSV file for easier editing. I like the idea of having a separate channel for timing info. I might try that.
And, to the P.S., I tried that, and I got an error (it was a while ago), but I'll give it another go.
No, "correlated DIO" isn't explicitly stated as being disabled. I just noticed the *lack* of specs that would be present if it was supported. For example, notice "Waveform Characteristics" starting on page 7 of the manual for an M-series PCI-6221.
As to the 2 DI lines in the same task, dunno what error you got or why. It oughta work. Try it out with a known-good shipping example in case the error was due to some other thing in your old code.