From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronize the AI reference clocks on multiple modules in .NET

I have been able to synchronize multiple DAQ cards in a PC as well as a PXI chassis.  This is the first time I have had to do this using Compact DAQ.  I am programming in .NET and needed to know how to synchronize multiple clocks using cDAQ.  All examples I have been able to find are all LabView.

 

Here is how I've done this in the past. 

Multiple DAQ cards in a PC chassis with an RTSI cable.  Use the "OnboardClock" of one of the cards as the AITask.Timing.ReferenceClockSource.  For any other cards, you set their ReferenceClockSource to the first ReferenceClockSource.  

 

Multiple DAQ cards in a PXI chassis.  Use the "PXI_Clk10" as the  AITask.Timing.ReferenceClockSource.  For any other cards, you set their ReferenceClockSource to the first ReferenceClockSource.

 

How does the cDAQ work with on board clocks like individual cards in a PC chassis, or more like a PXI chassis with a specific clock for synchronization? I haven't found much documentation on this.

 

Any help is greatly appreciated.

 

Mike S.

0 Kudos
Message 1 of 13
(3,389 Views)

Is there a specific reason you're approaching sync via Reference Clocks?  I've done a lot of multi-device timing and synchronization, and have only rarely resorted to doing any of it via Reference Clock.

 

I've found that usually when things need to be sync'ed, their data also needs to be correlated.  Thus, syncing via Sample Clock alone has often proven sufficient.  Triggering is sometimes also needed, but less often than people seem to think.

 

All that said, I can't give any great detailed specific advice about the cDAQ platform.  I just wanted to raise the question of whether the use of *other* timing signals might give you an alternative method to get sufficient sync.

 

 

-Kevin P

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 13
(3,375 Views)

The only reason I've used Reference Clocks is that the sample source code examples I've used in the past have used reference clocks and it definitely works.  I'm not opposed to using Sample Clock syncing.  Just would like to see an example to make sure I have all properties in the task covered properly. 

 

 

0 Kudos
Message 3 of 13
(3,373 Views)

If you're just looking for examples in .NET, there should be some installed with DAQmx if you navigate to Start » All Programs » National Instruments » NI-DAQmx » NI-DAQmx Examples » .NET[version].

CH
Applications Engineering
National Instruments
http://www.ni.com/en-us/support.html
0 Kudos
Message 4 of 13
(3,338 Views)

I've done that and find synchronization examples all have different series of AI cards (M, E, M PXI, DSA Sample Clock and DSA Reference Clock).  There is no C series example in the AI Continuous acquisition code.  What I have explained in my original post was the M series and the M series PXI examples.  I have made those work great, but they don't cover this latest series of DAQ modules (C series).  I know I can't use it as an M series device because I've tried that and it gives an error.  I've been trying to experiment and have not been able to make things work with two devices getting data at the same time.  Even if the clocks are not the same.

0 Kudos
Message 5 of 13
(3,335 Views)

You will likely just want to use sample clock synchronization. For more information, see section 3 here: http://www.ni.com/white-paper/11369/en/

 

In general, you will simply just want to share a sample clock between multiple tasks with the DAQmx Timing function. If you have many tasks,you will likely want one task to act a master and the rest act as slaves (i.e take care to start tasks in the correct order). Here is a LabVIEW example of synchronizing a digital output task with an analog output task: http://digital.ni.com/public.nsf/allkb/EBD603683446EC13862575B3006A63A2

 

I would look over that architecture and just try to apply it to .NET with appropriate function calls.   

CH
Applications Engineering
National Instruments
http://www.ni.com/en-us/support.html
0 Kudos
Message 6 of 13
(3,331 Views)

I'm missing something because I keep getting this error when I attempt to start scanning the devices (see attached file).  It is the slave device (cDAQ1Mod2) that is attempting to reference the master device (cDAQ1Mod1).  When I start the slave task first, I get this error.  Any tips on where to go from here? 

 

 

0 Kudos
Message 7 of 13
(3,326 Views)

Hmm, this is for VB but found this: http://digital.ni.com/public.nsf/allkb/E88C1861990F0DFE8625714F007517CF

 

Seems like a syntax error. Make sure you are typing that source terminal name in the correct format. I don't think that terminal should have any problem being routed. 

CH
Applications Engineering
National Instruments
http://www.ni.com/en-us/support.html
0 Kudos
Message 8 of 13
(3,324 Views)

Here is the code specifically:

 

m_AITask.Timing.ConfigureSampleClock(clockSource, ScanRate, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, Convert.ToInt32(ScanRate));

 

Where the clock source for the master is "", and for the slave it is "\cDAQ1Mod1\ai\SampleClock"

Do I have to call out the cDAQ device (cDAQ1) as opposed to the module (cDAQ1Mod1)?  Or do I have to call out them both (\cDAQ1\cDAQ1Mod1\ai\SampleClock)?

0 Kudos
Message 9 of 13
(3,322 Views)

I don't have much experience with DAQmx in C#, so I won't be of too much help. I believe it should be forward slashes and not back slashes, though?

CH
Applications Engineering
National Instruments
http://www.ni.com/en-us/support.html
Message 10 of 13
(3,318 Views)