Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Options for detecting USB-6501 port state change

I've been detecting state changes by calling DAQmxReadDigitalU32() in a polling fashion, on a port configured for input.

 

I'd like to know if there's a way to have the NIDaqMx library invoke a callback function when it has a state change. Is there an example of this somewhere?

 

Thanks

 

ted in AZ

 

 

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

Hi TedWagner!

 

I've been looking into how we can do some sort of interupt in the DAQmx driver and from what I've found there are two methods of doing it. The majority of the functionality is contained in the specific hardware, Change Detection is only available on certain pieces of hardware, i.e. we can only enable change detection on a card that supports it at a hardware level, we cannot force a card that doesn't support it to do it at a driver level. 

As your current device doesn't support change detection, you will have to set it up to poll the input whilst your other code runs. Then once it triggers it will run whatever code you include in that loop, so an emergency stop for example. This will take up resources on the host running this code, so mulithreadig would be ideal but like you said this could be overkill for this application. Unfortunately polling does seem to be the only option with the current hardware setup due to the nature in which the DAQmx driver works. 

To sum up, we cannot force the driver to detect a change on the line unless the hardware specifically supports change detection (like the NI 6509). The only option available to you with your current hardware is to continuously poll one of the hardware lines in a loop (and perhaps in another thread) and then act with an if statement when a certain value is returned. Aplogies that it seems the driver cannot sepcifically act in the way in whihc you require, but the polling option is available as a solution to this. 

If you have any more questions on this then let me know, hopefully the information above is sufficient. 


Kind Regards, 
Carlos O

Applications Engineer

National Instruments

0 Kudos
Message 2 of 3
(4,244 Views)

Carlos,

 

Thank you very much for the clear reply. I pretty much figured out independently that the 6501 hardware was not going to support interrupt style change detection, so recently I implemented a producer/consumer thread model that polls the USB-6501 for state changes between short (20 ms) sleep() periods.

 

I use 3 or 5 USB-6501's in my application, each getting their own thread, and so far this is working well.

 

-ted

 

 

0 Kudos
Message 3 of 3
(4,239 Views)