Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

multithreading and daq acquisition

I�m trying to run 2 DAQ�s (PCI MIO 16 XE) devices in one PC (Win XP) to acquire N-data samples from 5 AI channels each using LV 7.0. For the acquisition to starts, each device is independently triggered (5KS/s) . It works fine and I can get the data. The problem is that the second DAQ starts the acquisition probably only after the first has finished its acquisition. (I cannot be sure about that because actually I do not know how to get the start time of an acquisition). At least the DAQ�s are starting the acquisition at different times and this could be a problem if the time difference is to big( >500 micro seconds).

1. is this a classical Multithreading problem? Is there a solution?
2. how can I assure that both DAQ�s start
the acq. nearly at the same time?
3. how can I get the start time of the Acq. ?
4. if I have to use 4 DAQ�s on one PC will this work? Known problems?

Thanks

Alberto
0 Kudos
Message 1 of 9
(3,596 Views)
Are you using NI-DAQmx or Traditional NI-DAQ?

Regardless,

1. Assuming all devices are started and waiting for their triggers, multithreading should not affect when each device is triggered.

2. You mentioned that each device is independently triggered. If you actually want both devices to be use the same start trigger, you can configure each task's start trigger to be the same external signal. For a more accurate solution, you can configure one device send its start signal to the other device to be used as its start trigger. The NI-DAQmx example "Multi-Device Sync - Shared Timebase & Ext. Dig. Trigger" illustrates this approach (it also synchronizes the timebase between the two devices).

3. If accuracy isn't critical and you start to read the samples b
efore the acquisition is complete, the t0 timestamp in the Waveform Data Type provides this information. If you don't read samples before the acquisition is complete, the t0 timestamp will not be accurate. If accuracy is more critical, you could use a counter to measure the time elapsed after the trigger.

4. Nothing comes to mind, but I haven't tried.
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 2 of 9
(3,596 Views)
Thanks for your replay.

I have to use external independent triggers for each DAQ device. Using traditional DAQ and triggering the devices with one trigger only (for testing) I get a delay time in the timestamp between both devices of about 500-900 milliseconds. This is too much for my application. I�m just looking for a way to let the devices start the data acquisition nearly at the same time. By the way, do you know the consequences of using an interrupt instead of DMA?

Due to your question, I tried for the first time, DAQmx with better results, I think. But I have to do additional tests when I get the 4 devices. In the case you have any new idea, it is always welcome.

(being a beginner is not that easy, I�m afraid..)

Thank you again.
0 Kudos
Message 3 of 9
(3,596 Views)
The timestamps are probably off. The device detects the start trigger without any intervention from software. The timestamps are determined based on when you start reading samples and, using the sample rate, are adjusted back to t0. Therefore, if you start reading after all samples have been acquired, the timestamp will not reflect the moment when the trigger was detected and the acquisition started.

Using either interrupts or DMA as a data transfer mechanism should be fine. DMA is probably more efficient. Neither will have an effect on the trigger being detected.
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 4 of 9
(3,596 Views)
Unfortunately, this is correct. The timestamps come from when the AI Read VI starts to read data from the buffer that the DAQ card is streaming into. Although it shows a delay between the readings, if they are triggered from the same trigger, there will be no delay.

A simple way to test this is to put a sine wave into a channel on both cards. Use the same trigger into both, and then look at the resulting waveforms. They should be identical, meaning no delay, even though the timestamp says they are delayed.

Mark
0 Kudos
Message 5 of 9
(3,596 Views)
Let me try to explain my problem using the DAQmx example VI �Cont Acq&Graph Voltage-Ext Clk- Dig Start.vi�.

Making few changes to the above VI, you can use it as a Sub-Vi. ( I also limited the number of scans to 1000). I used 2 PCI MIO 16XE-10 devices and wrote a program using two of this sub.vi. I used one trigger signal and one clock for both devices and scanned the same channel. As input I used a Sinus voltage. After the program runs, If I plot the obtained data time independent, i.e the x-axis is now the scan number rather than time (relative or absolute) I get a shift in the signals of about 90 clocks, this means that for example, the scan position for the max amplitude came for one device 90 clocks later than for th
e first device. This is unacceptable for my application

In other test , If I just did copy the block diagram of the example in a new VI twice and made the necessary changes (trigger channel, channel names, etc). Now I got NO shift in the Graph. Both sinus waves were exactly the same. But I still have no idea about the difference on the start time of both devices. I suppose, in this case both devices started at the same time. But how can I be sure of that?

Without the possibility of using that Sub-Vi�s and because I have to use 1, 2 or 4 devices selectively, my program will be looking very complicated. I�m sure there must be a better way to solve this.

Thanks
0 Kudos
Message 6 of 9
(3,596 Views)
Is there any way that you can post your VI to the board? I have a feeling this has something to do with the DAQ thread.

Mark
0 Kudos
Message 7 of 9
(3,596 Views)
Attached find one test file out of a lot of further test which I did. If the input signal is the same for one channel on each card, the arrays have to contain exactly the same data, haven�t they? But this is not the case. May be you find my mistake.

Thank you very much in advance.

Best regards

Alberto Villa
Bremen, Germany
Download All
0 Kudos
Message 8 of 9
(3,596 Views)
The "init_DAQmx_Device" VI appears fine. You didn't include the "Read DAQmx Data" VI, so I can't verify it. If you are providing the same trigger to both devices, ensure that you invoke the "DAQmx Start" VI for each task before providing the trigger.

The samples that you read from each device should be very similar, but not necessarily identical. A number of normal conditions may result in the two devices providing close, but not identical samples. I would send both waveforms to the same graph and visually inspect them. I'm not sure what you were trying to do with the "Index Array" VIs, but maybe that is what you already had in mind.

Hope this helps.
--
Geoff Schmit
Huskie Robotics, FIRST Team 3061 Lead Mentor
http://team3061.org/
@team3061
0 Kudos
Message 9 of 9
(3,596 Views)