02-15-2017 07:42 AM
Hi,
I have problem with task. This is my code:
I initialize the task.
try
{
for (byte i = minRange; i < maxRange; i++)
{
if (pinInit[i]) {
digitalOutputWriteTask[i].Dispose();
}
using (digitalOutputWriteTask[i] = new Task())
{
digitalOutputWriteTask[i].DOChannels.CreateChannel(strDevice(i), "", ChannelLineGrouping.OneChannelForEachLine);
digitalOutputWriteTask[i].Control(TaskAction.Verify);
digitalOutputWriteTask[i].Start();
writer[i] = new DigitalSingleChannelWriter(digitalOutputWriteTask[i].Stream); //create writer
pinInit[i] = true;
}
}
}catch (Exception ex){
Console.Out.WriteLine(ex.Message);
return false;
}
I have writeDO method in my class:
public bool writeDO(byte pin, bool state) {
if (pinInit[pin])
{
try
{
writer[pin].WriteSingleSampleMultiLine(true, arrayToSend(1, state));
return true;
}
}
catch (Exception e)
{
Console.Out.WriteLine(e.Message);
return false;
}
I have Exception "NationalInstruments.DAQmx.DaqException: Task specified is invalid or does not exist.".
What's the problem??
Thanks in advance
02-16-2017 09:51 AM
Hi chino5.
did you already check the device name in MAX? Remember that you need to specify the correct device name to create a new phisical channel. Again, If you want to use a task to acquire or generate signals, the task needs to be created in MAX as well. Task's names in your code must match the ones in MAX.
regards,
Stefano