Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Export and import sample clock on cDAQ-9188 in C#

I've inherited 'the acquisition project from Hell'. Originally the project used one cDAQ-9188 filled with 9237 devices sampling data at 2.5ksamples/sec. We now have added a second cDAQ-9188 fulled with 9203 devices that we are running at 100 samples/sec. I can set up two tasks to collect continuous samples from the two 9188 chassis just fine, but now I want to synchronise the sample clocks by exporting the 2.5k samples/sec clock from one chassis and importing it then deviding it by 25 to generate the semple clock for the second.

 

Exporting the sample clock from the PFI0 connector on the the first chassis seems to work with:

 

Task1.ExportSignals.ExportHardwareSignal(ExportSignal.SampleClock, "/cDAQ1/PFI0"); 

 

and the 2.5kHz pulse stream appears on PFI0, but importing the clock in on PFI0 on the second device and dividing it down (and looking for it on PFI1) by using:

 

Task2.Timing.SampleClockTimebaseSource = "/cDAQ2/PFI0";

Task2.Timing.SampleClockTimebaseDivisor = 25;

Task2.ExportSignals.ExportHardwareSignal(ExportSignal.SampleClock, "/cDAQ2/PFI1");

 

returns an "Internal Software Error occurred in CPP_API software. Please contact National Instruments Support.

Requested Code: -213706" error when:

 

Task2.Control(TaskAction.Verify);

 

is used to verify the setup.

 

Is this the correct way to import a sample clock in C# (.NET 3.5)? I've looked at the NI .NET examples but they don't seem to cover this particular situation, therefore some pointers as to how to set up an 9188 to use a divided down external signal as a sample clock would be appreciated.

 

Regards,

0 Kudos
Message 1 of 5
(4,382 Views)

Hi Malcolm-

 

That error usually presents itself when some operation requires a "critical mass" of properties/values and one or more isn't set.  I haven't tried this, but I thought I'd throw out a suggestion in case it helps you get back on track more quickly.  Try setting the SampleClockTimeBaseRate property to the same rate you specify in your master task.  And, rather than setting the divisor directly, just set the sample clock rate using the DAQmx Timing functions.  The divisor will be set implicitly if you specify the TimebaseRate and sample clock rate.

 

And, by the way, don't worry about Exporting the second sample from PFI0 to PFI1- you can simply indicate the timebase signal source (<slaveChassis>/PFI0 in your case) and its rate and divisor and DAQmx *should* make the rest of the magic happen in hardware.

 

Hopefully this helps-

Tom W
National Instruments
0 Kudos
Message 2 of 5
(4,380 Views)

Tom,

 

Thanks for the rapid response!

 

With a bit of additional debugging I've found that adding:

 

Task2.Timing.SampleClockTimebaseRate = 2500

 

also supplies the necessary 'critial mass' of data to set up the timer and my code now runs correctly, with the second task (using the external clock) being supplied with buffers of data at the correct intervals and a 100 samples/sec signal being generated on PFI1 locked to the 2500 sample/sec signal for me to view on the scope as a check.

 

My next task is to ensure that both units start consistently at the same time. I'm not actually too concerned about sample skew between the chassis as I can measure and remove that later as long as it is consistent. I'm thinking that consistent starting is achieved by exporting and importing the StartTrigger signal on PFI1 after removing my

 

Task2.ExportHardwareSignal(ExportSignal.SampleClock, "/" + device + "/PFI1");

 

'debug' line for viewing the signal on the scope. Right?

 

Thanks again for your assistance.

 

Malcolm  

 

 

 

0 Kudos
Message 3 of 5
(4,376 Views)

Hey Malcolm-

 

That should do the trick.  Just use the ExportHardwareSignal on the master chassis, and on the slave be sure to set the triggering attributes to import it on your chosen PFI line.  It should be fairly simple, and there are shipping examples that show the use of an External Clock that can illustrate the API use if you're not already familiar.

Tom W
National Instruments
0 Kudos
Message 4 of 5
(4,373 Views)

Tom,

 

Thanks. I'll add this tomorrow and hopefully then leave the project running over the weekend to confirm all is working OK.

 

Best regards,

 

Malcolm

0 Kudos
Message 5 of 5
(4,369 Views)