05-11-2009 11:26 AM
I am in the process of porting some software writting in Traditional DAQ to DAQmx. We use the PFI4-7 pins on the NI6534 for general purpose IO. I did not have any issues programming/using these lines on the same PC under Traditional DAQ, but have been unable to get them to work under DAQmx. I have even tried to use the DAQmx softpanel for the device, but toggling the state of lines 0-4 on port 5 do not result in any state change on the physical pins.
Here is the code that I'm currently trying to use with DAQmx. The variable szChannel results in "Dev1\port5\line0:0". I have also tried "Dev1\port5\line0" without luck. Any help is appreciated. I'm currently using DAQmx 8.6.0f12.
int CVIFUNC DaqMxSetDiscrete (char* szDevice, int discrete, int state) {
char szChannel[256];
uInt8 data[1] = {0};
int error = 0;
TaskHandle taskHandle = 0;
data[0] = (uInt8)state;
GetDaqMxChannel(szChannel, szDevice, discrete);
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateDOChan(taskHandle, szChannel, "", DAQmx_Val_ChanPerLine));
DAQmxErrChk (DAQmxStartTask(taskHandle));
DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));
Error:
if( taskHandle !=0)
{
error = DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
return error;
}
05-11-2009 03:09 PM
05-11-2009 03:45 PM
After upgrading to 8.9, I am able to control PFI4-7 using the test panel in MAX, but cannot get the state to change for these lines from within my program. I've tried creating a DAQmx task from within CVI. When designing the task, I can change the state from the softpanel, but once I use the generated code within my application, no state change. The code it generated for one of the PFIs is:
int32 CreateDAQTaskInProject1(TaskHandle *taskOut1)
{
int32 DAQmxError = DAQmxSuccess;
TaskHandle taskOut;
DAQmxErrChk(DAQmxCreateTask("DAQTaskInProject1", &taskOut));
DAQmxErrChk(DAQmxCreateDOChan(taskOut, "Dev1/port5/line2",
"DigitalOut", DAQmx_Val_ChanPerLine));
*taskOut1 = taskOut;
Error:
return DAQmxError;
}
Then I call the function as follows:
CreateDAQTaskInProject1(&taskHandle);
DAQmxErrChk (DAQmxStartTask(taskHandle));
DAQmxErrChk (DAQmxWriteDigitalScalarU32 (taskHandle, 1, 10.0, 1, 0));
Thanks,
Michael
05-11-2009 03:54 PM