Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring ports and lines

Hi

Hardware USB-6009, OS FedoraCore 6 (Redhat WS4), Driver NIdaqmxBase, S/W ANSI C.

 

I'm trying to read the digital lines of the two  ports on this DAQ. I have tried the examples which are only for reading ports only and they work. The DAQ has a Port 0 with 8 lines and a Port 1 with 4 lines. I would like to read each and then display the result to the screen but I display 1 line at a time, I beieve it displays all line in the port as one HEX number. How can I split the data for each port into the different lines. Below is an extract of how I'm trying to do it:

 

TaskHandle   taskHandle = 0;

TaskHandle   taskHandle1 = 0;

 

 char         chan1[] = "Dev1/port0/line0:7";
 char         chan2[] = "Dev1/port1/line0:3";

 

 uInt32       r_data [8];
 uInt32      r1_data [4];
 int32        read=0;
 int32        read1=0;

 

 DAQmxErrChk (DAQmxBaseCreateTask ("", &taskHandle));
 DAQmxErrChk (DAQmxBaseCreateTask ("", &taskHandle1));
 DAQmxErrChk (DAQmxBaseCreateDIChan(taskHandle,chan1,NULL,DAQmx_Val_ChanForAllLines));
 DAQmxErrChk (DAQmxBaseCreateDIChan(taskHandle1,chan2,NULL,DAQmx_Val_ChanForAllLines));

 

 DAQmxErrChk (DAQmxBaseStartTask (taskHandle));
 DAQmxErrChk (DAQmxBaseStartTask (taskHandle1));

 

DAQmxErrChk (DAQmxBaseReadDigitalU32(taskHandle,1,1.0,DAQmx_Val_GroupByChannel,r_data,8,&read,NULL));
DAQmxErrChk (DAQmxBaseReadDigitalU32(taskHandle1,1,1.0,DAQmx_Val_GroupByChannel,r1_data,4,&read1,NULL));

 

  for(i=0; i<8; i++)
      {printf("Data read port 0, line %d: 0x%X\n", i, r_data[i]);
        printf("read functions : %d\n", read1);

 }

  for(i=0; i<4; i++) {
        printf("Data read port 1, line %d: 0x%X\n", i, r1_data[i]);
        printf("read functions : %d\n", read1);
}

 

This is how I interpreted to read the mutlipe lines for each port. When I turn the switches on and off only the first line number changes all.

 

Im not sure what im doing wrong.

 

Regards

 

Thivash 

 

0 Kudos
Message 1 of 2
(2,786 Views)

Hi, Thivash.

 

It seems as if the data you are reading is digital, and you're trying to display it as binary, in order to see the bit value on each line.   To solve this issue, insert the appropriate code that will allow you to convert from digital to binary.  Here is an example of how to do so.

 

Let me know if this helps.  I hope you're having a great day!

Regards,

Sara Lewandroski
Applications Engineer | National Instruments
0 Kudos
Message 2 of 2
(2,766 Views)