Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

cDAQ-9172 synchronizing two analog inputs

Solved!
Go to solution

Hello,

 

I have a NI-9219 and a NI-9239 inside a cDAQ-9172 and want to read the voltages of all 8 channels (4 channels per device). I managed to measure those voltages at 1 second sample rate using C# .NET. However, there seems to be a delay somewhere which causes the voltages from the two devices not to be measured at the same time. 

 

I looked at a bunch of examples and other posts here, but nothing helped. I tried some of the C# examples for synchronization, but they use multiple tasks, which I can't do, since I have two devices of the same type (analog I/O). 

 

I'm setting up the timing like this (I've played with different sample rates, no change):

myTask.Timing.ConfigureSampleClock("", 100, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 1);

 

and am using a reader to get the data:

reader = new AnalogMultiChannelReader(myTask.Stream);

 

and then every 1 second I run:

data = reader.ReadSingleSample();

 

Thanks for your help, I'm sure I'm missing something here.

 

Marvin

0 Kudos
Message 1 of 2
(1,780 Views)
Solution
Accepted by topic author marmes

Hello again,

 

Nevermind, I fixed it. 

 

For anyone who may have a similar issue:

 

I did end up changing a bunch of things, but I think what fixed it at the end was learning that the NI9219 has these different ADC timing modes to determine the tradeoff between fast sample rate and high resolution. By default it is set to high resolution, which means it has a 500ms conversion time, this (I think), explains the phase shift I was seeing. To fix this, the ADC timing mode can be changed like this:

 

myTask.AIChannels[ChannelNumber].AdcTimingMode = AIAdcTimingMode.HighSpeed;

 

Note: this has to be the same for all channels in the device (but can be different between devices). 

 

Also see: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P90VSAS&OpenDocument=&l=en-CA

 

Thanks anyway!

 

Marvin

 

 

0 Kudos
Message 2 of 2
(1,735 Views)