Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

6534 PFI4-7 and NIDAQmx

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;
}

0 Kudos
Message 1 of 4
(3,715 Views)
I upgraded to DAQmx 8.9 and am now able to control PFI4-7 without issue.
0 Kudos
Message 2 of 4
(3,705 Views)

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

0 Kudos
Message 3 of 4
(3,701 Views)
Ok... figured out that for the PFI lines, I must write the data as if I'm doing a port write.  I'm not sure why this differs from the other ports where I can address lines individually.  In order to set PFI6, I have to write the value 0x04.
0 Kudos
Message 4 of 4
(3,700 Views)