Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxWriteDigitalU8 writing mod

Solved!
Go to solution

Hi, I'm not sure how DAQmxWriteDigitalU8 function writes 4 digit sample. Does it write 0x04 data like 0000 0100 or just 0100 0000 ?

 

Looks like DAQmx ignores first four zero bits. 

 

Here is a testing code

 

#define TEST 0x04

DAQmx_Digital_Output(taskHandle, NATDEVICE_NUM1, PORT_A, TEST); 

 

... 

 

int32 error=0;

int32 numWritten = 1; 

    

if(DevNo == 1 && PortNo == 2){

DAQmxErrChk (DAQmxCreateTask("", &MX_DO_Handle));

DAQmxErrChk (DAQmxCreateDOChan(MX_DO_Handle,"Dev1/port1","",DAQmx_Val_ChanForAllLines)); // it has 8 lines

DAQmxErrChk (DAQmxWriteDigitalU8(MX_DO_Handle,1,1,0.0,DAQmx_Val_GroupByChannel,&iDataToWrite,&numWritten,NULL));

if(!error && iDataToWrite == 0x04){

printf("Writing iDataToWrite: 0x%X\n", iDataToWrite);

}

}

else

printf("Writing failure!\n"); 

... 

 

From if(!error && iDataToWrite == 0x04) code, whatever I wrote it like == 0x4 or 0x04, it passes the condition without an error.

 

I wonder if DAQmxWriteDigitalU8 writes the data like 0100 0000. It should be 0000 0100.

I'm converting DAQ to DAQmx..from Parkoz.com
0 Kudos
Message 1 of 2
(3,763 Views)
Solution
Accepted by topic author anarkie

If you write 0x04 to an 8 bit port, then what you get out is:

 

line 0 - 0

line 1 - 0

line 2 - 1

line 3 - 0

line 4 - 0

line 5 - 0

line 6 - 0

line 7 - 0

 

line 0 is the lsb and it's no different in DAQmx than it was in traditional DAQ.

Message 2 of 2
(3,758 Views)