Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple tasks in multi threads

Solved!
Go to solution

I have an application which needs to be capable of outputting and capturing from multiple NI devices simultaneously.

 

I have coded it such that each nidaq task contains only capture ports for a single device or output ports for a single device. I.e. if I'm using two devices DevA and DevB for capture and output I'l have four tasks capture devA, capture devB, output devA and output devB.

 

Currently each task runs in its own thread, taskstart is only called when all threads are ready to proceed (each thread starts up its own task).  AO1 is looped back to AI0 on devA so that the output is captured by the same device.

 

Unfortunately repeated captures show a variable phase shift in the AI0. The captured waveform is often shifted left or right by as much as 1000 samples @48 kHz.

 

Could this problem be alleviated by peforming the capture and playback across all channels and devices in a single thread (sequential input and output) or would the random shift still exist?

 

Basically I'd like to perform sample accurate input and output.

0 Kudos
Message 1 of 8
(4,574 Views)

Also, is it possible to combine AI and AO ports in a single nidaq task>

0 Kudos
Message 2 of 8
(4,562 Views)

According to this:http://www.mathworks.in/help/daq/synchronize-analog-input-and-output-using-rtsi.html for inputs and outputs on the same device it's possible to start capturing as soon as playback starts. I can't figure out how to set this using the C API: 

ai.ExternalTriggerDriveLine = 'RTSI0';
0 Kudos
Message 3 of 8
(4,557 Views)

A DAQmx task can contain channels of the same type, so analog input and output channels cannot be grouped together.

 

The resource your posted discussed using the RTSI bus. This hardware synchronization method uses RTSI cables to connect different devices. More information on RTSI synchronization can be found at the following link:
http://digital.ni.com/public.nsf/allkb/A120195AAAA9222A86256C69007C8B27

 

What data acquisition devices would you like to synchronize?

Cameron
0 Kudos
Message 4 of 8
(4,521 Views)

Hi

 

Thanks for your reply.

 

At the moment I'm trying to synchronise ai and ao on a single USB-4431. Since each capture/generate task is separate they start up at different times.

 

I tried the VC_SynchAI_AO example and it didn't work prevously but does now. I guess that's the way of doing it.

 

Could this be extended to multiple USB-4431 and NI-9234 devices?

 

Thanks

Nirvtek

0 Kudos
Message 5 of 8
(4,518 Views)

Also is it possible to sync using the internal RTSI bus in the USB-4431 or does that not exist in this device?

 

It would be useful if multiple such devices could be synched, using the same code.

0 Kudos
Message 6 of 8
(4,508 Views)
Solution
Accepted by nirvtek

If you are interested in syncing multiple USB-4431 devices, then you will have to use another type of device to output a triggering signal.

 

Although the USB-4431 has Digital I/O Lines, they can only be used to import start or reference triggers (see page 9 of the following manual):
http://www.ni.com/pdf/manuals/372485e.pdf

 

Due to this limitation, you will have to use an external trigger source to synchronize multiple USB-4431 devices.

 

For large synchronization applications, I recommend investigating the PXIe system. A PXIe chassis full of NI PXIe-4499 modules can support the synchronization of up to 272 channels. More information about synchronization can be found in the following Developer Zone article:
http://www.ni.com/white-paper/11369/en/

Cameron
Message 7 of 8
(4,482 Views)

Thanks, that answers my question.

0 Kudos
Message 8 of 8
(4,461 Views)