ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

usb-6509 task problem

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

 

0 Kudos
Message 1 of 2
(2,861 Views)

 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 

0 Kudos
Message 2 of 2
(2,823 Views)