Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

reading Ni-Daq continuously in C#

Hello,

 

I'd like to write a little C# code that reads data from a NiDaq Analog Input channel continuously at lets say 500 samples per second and add them to a buffer. This sampling may go on and on for a few hours or even a day.

 

One way that came to my mind (I had previously done this but I only needed snap shots of data every few seconds) that I had previously implemented is to have a thread that has a while loop with a delay of 2ms and inside of that loop I read the NiDaq channel using: "analogReader.BeginReadWaveform(...)"

 

But the way I have current system implemented is by triggering "analogReader.BeginReadWaveform(...)" and then firing an Asynch call back when the read is finished seems to be very complicated specially for a high speed application like this.

 

Is there an example that shows how to read one teeny tiny sample every couple of milliseconds and add it to a buffer without all this events and callbacks and asynch blah blah that can slow down a time sensitive sampling?

 

Thanks

 

 

 

 

0 Kudos
Message 1 of 6
(6,236 Views)

Hatefk,

 

Are you wanting to analyze this data in real-time? Or is some delay in the analysis ok, provided the sampling intervals are constant?

--------------------------------------
0 Kudos
Message 2 of 6
(6,195 Views)

The data needs to be analyzed in real-time and delays are not acceptable.

 

But I have started looking at this example: "AcqMultVoltageSamples_SWTimed" which seems to be ok.

 

Thanks OlliesCamel for the reply.

0 Kudos
Message 3 of 6
(6,184 Views)

I'm glad you found a solution, but would like to emphasize that a real-time OS would be incredibly beneficial for this application. Otherwise you are certainly going to see jitter of more than 2ms.

--------------------------------------
0 Kudos
Message 4 of 6
(6,163 Views)

Thanks but the system needs to run under windows.

0 Kudos
Message 5 of 6
(6,160 Views)

Dear Alan,

 

Can you kindly provide me the source , I also want this for a high speed application with PCIe  6321. Please help me

0 Kudos
Message 6 of 6
(2,062 Views)