Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous DAQ

Hello,

I'm trying continuous DAQ and have some problem of data missing.

I'm using USB-6361 and USB-6366, MAX 19.6, python 3.7.6 and windows 10.

 

I want to take 2 AI channels and 2 DI channels simultaneously.

Sampling rate of AI is 1MS/s/ch, and I used sample clock timing for DI as below to take data at the same timing with AI.

nidaq.DAQmxCfgSampClkTiming(DItaskHandle,b"/Dev%d/ai/sampleClock" %num,float64(sampleRate),DAQmx_Val_Rising,DAQmx_Val_ContSamps,uInt64(1000000))
 
And it seems I can take 4 channels of data simultaneously,
however, it lost some data.
 
Last time, I had similar problem with USB-6212 (200kS/s/ch, 2 AI).
At that time, I changed the buffer size as 1MS and take 20k data /ch at once, continuously. I had a problem when the buffer size is small(~k) and take small number of data (~10~100) at once.
 
So I though I can solve the problem if I change the buffer size and the # of samples, but it never works now.
Is the bandwidth of USB 2.0 can be the problem here?
It lost a lump of data so I still suspect the buffer size or # of samples is the reason. (Of course there's a probability that I'm wrong. Actually I don't have much experience to use NI DAQ board)
 
Please let me know if you have any idea.
Thank you in advance!
 
 
0 Kudos
Message 1 of 4
(1,696 Views)

In the post, you mentioned that you are using USB-6361 and USB-6366 + 2 AI channels and 2 DI channels simultaneously. And the AI is synchronized with the DI. Are the 2 AI channels and 2 DI channels all on the same USB device? Or are you exporting the sample clock from one USB device to another?

 

DAQmx should have throw an error if the application is not able to keep up with the acquisition, so no data should be lost. Are you seeing the data has been overwritten error?

 

2 16-bit AI channels at 1 MS/second. That is about 30.5 MB/second of bandwidth which is close to the limit of USB 2.0 bandwidth (30~40 MB/second) in practice. Getting close to 40 MB/second is extremely difficult, requiring a good dedicated USB host controller + good programming practices to reduce buffer copies. Typically application tops out around mid-30's MB/second. That is not counting the DI channels which will share the same USB bandwidth if the DI channels is on an USB device plugged into the same USB host controller.

0 Kudos
Message 2 of 4
(1,642 Views)

Thank you for the reply.

Oh, I'm sorry. My question was unclear.

I used only one device to take 2 AI and 2 DI channels. I tried same thing for both USB-6361 and USB-6366 separately.

 

There was no error. However it seems it doesn't throw an error sometimes in the python environment even if there is an obvious malfunction (Once, someone has seen an error in ANSI C and I couldn't see any error message in python for the same code.

Maybe I can translate the code to ANSI C and see if there is any error.

 

2 16bit AI channels at 1MS/s should be ~32Mbit/s and the maximum speed of USB 2.0 is 480Mbit/s so I thought it should be okay..Maybe I miss something. 1bit info is not 1bit in this case?

 

Thank you so much again,

and please let me know if there is any further question or idea. 🙂

 

 

0 Kudos
Message 3 of 4
(1,612 Views)

Oops, that was my bad, bit is not the same as byte. 😅 2 16-bit AI channels at 1MS/s should be ~32Mbit/s which a 4 MB/second. Even plus the DI channel, 32-bit per sample for both channels, that would be another 4 MB/second. In total that would be 8 MB/second. USB 2.0's theoretical throughput is 480 MBit/second (60 MB/second), but in practice it tops out around 30~40 MB/second. The input bandwidth of your application is well under that limit so USB bus limitation should not be a problem.

 

I am concerned that your Python is not getting a DAQmx error/warning when doing a read if the buffer has overwritten old data with new data. By default, DAQmx do not allow old data to be overwritten before the application reads it: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000PAraSAG&l=en-US Do you have "allow overwrite" attribute set in your application? Is your application using this Python API: https://github.com/ni/nidaqmx-python

 

Would you mind posting snippets of your python code, just the DAQmx part? 

 

0 Kudos
Message 4 of 4
(1,587 Views)