Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx task stop-start

My task: to stop the DAQmx task at the user's request and then restart it. Since the configuration does not change, I decided not to recreate the task, but to use the existing one.

And as a bonus, after stopping, “reset” the outputs to 0 for safety.

 

I found out that there is no common standard solution, so they advise to stop -> write 0 -> stop again (see here and here)

 

But It turned out that the Stop function, although the help says that it returns the task to a “prestarted state"

stop-help.png

stops in a strange way, so that nothing can be written to the buffer afterwards: spaceAvail indicator shows 0 after stop. And Write VI returns error.

stop-start.png

 

 

How do I correctly set the output value to 0 before stopping the task?

How do I stop the task so that it can be restarted after a while?

 

Attached example VI is the same as snippet.

0 Kudos
Message 1 of 5
(100 Views)

You need to write a data before starting the task. Hence the KB actually recommends Write -> Start -> Stop

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
-------------------------------------------------------
https://github.com/ZhiYang-Ong
0 Kudos
Message 2 of 5
(80 Views)

The fact that you're explicitly advancing to the "Committed" state prior to task start might be playing a role here.  I'm not sure I've ever used commit-before-start on a buffered output task, only on input tasks.  There, it's primary value was to speed up a subsequent stop-restart cycle, often to support repeated triggerings on a device that didn't support retriggering natively.

 

When you stop a task that was pre-committed, the task reverts only back to the "Committed" state.  I *think* this implies that the size (and maybe also the the contents?) of the output buffer remains unchanged.  So it *might* prove prudent to write an entire buffer full of 0 values before restarting the task, rather than the minimal 2 values illustrated in the KB article at your 2nd link.

 

I *think* it would be the case that simply stopping and restarting would generate the former buffer contents one time, followed by an error (because you disabled regeneration).   My *guess* is that it would restart the generation from the beginning of the buffer rather than from the point where the prior task run left off, but that's only a guess as I don't have hardware available to test.

 

If you don't have a specific need for the pre-Commit, you might find it easier to get the overall stop-restart behavior you want by leaving it out.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 3 of 5
(43 Views)

@ZYOng wrote:

You need to write a data before starting the task. Hence the KB actually recommends Write -> Start -> Stop


I tried different combinations.
You may notice that the task has an “autostart” constant.
I added that start before recording to see if the “available space” value would change. No, it does not change; it equals 0 immediately after the task stops, regardless of whether the task is paused or running.

0 Kudos
Message 4 of 5
(37 Views)

@Kevin_Price wrote:

The fact that you're explicitly advancing to the "Committed" state prior to task start might be playing a role here. 


I will try that way. 

0 Kudos
Message 5 of 5
(34 Views)