11-29-2022 12:28 PM
I have a code snippet using a multifunction DAQ to acquire two 4-20mA continuous current signals (temperature and pressure). The code reads and applies relevant scaling to these values to covert to Celsius and Pascal values, appending to a loop for subsequent averaging, and finally being stored to a queue for subsequent use.
After a period of continuous acquisition, the signal will dropout and report an issue with buffer overflow (-200279). This can be delayed by slowing the sampling rate (I assume reducing the gradual size buildup of the buffer memory), but eventually results in error/no values read in from the sensors after eventual buffer timeout (>100, 1000, 10000s). I viewed the example VI for continuous capture in the help menu and tried timing delays as per Error -200279: Unable to Keep Up with Acquisition in DAQmx - NI but have not been able to resolve this issue. The issue appears to be related to a discrepancy between the sampling rate and reading rate of the mxDAQ itself somehow still contributing to buffer buildup.
Faster acquisition (~>100Hz) is desirable from the installed sensors and should be within their rated means - any suggestions or obvious corrections in the initialization of the mxDAQ that could help resolve this? (In the event this is a continual issue,) Is there a clean way in the meantime to error trap and reset the mxDAQ buffer/operation within the loop when overflow happens without otherwise interrupting the code operation?
Solved! Go to Solution.
11-29-2022 01:37 PM
The first and most important thing is to call a version of DAQmx Read that can request *multiple* samples at a time. A good rule of thumb is to request 1/10 sec worth (i.e., 1/10 the sample rate) at a time.
There will be some other things too (such as removing the Wait function b/c the DAQmx Read function will accomplish the same kind of thing once you're reading multiple samples per loop), but start there.
11-29-2022 02:48 PM
Ah, I see my error. I was assuming to be reading multiple samples, whereas in reality I was sampling only a single point from each set of the transducer channels. This seems to be working now - I've modified the sample array to acquire the mean of each set to pass along to the averaging functionality/queue as intended.
Thanks for the reply - for reference, the DAQmx read should be configured to read Analog<Multiple Channels<Multiple Sample<2D DBL (or otherwise) with the previous ~1/10 read-to-sampled, the dropout would have been due to excess accumulation of unread points from only reading a single value from each set sampled from the transducers.