Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupt Driven (Asynchronous) Digital Input from NI6008

Solved!
Go to solution

Hi,

 

I want to set up my NI-6008 OEM to "interrupt" i.e. call a Windows Callback function, when a digital I/O line changes state. I looked at the example ReadDigChan-ChangedDetectionEvent.c which is sample source and modified it slightly for my hardware.  The code is in c++ and runs on Windows XP.  Am I doing something wrong in the setup or is the 6008 board incapable of interrupt driven I/O?

 

The code in question is:

 

DAQmxErrChk (L"DAQmxCreateTask", DAQmxCreateTask("",&taskHandle));
 
DAQmxErrChk (L"DAQmxCreateDIChan", DAQmxCreateDIChan(taskHandle,DINPSTR,"",DAQmx_Val_ChanForAllLines));


//DAQmxErrChk (L"DAQmxCreateDIChan", DAQmxCreateDIChan(taskHandle,DINPSTR,"",DAQmx_Val_ChanPerLine)); tried this, didn't help
DAQmxErrChk (L"DAQmxCfgChangeDetectionTiming", DAQmxCfgChangeDetectionTiming(taskHandle,DINPSTR,DINPSTR,DAQmx_Val_FiniteSamps,1));
DAQmxErrChk (L"DAQmxRegisterSignalEvent", DAQmxRegisterSignalEvent(taskHandle,DAQmx_Val_ChangeDetectionEvent,0,ChangeDetectionCallback,NULL));
DAQmxErrChk (L"DAQmxStartTask", DAQmxStartTask(taskHandle));

 

"DAQmxErrChk" is a macro defined in the line below

#define DAQmxErrChk(functionName, functionCall)if(DAQmxFailed(s_iError=(functionCall))) {s_iLine = __LINE__; s_szFunctionCall = functionName; goto Error;} else

The error occurs on the call to DAQmxCfgChangeDetectionTiming

A call to  DAQmxGetExtendedErrorInfo through the macro returns

 

2011-04-15 @ 14:01 Module:  InitializeIO, Line:  85
Function:  DAQmxCfgChangeDetectionTiming

 Requested value is not a supported value for this property.
Property: DAQmx_SampTimingType
You Have Requested: DAQmx_Val_ChangeDetection
You Can Select: DAQmx_Val_OnDemand

Task Name: _unnamedTask<0>

Status Code: -200077

 

I'm attaching the c++ source file that contains the NI DAQmx calls for your review as well.

 

 Any help would be appreciated.  Thanks is advance.

 

- Neil Shore

Download All
0 Kudos
Message 1 of 4
(3,637 Views)
Solution
Accepted by topic author LaserShore

It doesn't look like the 6008 supports change detection. You could try using a parallel loop structure to monitor the state of the digital line and then putting a small delay in a loop to monitor your DI and base your change on that. 

 

http://digital.ni.com/public.nsf/websearch/8914FA5E30971E0C86256FEF005760FF?OpenDocument

Jake H | Product Manager
0 Kudos
Message 2 of 4
(3,623 Views)

Hi Jake,

 

Thanks for your reply.  Thanks for your link that confirms my understanding.

 

Would you have a quick suggestion as to what NI USB device would be the closest to the 6008's feature set, I/O lines A/D, and D/A, and DOES support change detection (interrupt driven digital I/O)?

 

Thanks again for your help.

 

- Neil Shore

 

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

Hi Neil,

 

Assuming you stick with USB, any of the hardware timed products should detect the interrupt you're looking for. I wouldn't want to recommend anything specific without talking about your application a little more. If you want to send me your contact information I can have someone get in touch with you and discuss some of our different products.

Jake H | Product Manager
0 Kudos
Message 4 of 4
(3,594 Views)