Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

WriteDigMultiplePorts.c example code does not work for USB-6501

Hello,

I am running a USB-6501 under Linux with NI-DAQmx Base v 2.1. I am trying to do exactly what is supposed to be done in the example code "WriteDigMultiplePorts.c".

The problem I'm having is very similar to this post: http://forums.ni.com/ni/board/message?board.id=250&message.id=34319&query.id=33116#M34319

I am running completely un-modified example code (attached for reference). The code is able to successfully control port0, but ports 1 and 2 are left unchanged. I have also toyed around with specifying all ports as /Dev1/port0:2, though haven't had any luck with this route either. The example code "WriteDigPort.c" works flawlessly. It seems like there is a problem with trying to control more than one port with the same task.

Any ideas why this example code does not work for this case?

Thanks.
0 Kudos
Message 1 of 6
(3,748 Views)
Hi,

Sounds like a very peculiar issue.  I will see if I can get a USB-6501 to try to reproduce the problem. 


Best Regards

Hani R.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(3,721 Views)
Hi tivoter123,

I took a look at your code and created a LabVIEW VI that uses DAQmxBase to test the ports of a USB 6501.  What I noticed in your code was that you are only declaring one task for all three ports.  To write to multiple digital ports you can create a separate task for each port.  You will then have to start, write and stop all tasks separately.  Keep me posted on your progress.


Message Edited by Hani R on 12-04-2007 02:10 PM


Best Regards

Hani R.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 6
(3,699 Views)
I have gotten my application to work doing exactly what you said. However, the code that I posted was not my code, it was the exact example code that is distributed with DAQmxBase for linux. This file is placed in usr/local/natinst/nidaqmxbase/examples/dio/writeDigMultiplePorts.c when you install DAQmxBase 2.1 for linux.
0 Kudos
Message 4 of 6
(3,696 Views)
Hi tivoter123,

I believe I know why only port0 is being updated and it is related to the forum post that you mentioned earlier.  When you write data (w_data[i] = 0x55) you are only writing 8 bits to the port.  You will have to write 8 bits for every port (in the code, change to w_data[i] = 0x555555; or whatever Hex value corresponds to the output you want) to get the other ports to update.  That way you won't have to create a task for every port. 


Message Edited by Hani R on 12-04-2007 04:37 PM

Message Edited by Hani R on 12-04-2007 04:37 PM


Best Regards

Hani R.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 6
(3,687 Views)
I have previously tried changing w_data[i] to 0x555555, with no luck.

0 Kudos
Message 6 of 6
(3,680 Views)