02-25-2017
10:53 PM
- last edited on
01-12-2025
04:23 PM
by
Content Cleaner
I'm writing a plain C application using the DAQmx API. I've modified the sample TDMS-ContAcq-IntClk Example program to give me multiple channels (4 channels in this case).
It keeps giving me buffer overrun problems (Error -200279) no matter what. Can any veterans spot the bug?
If I increase the buffer, I can at least increase the time before it overflows, but it always does, as suggested by https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019KTeSAM&l=en-US
This Producer/Consumer pattern may be what I need, but I don't quite see why (since it's a simple single-thread application), nor how to implement it https://www.ni.com/en/support/documentation/supplemental/21/producer-consumer-architecture-in-labvie...
Another hint may be that, of what little data I can record, it appears that the channels are not separated properly, and all channels are the same data, I believe channel 0.
My code is attached. Any help is greatly appreciated.
I forgot to mention- I tried the default XferMech (Transfer Mechanism) of USBBulk, I tried changing it to Interrupts, and then I tried DMA. All give the same resulting buffer overflow.
02-27-2017
05:42 PM
- last edited on
01-12-2025
04:24 PM
by
Content Cleaner
Hello jayache80,
When using Text Based emviroments you should try follow some good instructions found here: https://www.ni.com/en/support/documentation/supplemental/21/using-ni-daqmx-in-text-based-programming...
Even if you need some reference about it: https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/cdaqmx/help_file_title.html
Even more examples: https://www.ni.com/en/support/documentation/supplemental/20/examples-included-with-ni-software-produ...
But you definetely have to consider using a producer/consumer architecture. The error you're getting is related to the buffer size as you can see here: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000PAraSAG&l=en-US
The error indicates that information is lost and occurs when LabVIEW does not read data from the PC buffer quickly enough.To avoid an overwrite error, you need to increase the buffer size, read faster, or write slower.
Good Luck!
-Andrea G.
Applications Engineer National Instruments
03-03-2017 08:28 PM
Thanks, but none of those resources helped me see why my code doesn't work. It seems that on the N-Samples callback, none of the samples in the buffer actually get consumed when they get read. Do I need to manually clear the buffer?