Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if a task is started already?

I need to check if a task that uses digital trigger to start sampling  has started before I enable the trigger source.

 

I came across a post http://forums.ni.com/t5/LabWindows-CVI/DAQmx-get-task-status/m-p/478759 saying that one can use DAQmxIsTaskDone to check, but the help file says DAQmxIsTaskDone returns one when the task is finished. But I want to check if it starts already before determining if it is finished. Anyone could suggest how to do it?

0 Kudos
Message 1 of 10
(8,030 Views)
anyone please help?
0 Kudos
Message 2 of 10
(8,006 Views)

I'd like to know of a *better* way, but here's a method that I've found useful on occasion.

 

You can query a DAQmx Read property node for the property named "Status->Total Samples Per Channel Acquired".  Any value >0 implies that the task is active and has already been triggered.  Not a perfect method, but it has worked fine for my apps. 

 

But doesn't it seem that the DAQmx Task property node should be query-able for this kind of "task state" info?

 

-Kevin P.

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 3 of 10
(7,991 Views)

Thanks Kevin, but this method can't work for me. I have to know the task has started before I can enable the pulse sequence to counter gate, so if I use Total Samples Per Channel Acquired, it will always return zero. I think there should be a way to check the task status.

0 Kudos
Message 4 of 10
(7,974 Views)

Ok, sorry.  I got thrown off by the term "digital trigger".  I was picturing an acq task with a start trigger and a separate sample clock.  Now I take it to be a regular counter period measurement task without a separate start trigger, right?

 

1. Here's an idea I just tried out successfully on a simulated DAQmx device.  Still assuming you have access to the task refnum, try calling "DAQmx Control Task.vi" with an 'action' input of "verify".   If the task has been started and is ready to react to the pulses you're ready to generate, this call will output an error.  Lack of error means the task hasn't been started.  Just be sure to check for this error without passing it along to the next function call.

 

2. There are probably a number of other DAQmx properties you could attempt to set which would produce a similar error result only when the task is already running.

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 10
(7,966 Views)

I am using C++ and I looked through the NI-DAQmx C reference file, but I couldn't find similar function as the vi you mentioned. Any idea how to realize it in C++?

0 Kudos
Message 6 of 10
(7,956 Views)

Best I can tell you is what I find when I tunnel down into the LabVIEW vi.

 

There's a call to a function named "DAQControl" in the file nilvaiu.dll.

 

The function prototype is:

int32_t DAQControl(uintptr_t taskID, int32_t mode, LStrHandle extendedErrorInfo);

 

- 'taskID' is the normal DAQmx task pointer.

 

- 'mode' has the following defined values:

2 - verify

3 - commit

4 - reserve

5 - unreserve

6 - abort

 

- extendedErrorInfo returns a LabVIEW string which is subsequently parsed/interpreted for error conditions

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 7 of 10
(7,947 Views)

unfortunately, there seems no similar functions in the DAQmx C library. Do you have idea about how long it will take for a task to be ready after DAQmxStartTask is called? Does it mean the task is started and completely ready when this function returns?

0 Kudos
Message 8 of 10
(7,927 Views)

I'd expect the task to be started and completely ready before the function call returns, though I can't be 100% sure for the C interface. 

As to the task control function, I saw a reference to something in another discussion that my prove useful.  It appears that the function is called DAQmxTaskControl, and some more info can be found here.

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 9 of 10
(7,898 Views)

These functions actually do exist in the C reference under Task Control -> Advanced. I'm also trying to find out how to do this and no luck so far.

0 Kudos
Message 10 of 10
(7,319 Views)