02-24-2010 11:56 AM
oe- I am seeing this error when I try to perform dio twice in a function that is contained in a subroutine (in a separate file):
DAQmxBase Error -200428: Value passed to the Task/Channels In control is invalid.
an outline of the code is below. We have two files- the main file and the subroutine file. In the main file, I have:
#define DAQmxErrChk(functionCall) { if(DAQmxFailed(error=(functionCall)) ) {goto Error; }}
int writeDigPort(TaskHandle taskhandle,int,int); //This is the dio subroutine
int main(void) {
TaskHandle taskHandleDO = 0;
int direction ;
// Set Channel Numbers, filenames
char chan[] = "Dev1/port1";
// Task parameters
int32 error=0;
char errBuff[2048];
// Begin Program
DAQmxErrChk (DAQmxBaseCreateTask ("",&taskHandleDO));
DAQmxErrChk (DAQmxBaseCreateDOChan(taskHandleDO,chan,"",DAQmx_Val_ChanForAllLines));
DAQmxErrChk (DAQmxBaseStartTask (taskHandleDO));
direction = 1;
DAQmxErrChk (writeDigPort (taskHandleDO,1,direction)); //This is the dio subroutine call
usleep(1000000);
direction = 0;
DAQmxErrChk (writeDigPort (taskHandleDO,1,direction));
.
.
.
In the subroutine file, I have:
#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
int writeDigPort(TaskHandle taskHandleDO, int lineNum,int direction)
{
int32 error = 0;
char errBuff[2048];
uInt32 w_data[1];
int32 written;
if(direction == 0) {w_data[0]=0;} //set all channels to zero
else {w_data[0]=lineNum;} //turn on selected channel
DAQmxErrChk (DAQmxBaseWriteDigitalU32(taskHandleDO,1,1,10.0,DAQmx_Val_GroupByChannel,w_data ,&written,NULL));
The subroutine is called twice by the main program. The first time it works, the second time I get the error shown above. I looked up the error number, but all I found was this:
http://digital.ni.com/public.nsf/allkb/7705D38D59EF562886256F79007E4B5A
which assumes labview is being used.
Any thoughts?
thanks,
eric