Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing values to multiple ports on PIC-DIO-96 with DAQmxBase

I am trying to write a program that writes multiple values to different ports on the PCI-6508 (PCI-DIO-96) board using NI-DAQmx Base in C on Mac OS X.

I would like to write values to 3 different ports in sequence. Originally my code would create 3 tasks (one for each port) and then call the DAQmxBaseWriteDigitalOutputU8 function for each task to write the different values to the three ports.

Is there a way to lump the 3 ports into one task and then write an array of values to each port? I have tried to run the writeDigMultiplePorts.c example program, but I get error message -200559. Is this a limitation of the board?

Thanks
0 Kudos
Message 1 of 6
(4,066 Views)
DPBiss,

Thanks for contacting National Instruments.  You can specify multiple ports on the same card, Dev1/port0,Dev1/port1,Dev1/port2 when you configure your task and then write an array to to the task using the same write function you specify.  Be sure to look in the C reference help that can be accessed through the start menu under National Instruments >> NI-DAQmxBase.

Regards,

Message Edited by Kenn N on 11-10-2006 10:53 AM

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 2 of 6
(4,057 Views)
Ken, thanks for the response, but I still seem to be having problems. I should have done this in my first post, but I'll walk through what I am doing.

I initalize my task like this:

TaskHandle myTask;
char chan[] = "Dev1/port0, Dev1/port1, Dev1/port2";

DAQmxBaseCreateTask("", &myTask);
DAQmxBaseCreateDOChan(myTask, chan, "", DAQmx_Val_ChanForAllLines);

Then I generate the data I want to output to the digital ports, lets just say I want to write 5 values to each port. In this example I want port 0 to get 0, 3, 6, 9, 12, port 1 to get 1, 4, 7, 10, 13, and port 2 to get 2, 5, 8, 11, 14.

uInt8 dataOut[15];

for ( ii = 0; ii < 15; ii++ ) {
    dataOut[ii] = ii;
}

DAQmxBaseWriteDigitalU8(myTask, 5, 1, 10.0, DAQmx_Val_GroupByScanNumber, dataOut, NULL, NULL);

So this code should write the 5 values in sequence to each of the three ports, correct? I keep getting an error message that says, "Write cannot be performed, because the data does not contain data for all the channels in the task." I don't understand what this means. I tried turning the autostart off and using DAQmxBaseStartTask, but that doesn't help either.
0 Kudos
Message 3 of 6
(4,047 Views)
DPBiss,

This code is not going to write the values consecutively.  There is no loop to iterate through.  Try writing a value that is 24 bits wide or a uInt8 array with three elements in it.  The ports on the PCI-DIO-96 are 8-bits wide so you can write 24-bits of data to the ports.  If you want to consecutively write to the port different values you need to setup a loop to write the new values to the ports.

Regards,


Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
Message 4 of 6
(4,037 Views)
I am currently looping through a bunch of values and calling the DAQmxBaseWriteDigitalU8 function in the loop to write to a channel. I was hoping there might be a faster way to just send a waveform or something and call the DAQmx function once.

Thanks for your help!
0 Kudos
Message 5 of 6
(4,025 Views)
DPBiss,

DAQmxBase only has the 3 digital write functions.  None of them can write a waveform to onboard memory.  This is a feature that is implemented in our High-Speed Digital I/O (HSDIO) driver and HSDIO cards.  These series of cards would include the 654x, 655x, 656x series of digital cards.  You can also look at our newest addition to the site, www.ni.com/hsdio.

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 6 of 6
(4,008 Views)