Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Time duration to read simple sample in c#

Hi,

I'm trying to get a value every millisecond. I measure the reading time and I notice that some measurements are greater than a millisecond, not much but still. I get the correct value but sometimes it's to long (results in picture below, max 27 ms).

 

output.png


I tried to change the reading functions, "sampleQuantityMode", buffer size, rating but the problem is still there. Same result with code examples.

These are the results after 10 minutes running (Second col : time for reading single sample / Third col : occurences).

Console app in C# with Visual Studio 2022. Daq NI PCIe-6321

Can you tell me where is the issue and what am I missing ?
Thanks a lot

 

 

Download All
0 Kudos
Message 1 of 3
(384 Views)

You may get a better response by reposting to the Multifunction DAQ forum:

 

Multifunction DAQ - NI Community

 

This forum is intended for people using real targets (NI Linux RT, etc.).

 

That said:

 

I am not a C# expert, so I may have this wrong, but it looks like you are reading a single sample inside the while loop. This means the loop is setting the sample rate, and as while loop execution time varies you are seeing different times. You should set the DAQ card up to perform hardware timing and read blocks of data. Take a look at examples that perform continues, or finite hardware timing. 

0 Kudos
Message 2 of 3
(350 Views)

Sorry. You can delete this topic.
Thanks for the response.

0 Kudos
Message 3 of 3
(331 Views)