01-23-2015 06:51 AM
We are using a DAQ 6535 Digital IO board and are using the .NET classes to programmatically read/write the lines. We have a working patttern of creating a task and channel each time we need to read or write.
Examples:
private static bool ReadDigitalValue(string line)
{
using (NationalInstruments.DAQmx.Task digitalReadTask = new NationalInstruments.DAQmx.Task())
{
digitalReadTask.DIChannels.CreateChannel(line, "", ChannelLineGrouping.OneChannelForAllLines);
DigitalSingleChannelReader reader = new DigitalSingleChannelReader(digitalReadTask.Stream);
return reader.ReadSingleSampleSingleLine();
}
}
private static void WriteDigitalValue(string line, bool val)
{
using (NationalInstruments.DAQmx.Task digitalWriteTask = new NationalInstruments.DAQmx.Task())
{
digitalWriteTask.DOChannels.CreateChannel(line, "", ChannelLineGrouping.OneChannelForAllLines);
DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(digitalWriteTask.Stream);
writer.WriteSingleSampleSingleLine(true, val);
}
}
This is very slow and we need several orders of magnitude performance increase. We are using 3 digital lines that can be both input or output. They are either input or output at any given time and we know when to change the direction. I was assuming we would start but creating and holding on to the task but now I am not sure.
Do we need to create the task and channels each time we need to change the direction of a single digital line?
Can a digital line have more than one channel created? ie. one for input and one for output?
01-23-2015 02:24 PM
Create the task once. Create the channel once.
02-10-2015 10:52 PM