06-21-2007 01:10 PM
06-28-2007 11:20 AM
07-09-2007 07:38 AM
07-24-2007 06:57 AM
07-25-2007 09:22 AM
07-25-2007 10:21 AM - edited 07-25-2007 10:21 AM
Hey John-
You don't mention which hardware you're using, but I'll assume it is an M Series 62x1 or 62x0. The reason for that assumption is that those devices feature 8-bit digital ports for change detection. The likely reason you're seeing this behavior is that the device waits to buffer 32-bits of data for DMA transfer, so it takes 4 events to buffer enough data from the port.
One suggestion to get data back on each event would be to use interrupt-driven transfers rather than DMA. This will most likely decrease your performance slightly, but it will provide on-demand transfers. This can be accomplished via a call to DAQmxSetDIDataXferMech() to set the transfer mechanism to DAQmx_Val_Interrupts (10204).
EDIT: BTW- if this is indeed the issue, it is not specific to Linux. This behavior is dictated by the device and would also occur on Windows or any other platform.
Message Edited by Tom W [DE] on 07-25-2007 10:22 AM
07-25-2007 10:56 AM
07-25-2007 11:00 AM
Hi John-
Here's the documentation for that function:
----------------------------------------
Data Type: | int32 |
Description: | Specifies the data transfer mode for the device. |
Valid values
DAQmx_Val_DMA | 10054 | Direct Memory Access. Data transfers take place independently from the application. |
DAQmx_Val_Interrupts | 10204 | Data transfers take place independently from the application. Using interrupts increases CPU usage because the CPU must service interrupt requests. Typically, you should use interrupts if the device is out of DMA channels. |
DAQmx_Val_ProgrammedIO | 10264 | Data transfers take place when you call an NI-DAQmx Read function or an NI-DAQmx Write function. |
DAQmx_Val_USBbulk | 12590 | Data transfers take place independently from the application using a USB bulk pipe. |
You can get/set/reset this property using:
DAQmxGetDIDataXferMech
DAQmxSetDIDataXferMech
DAQmxResetDIDataXferMech
-----------------------------
A call to set this property would look like:
DAQmxSetDIDataXferMech(taskHandle, channelName, DAQmx_Val_Interrupts);
where taskHandle is the task handle associated with the task of interest and channelName is the channel name you assigned (or "") in DAQmxCreateDIChan()
07-25-2007 11:18 AM
07-25-2007 11:21 AM
Hi John-
Thanks for the feedback- I would prefer to leave the example as-is because it shows the best method performance-wise. I do agree that we should document this behavior; I'll request that an online KnowledgeBase entry be created.
Thanks again-