09-23-2025 05:27 PM
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"
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.
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.
09-23-2025 08:48 PM
You need to write a data before starting the task. Hence the KB actually recommends Write -> Start -> Stop
09-24-2025 07:00 AM
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
09-24-2025 07:17 AM
@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.
09-24-2025 07:21 AM
@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.