Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

ConfigureSampleClock throws an exception

I am using C# and DAQMX I have a PXI-1045 with 16 off M series PXI-6254 cards.

I am trying to get all the cards to use a common clock. When I make this call for evary task, I have a task per card everything works but each card is using its own internal lock. Every channel aquires at 20Khz. I can compenstate for sampling delays for channels on the same card but not accross cards due to the use of multiple clocks.
Works:

task.Timing.ConfigureSampleClock("", 20000.0, NationalInstruments.DAQmx.SampleClockActiveEdge.Rising, NationalInstruments.DAQmx.SampleQuantityMode.ContinuousSamples, 1000000);

However when I try and use the PXI clock (And I dont know if this ithe correct syntax, I found the string '10MHzRefClock' from a drop down on measument explorer.

Does not Work:

Works: task.Timing.ConfigureSampleClock("10MHzRefClock", 20000.0, NationalInstruments.DAQmx.SampleClockActiveEdge.Rising, NationalInstruments.DAQmx.SampleQuantityMode.ContinuousSamples, 1000000);

The exception message is:

'ADC conversion attempted before the prior conversion was complete. Increase the period between ADC conversions. If you are using an external clock, check your signal for the presence of noise or glitches.'

Any help would be appreciated.

Thanks in advance

Andrew
0 Kudos
Message 1 of 2
(3,682 Views)
Solved my own problem, the help documentation is poor for us API (C#) programers I have to say

If you want to know how to use the built in clock within a PXI chassis then simple use these lines

task.Timing.ConfigureSampleClock("", 20000.0, NationalInstruments.DAQmx.SampleClockActiveEdge.Rising, NationalInstruments.DAQmx.SampleQuantityMode.ContinuousSamples, iSamplesPerSec);
// task.Timing.ConfigureSampleClock("PXI_CLK10", 1, NationalInstruments.DAQmx.SampleClockActiveEdge.Rising, NationalInstruments.DAQmx.SampleQuantityMode.ContinuousSamples);
task.Timing.ReferenceClockSource = "PXI_CLK10";

This samples all the channels added to the task at 20 KHz. I have 16 tasks and all samples now occur at the same time across all boards.

I found the string PXI_CLK10 from within a document relating to the PXI-665x card because I was cynical enough to imagine that NI might be discoraging use of the perfectly adequate built in 10Meg clock, It is *NOT* documented in the drop down list in measuremtn and automation explorer NOR is it mentioned anywhere in the 'example lacking' DAQmx help. It is also shameful that the PXI star trigger cannot be accessed from any card, ah well a digital output toggling the PFI0 channels will surfice as my trigger.

Thanks for anyone that took the time to look.

p.s.

Labview is the devils work, long live real programming!

p.p.s I think the NI hardware and underlying programming API (i.e. what sits beneath Labview) is excellent, top marks to NI for that, pity it is not more accessible. .NET will replace labview IMHO.
0 Kudos
Message 2 of 2
(3,671 Views)