Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using a channel with multiple ports on NIDAQmxBase

I'm using NIDAQmxBase to create an application for an NI 6508.  I want a channel to be composed of ports 1 and 2, and then to write to that channel.  My code looks like this:

TaskHandle th = 0;
int32 ret = 0;
ret = DAQmxBaseCreateTask("myTask",&th);
ret = DAQmxBaseCreateDOChan(th,"Dev1/port1,Dev2/port2","",DAQmx_Val_ChanForAllLines);

uInt8[2] out;
out[0]=0xFF;
out[1]=0xFF;

int written

ret = DAQmxBaseWriteDigitalU8(th,2,1,5.0,DAQmx_Val_GroupByChannel,out,&written,NULL);


When I do this, nothing is written to either port, but it says that 2 bytes were written (I'm using a multimeter to check the voltage at the pins, and all the lines on ports 1 and 2 are low).

On the other hand, if I change numSampsPerChan to 1, so the line looks like this,

ret = DAQmxBaseWriteDigitalU8(th,1,1,5.0,DAQmx_Val_GroupByChannel,out,&written,NULL);

I get error code -200524, but the lines on Port 1 go high, while the lines on port 2 are still low.  Then I tried this:

ret = DAQmxBaseWriteDigitalU8(th,1,1,5.0,DAQmx_Val_GroupByScanNumber,out,&written,NULL);

Again, I got error code -200524, and the lines on Port 1 went high.  Finally, I changed numSampsPerChan back to 2 for this following line:

ret = DAQmxBaseWriteDigitalU8(th,2,1,5.0,DAQmx_Val_GroupByScanNumber,out,&written,NULL);

I recieved to error message, but again only the lines on port 1 were set to high.

What do I need to do to have one command that will set all of the lines on ports 1 and 2 at the same time.

My System:
x86 running Suse 10.1
NI 6508
NIDAQmxBase v. 2.1.0

Thanks for any help,

Kenny Abernathy

0 Kudos
Message 1 of 2
(3,008 Views)
Hi Kenny,

I believe the reason you are not able to see port 2 go high is because you aren't writing enough data.  You are only writing 8 bits of 1's.  You need to write atleast 16 bits of 1's to see all the lines on both ports go high.  When you create the channel with "Dev1/port1,Dev2/port2" or if you meant for just one device, "Dev1/port1:2", the driver allocates this as one channel with 16 lines.  This will require 16 bits of data to write to all 16 lines.  I would recommend using the DAQmxBaseWriteDigitalU32.  This should give you enough data points to write to all the lines on both ports.

I hope this helps,
Paul C.

Message Edited by Paul C. on 10-25-2007 07:58 PM

0 Kudos
Message 2 of 2
(2,990 Views)