Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble Writing to Digital Channel Line

Hello:

 

I am developing a C#/.NET that uses DAQmx 9.4 to communicate with a NI 6015 DAQ Pad. 

 

When I try to write to several digital channel lines at a time, an error message is returned:

            

            var digitalWriteTask = new Task();
 
            digitalWriteTask.DOChannels.CreateChannel("Dev1/Port0/line0"string.Empty, ChannelLineGrouping.OneChannelForAllLines);
            digitalWriteTask.DOChannels.CreateChannel("Dev1/Port0/line1"string.Empty, ChannelLineGrouping.OneChannelForAllLines);
            digitalWriteTask.DOChannels.CreateChannel("Dev1/Port0/line2"string.Empty, ChannelLineGrouping.OneChannelForAllLines);
 
            var dataArray = new bool[3];
            dataArray[0] = true;
            dataArray[1] = false;
            dataArray[2] = false;
 
            var writer = new DigitalSingleChannelWriter(digitalWriteTask.Stream);
            writer.WriteSingleSampleMultiLine(true, dataArray);
 
            // The following error is returned when the writer.WriteSingleSampleMultiLine method executes:
            //Write cannot be performed, because the number of channels in the data does not match the number of channels in the task.
 
            //When writing, supply data for all channels in the task. Alternatively, modify the task to contain the same number of channels as the data written.
 
            //Number of Channels in Task: 3
            //Number of Channels in Data: 1
 
            //Task Name: _unnamedTask<0>
 
            //Status Code: -200524

 

 I was also wondering if it is possible to write to a digital line individually using a logical line name (instead of having to write to all lines at the same time using an array)?  If so, can you please provide a code example?

 

Thanks for your assistance.

 

Chris 

 

 

 

 

0 Kudos
Message 1 of 2
(4,461 Views)

Hi,

 

Try using this

 

 

digitalWriteTask.DOChannels.CreateChan​nel("Dev1/Port0/line0:2", string.Empty, ChannelLineGrouping.OneChannelForAllLines);

 

 

Curt

0 Kudos
Message 2 of 2
(4,443 Views)