10-13-2014 02:16 AM
Hi,
I'm currently developing an application in C# using: framework 4.5, Windows 7, NationalInstruments.DAQmx.dll version 9.9.45.39, PCI-MIO-16E-4.
My application uses the internal clock to acquire the voltage from two input channels. It is a finite acquisition and I can choose the number of samples and the rate. My problem is for high rates (like 100kHz), I don't get all the samples. During the acquisition, I also display the data already acquired.
How I do:
I create a task with my two channels.
I configure the sample clock with the rate and the number of samples.
I use the SampleClockEventHandler even to display each data during the acquisition.
I use the TaskDoneEventHandler event to know when my acquisition is finished.
My application works well for low rates ( < 50 kHz). The problem is If I run the application for instance with a rate = 100kHz, I am not able to acquire more than 60% of the total amount of data asked (if I ask for 10 samples I get 6, 100 ->60, 1000->600,...).
Each time, my task sends the "done" event without error.
Would you have any idea of the origin of this limitation? With the PCI-MIO-16E-4 and two channels the maximum rate is suppose to be 125kHz.
What is the link between the rate and the number of samples?
I have the same problem if even if I don't display the data during the acquisition.
I tried also not to use the buffer with the command myTask.Stream.Buffer.InputBufferSize = 0. In this case I can acquire 98% of the number of samples. But if I ask more than 1000 samples, the program get stuck with the error:
"A first chance exception of type 'NationalInstruments.DAQmx.DaqException' occurred in NationalInstruments.DAQmx.dll"
Thanks for you help.
Sélim
10-14-2014 02:15 PM
A good troubleshooting step would be to find a shipping example code that is closest to your application and see if the results are the same when you increase the sampling rate.
10-15-2014 08:05 AM
Hi,
I didn't find an example using the SampleClockEventHandler event. Instead I found several examples using a callback and an asynchronous read operation.
So, I tried with the asynchronous reader : BeginReadSingleSample and with a callback to get all my data.
This method solves partially my problem. For a small amount of samples (<1000) I can acquire all my data even for the high rates (>10kHz).
But if I increase the number of samples, the acquisition get slower and slower even for low rates (<500Hz). How the number of samples is connected with the speed of the callback?
Thanks
Sélim
10-15-2014 02:50 PM
The acquisition could be slowing down because your pc can't read single data points fast enough. Could you try to read multiple data points rather than single data points?