Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Task Timing question in c#

This may be a simple question but i have not been able to figure it so I am hoping you can help.

 

 I am trying to read Analog channels andI would like to get 500 readings/secord, each reading representing an average of 10 voltages. So i am trying to continuosly read 5000 readings per seconds and update the file after each 10 readings. I can set up a task with a sample clock set at 5000 readings but how do I get my code to be called after each 10 readings?

I am using usb-6210.

 

If I set up sample clock to run continuously and set the samples per channels to 10 the buffer size is too small. If I make the buffer larger, I do not get the timings I want.

 

I think this should be very simple but I am missing something. Thanks for you help in advance.

 

Michael T.

0 Kudos
Message 1 of 2
(3,194 Views)

Hi M.T.  The buffer size is determined by the sampling rate.  The hardware will sample the data at the rate determined by the sampling rate.  The "samples to read" is a attribute that will read from the buffer once the buffer meets or exceeds that number.

 

So, if you set the samples to read too low, it will be trying to reading a small amount from the buffer while the buffer is being filled at 5000 Hz (sampling rate).

 

If you set it too high, then your program will wait too long before reading the data, causing the buffer to be overwritten and losing data.  For example, if you set the samples to read at 25000, it will wait 5 seconds before it reads the data. 

 

So, the solution is to set your samples to read at a number that doesn't fill up your buffer and doesn't wait too long.  After that, you'll have to manually parse out the data to be 10 samples per chunk and run your code.

Che T.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(3,179 Views)