Discussion:
Number of channel in the task not match with number of channel in data
(too old to reply)
Khammonh
2007-05-08 10:10:10 UTC
Permalink
Hello There
We just bough new PCI-DIO96 board for our new project and use managed NI-DAQmx library to develop our own software application using VB.NET on Visual Studio 2005.
I build the class DIO with a subClass name MyBit which will represent 12 Ports as a member of the class each name AA,AB....and so on and end with DC .
Each port will share a ReadTask , WriteTask ,MyReader and MyWritter (ReadTask and WriteTask is of type Task and MyReader and MyWritter is of type DigitalSingleChannelReader and DigitalSingleChannelWrite Respectively) .
Class DIO has method SetOut for Output a specific port and bit or Bit array and method ReadPort for reading a Bit array of a specific port.
When the class DIO is instantiate with its constructor the 12 ports will be initialized and a shared member (Static in C++) also will be also initialized and add channel to its respective Task (ReadTask for Input Port and WriteTask for OutPut port with their respective MyReader and MyWritter ).
I got problem when I try to use Sub SetOut which its body use MyWritter.WriteSingleSampleMultiLine(True,DATA()) command in NI-DAQmx library . I got error message telling that the number of Channels in the Task not Match with Number of channels in Data.
I don't know what does it mean.
The intention of creating a class MyBit which is a sub class of DIO  with the shared member is for keeping the channel status in ReadTask and WriteTask during software run , as if we create a new Task each time and add the same channel name to the task would not possible unless the old task is disposed , so each time the task create and add channel a physical status of a current channel will be lost.
So how to overcome the above error (Number of channel in data and task not match).
Regards
 
TheWoost
2007-05-09 14:40:18 UTC
Permalink
Hi Khammonh, You did not mention the error code associated with the error, but I believe it is -200463:"Specified read or write operation failed, because the number of lines in the data for a channel does not match the number of lines in the channel."The WriteSingleSampleMultiLine method writes a single digital sample to multiple digital lines contained in a task channel.  The DATA() array that you pass to this method is a 1D array of samples to write.  Each element of the array
corresponds to a digital line within the channel, and the size of the array must be equal to the number of digital lines in the channel or the error will be returned.  What is the size of the DATA() array that you are passing compared to how many digital lines you are intending to write this data to?Regards,Andrew WNational Instruments
Khammonh
2007-05-10 03:10:11 UTC
Permalink
Hello Andrew
Thank you for your answer, I actually very new to NI though I developed a lot of application but never use NI .Answer to your question .
DATA() is 1D array with 8 elements and no thing wrong with the format , before I get your reply I try on error and found that I need to create the task and its associate Reader and Writter for each channel . Previously I create a common ReadTask ,WriteTask and their associate Reader and Writer as a shared member of the class ( hope to save system resources) but this way it doesn't work as these common tasks content six channels each ( 6 Inputs and 6 OutPuts) when I want to write to a specific channel in the task I got the error message. So I change my class structure , add 4 readonly properties to the class each represent ReadTask, WriteTask , Reader and Writer of the class. This way I have no problem. I download NI-DAQmx for .NET but its documentation seems not completely loaded , when I drill to some particular member of the class there is no help available. Where I can get a complete documentation preferably a compiled help that integrated into Visual Studio 2005(or VB.NET 2005)  IDE if not a PDF format is also fine.
I also want to learn more about NI hardware and software driver for my next development a comprehensive sample code would be good as I saw each sample code provided is a small piece of code contain only one a few commands . A small application code would be a good sample says has a few AI ,DI ,DO and AO , AI and DI may have one that work in a interup mode (Interup when detect status change).
Hope I will get a good recommendation.
Regards

Continue reading on narkive:
Loading...