04-13-2018 09:10 AM
Hi everyone,
I am trying to sample multiple analog inputs arriving at different points in time, after a 2kHz trigger signal. the first analog signal comes directly after the trigger and another analog signal comes about 30 us after accompanied by a digital data ready signal. The DAQ i am using for this is a NI PCe-6321.
The current method i am using is creating two separate tasks and unreserving/starting those in a loop according to the following example i found.
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000PA7XSAW
The problem i'm having with this method is that it takes about 33 ms (300 Hz readout) to finish sampling the two channels. This is far below my 2kHz trigger signal which means i'm not receiving all my data. So i was wondering if anyone has a method of speeding this up or another acquisition method completely.
04-13-2018 09:54 AM
@Arkonder wrote:
The current method i am using is creating two separate tasks and unreserving/starting those in a loop according to the following example i found.
Don't do that. Just use a single task with both channels and read enough data to see the reaction of both signals.
04-13-2018 10:05 AM - edited 04-13-2018 10:05 AM
Thanks for the quick reply!
I am going to try to measure it all with one single task. Do you maybe know a way to correlate the second analog input to the data ready signal, or to possibly place a delay between the signal acquisition?
04-13-2018 11:20 AM
The simplest thing would be to wire in the digital signal to be a 3rd analog input channel in the same task. The only notable downside is that you'll be reducing your max sample rate from ~125 kHz with 2 channels to ~83 kHz with 3.
There are a couple other options that would require some special setup to hardware-sync your analog task to a digital or counter task. It isn't terribly complicated, but there are a few specific details that need to be done right and I'm not at a LabVIEW machine to illustrate now.
First try bringing in the "data ready" digital signal as a 3rd AI channel. Get this much to work. Later, if you *really* need better time resolution than the 12 usec you get at the max sample rate of 83 kHz, write back and we'll take it from there.
-Kevin P
04-16-2018 08:59 AM - edited 04-16-2018 08:59 AM
Thanks Kevin, sorry for the late reply.
At the moment my program reads all my channels one at a time in a series. I do this, because I noticed that the data from a previous trigger is still readable trough a sample & hold chip. The plan right now is to also make another sample & hold for my other signal and to solve it this way.
I have attached my current program.
04-16-2018 09:31 AM
Now that I've had a chance to look at your code, I strongly suspect you have some misconceptions about how to best use your DAQ device's capabilities.
I'm not entirely clear on what the needs are for this measurement app, but I can almost guarantee that "hardware-timed single point" is not the best choice for sampling mode. I'd only consider that mode for an output task in a tight control loop, and even then, usually only if running Real-Time.
You're simply accumulating and processing your data, and I see no obvious advantage to doing it 1 sample at a time. You'll be much better off with a continuous sampling task where you read many samples per loop iteration. A typical starting suggestion is to read about 0.1 sec worth of samples per iteration.
-Kevin P
04-16-2018 09:38 AM
I use the hardware timed single point, because the timing is pretty tight. When I have an extra sample & hold chip I will make it a retriggerable function with finite samples per trigger.
I do this, because I want to make sure that there aren't any missed laser shots or data associated with the wrong shot.
04-16-2018 10:29 AM
But you're actually much *more* likely to miss data using hw-timed single point because then you also depend on the software loop iteration speed keeping up with the "laser shot".
With continuous (or finite) sampling, DAQmx will do most of the dirty work for you. In those modes, a data buffer is allocated for the task and DAQmx keeps pushing samples into it. This allows your application to retrieve data from the buffer in larger chunks but at a more leisurely rate such as 10 Hz. In finite sampling mode, you can even wait for the whole buffer to fill and then read all of it at once without a software loop.
Take a look at shipping examples for finite and continuous acquisition and you'll see the notable *absence* of the use of hw-timed single point. You'll also find that the app has no problem keeping up with the board's max aggregate sample rate of 250 kHz.
-Kevin P