Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

the order of creating DAQmx tasks

I would like to report a bug for the M-series devices when using the code written in Measurement Studio.

If you have multiple tasks and one of them is the Continuous Analog Input task that uses DAQmxRegisterEveryNSamplesEvent, you have to be careful about the order of creating the tasks with DAQmxCreateTask.

After some testing, I realized that for successful repeated creation of the AI task after deleting it with DAQmxClearTask, it must be declared LAST in your list of the tasks.

It does not matter, what other tasks you create (AO, DO, DI, Counter), the DAQmxCreateTask for the AI task has to be the last one (otherwise it works only until the first DAQmxClearTask call).

I am not sure whether this is a Measurement Studio quirk or a hardware issue.

There is nothing intuitive about this behavior, so I hope you find this advice before wasting much time with your malfunctioning code.

 

Victor  

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

Howdy Victor!

 

Do you have any examples of the code demonstrating what works and what does not work that you can post?  Also, what is the behavior/error that you are experiencing when configuring the tasks without AI last?

 

Thanks!

Barron
Applications Engineering
National Instruments
0 Kudos
Message 2 of 4
(2,922 Views)

Here is the sample program for Visual Basic 6. If you click on the left button, it will start the Ctr and AI tasks and the readings will be updated once a second.

Now, click the left button once to clear the tasks, and the second time - to restart the tasks. The readings resume as expected.

The bug occurs when you move the line ErrChk DAQmxCreateTask("ai0", hAI) before the line ErrChk DAQmxCreateTask("c0", hCtr).

Now, when you try to restart the tasks, readings do not resume.

0 Kudos
Message 3 of 4
(2,913 Views)

Thank you Victor for posting the code and explanation.

 

Regards,

Barron
Applications Engineering
National Instruments
0 Kudos
Message 4 of 4
(2,886 Views)