04-15-2011 09:36 AM
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
Solved! Go to Solution.
04-18-2011 11:20 AM
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
04-18-2011 12:55 PM
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
04-19-2011 06:32 PM
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.