Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Base, continuous acquistion, dynamic number of samples to prevent buffer overrun

I am trying to modify my LV 6 data acquisition code to work in LV 7 and DAQmx base on OS X.

The ‘behind the scenes’ approach of DAQmx base is not comforting and I am hoping there are people who can shed some light on what is occurring. I am trying to sample multi-channel data as fast as possible. I have a NI6031E, it is like 64SE, 100k/s specs. I will probably be using around 10-20 channels but regardless of the number I always want the card providing 100k/s data.

I am measuring something with pretty high RMS noise but with true signal changes at 100 Hz. The signal is already filtered, but it is just noisy because of the underlying sensor. Anyhow, I was acquiring at 100k/s and then averaging (downsampling) to around 200 Hz and using the extra datapoints to reduce my RMS noise. This worked really well and kept my disk space usage down. In the past I would run my DAQ at 100k/s and then use the “Ai continuous acquire.vi’ in a while loop. That VI just grabs data at the ACQ rate and stores it in a buffer and when you call it you tell it how many samples to grab. I would have it grab either ~25 samples OR the number of samples remaining in the buffer after the last call… this gave me a slight temporal error but I don’t care because it is a X vs Y type measurement. I am driving a sensor and measuring both the drive signal and output signal pseudo-simultaneously. In the multi channel acquisition, the first channel is the drive signal (which is just a continuously running FIFO buffered output from another board) and then the remaining channels (say 2-10) are all the output signals. This technique allowed me to collect the data very quickly (100k/s) and then immediately downsample (within my while loop) and then only retain the average value (of the drive signal and output signals) and store those to disk. Now… how do I do this with DAQmx base (yes BASE!).

I can get Base to give me the data at 100k/s but trying to grab that data at 1 point per while loop is not going to work because the while loop is just tooo slow. The only option is to have the Read VI return several points during each call. Now, how many points do I ask for? In LV6, the equivalent ‘read’ VI would also return the number of samples remaining in the buffer, so that if the buffer started getting full, I can dynamically ask for more so it wont overflow. Well, now in Base, I have no way of knowing how full the buffer is getting. The only way I can do this currently is to just make sure I ask for enough data so the buffer doesn’t overflow. Alternatively, can I go in to all the subvis of the ‘read’ VI and wire up a new output terminal that passes up the number of samples remaining in the buffer? I am worried I will buffer overrun… this system runs for days and it would be terrible if it failed because of this problem. There is a ‘set’ buffer size VI in DAQmx base, but I cannot find a ‘query’ buffer size.

It is also possible that my understanding of how the Read VI is working is not correct. I configured the task to be ‘continuous’ (or whatever the new term is). Does it start filling its buffer as soon as I run “start task”? or only when I run the “read” vi? Does the ‘read’ VI grab the OLDEST (FIFO rules?) samples in the buffer? Is this a ring buffer? Will it overflow? Etc etc etc, I just have NO IDEA how this is working behind the scenes. I’ve read the help documents and they are worthless… the help documents are only a substitute for mousing over the terminals. Is there any good reference for DAQmx Base?

Should I change my acquisition to ‘single-shot’ and then just ask for ~25 samples during each while loop? This seems much slower than using the continuous acquisition, provided I can keep it sane.

Thanks-
Brad
0 Kudos
Message 1 of 7
(3,684 Views)
UPgrade to NI DAQmx 8.0. Uninstall mx base first. Leave base off your system. Its not needed anymore I don't know if this will help your case but it wont hurt. Can you change the amount of data grabbed per loop to 100 points? I don't know how your sensors are connected but you can reduce the noise issue some by connecting in differential mode.
0 Kudos
Message 2 of 7
(3,671 Views)
DAQmx 8.0 DOES NOT WORK on MAC OSX. DAQmx base 2.0.0 is the current option for Mac OSX... it is a very limited option too.
0 Kudos
Message 3 of 7
(3,655 Views)
I wasn't aware of that limitation of DAQ mx and a MAC.
0 Kudos
Message 4 of 7
(3,648 Views)

Hi Brad,

Unfortunately, not being able to specifically configure data transfer characteristics from the buffer is one of the limitations of DAQmx Base. My recommendation is to make sure that you read samples faster than you acquire them. This will prevent the buffer from overflowing and generating an error. However, please be aware that if you read too quickly from the buffer, you run the risk of getting a timeout error. Also, if you would like additional functionality for the MAC, then you can always use the Measurement Hardware Driver Development Kit (MHDDK).   I hope that you find this information helpful.

Regards,

Hal L.

Message 5 of 7
(3,626 Views)
I've gotten into the deeper level VIs and have found how to do what I mention above. However, I am stil a bit 'unsure' of what is going on. I setup the acquistion as normal (create task, create AI channel, set timing to 'continuous' and at X Hz, and then Start). Instead of using the DAQmx base VIs to get data and have started to write my own DMA transfer VI. Basically, I wire the "hardware exec ref" into some special invoke node I found in a BASE VI. I would really like more info on this special invoke node. I get the following options:

Set Write Caching
Flush Write Cache
DMA Config
DMA Start
DMA Read
DMA Write
DMA Stop
DMA Reset
DMA Swap Mode

I can play around with these (mainly start/read/stop/reset) but I would like actual documentation. There is no 'right click -> Help' and I have already experience some strange, non-obvious behavior so I really just need to read the documentation. Soo... where can I find information about this special "DMA" invoke node? I've attached some test code, just so it is easier to identify what I am looking at. The test VI doesnt have any of the task creation, timing, etc.. but you should need those to identify this node.

thanks-
brad
0 Kudos
Message 6 of 7
(3,605 Views)

Hi Brad,

So, it looks like you are getting into the invoke nodes that are part of the MHDDK. I am attaching a link with more information about the driver development kit: Measurement Hardware Driver Development Kit Frequently Asked Questions. Also, there is a different set of discussion forums just for MHDDK. I recommend posting any questions about MHDDK on these forums.

Regards,

Hal L.

0 Kudos
Message 7 of 7
(3,580 Views)