Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Using dummy task to synchronize other tasks

Hi,
 
Environment: NIDAQmx 7.4 - ANSI C
 
Is there a way to use a dummy task to synchronize the starting of other tasks?   What I need to do is to make sure that multiple tasks (AIN, CTRs) are simultaneously started.   I was hoping that there might be some way to route the start trigger from the dummy task to a terminal (e.g. RTSI-2) and then have all my other tasks (armed and waiting for a pulse to come along on RTSI-2) start when RTSI-2 pulses.
 
In the past I would setup my counters to gate off of an RTSI pin, and then routine my AIN tasks's sample clock to the same RTSI pin.  I would then start the CTR tasks first, followed by the AIN taks.   This all worked OK until I got a "DMA error" (-20078)  when using E-series cards.  The error text suggests that I need to start the AIN task before the CTR task.  But doing so adds a time skew between the AIN and the counter cards.   I am hoping to circumvent this by having ALL tasks gate off a signal (e.g. RTSI-2), and using a dummy task to pulse the RTSI pin.
 
Is this possible?  If so, can you point me to some documentation on how to do this?
 
Thanks in advance,
 
-bill
 
0 Kudos
Message 1 of 3
(3,377 Views)

Hi Bill,

You can definitely synchronize multiple tasks from a same start trigger. You can do this using the RTSI cable but also you can use the internal signal sampling clocks as start triggers.

First you will have to configure your RTSI in MAX. This can be done by right-clicking on Devices and Interfaces -> NI-DAQmx Devices and choosing Create New NI-DAQmx Device -> RTSI Cable. Then, for each device that is connected to the RTSI cable, use MAX to edit its properties and in the "RTSI Configuration" tab, specify the RTSI cable. This will allow NI-DAQmx to automatically route signals of the RTSI cable.

Actually, the discussion forum http://forums.ni.com/ni/board/message?board.id=250&message.id=9743&requireLogin=False explains in detail how setup the time bases and synchronize the each of the tasks using the DAQmxGetMasterTimebaseSrc function. Please also refer to synchronization examples in the C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Synchronization.

 

Also, if you decide just to use the internal sampling clock option, when you set up the timing for the task by using the function DAQmxCfgSampClkTiming(), for the source parameter you can specify the same start trigger for all tasks (for example Dev1/ao/Start trigger). Daqmx will automatically synch the start of all tasks once the source is specified.

 

Regards,
Natasa
0 Kudos
Message 2 of 3
(3,360 Views)

Hi Natasa,

Thanks for the reply.  Actually, I was able to solve the problem after I stumbled onto a property called "DAQmxSetStartTrigDelay()".  I actually *had* setup all the items you'd suggested, but the problem I was a "chicken-and-egg" situation.  I needed to use CTR0 and CTR1 on my E-series (6033E) card for buffered acquisition, but I was getting an error (-200078) that suggested (because of DMA issues) that I needed to "start my AIN tasks before I start my CTR tasks, or not use CTR0".  The problem was, if I started the AIN tasks first, the CTR tasks were "behind" by about 30 milliseconds or so because  the CTR tasks depended on exported sample clock timing signals from the AIN tasks. 

My solution (and I don't know if it's the RIGHT solution, but it did work) was to use the ""DAQmxSetStartTrigDelay()" feature on the AIN task.  This allowed me to start the AIN task first (which really just seemed to "arm" it because it's actual start would be delayed), and the delay gave me enough time to start the CTR tasks.  When the delay expired, the AIN task started up automatically, and because the CTR tasks were hooked up to the expoted timing signals from the AIN task, the entire system came up synchronized, with the counters in lock-step with the AINS, and with no DMA errors.

Thanks for your reply!

 

0 Kudos
Message 3 of 3
(3,350 Views)