I've been having some trouble exiting a For-loop conditionally. The problem is that when the loop is stopped conditionally (a button is pressed) the DAQ (NI USB 6353) outputs get stuck to whatever value they were in. I tried stopping the DAQ Assistant output task (1 sample on demand) before exiting the loop but that didn't solve the problem. Should this perhaps be done one iteration before exiting the loop or can it be done in the same iteration round?
What would be the "right" way to exit a for loop with output tasks so that the output signals would be 0V after exiting? I know that I could "force" feed the DAQ Assistant with 0V control before exiting but in this case that would be quite difficult...
Any ideas? Help is appriciated.
the "right" way would be to get rid of the DAQ-Assistent ( 😄 ) - and to stop the task after the loop has finished.
That way the task will get stopped regardless of premature/conditionally stopping of the loop…
Yes, I get it... However at this point I don't think that's an option.
Would this kind of solution work? ( I am not able to test all possible solutions in the real system which is why I would like to get a confirmation first)
The idea is to connect the output of the "Or" port to the "Stop" -ports of the DAQ Assistants in the loop.
Edit. Will the output automatically go to 0V if I just stop the task? I am not really sure about this.
why do you think stopping a DAQmx task after the loop is no option here???
Well yes - stopping the DAQAssistent twice might be a workaround too…
I quess that is an option then but what would it mean in practice? As you would expect the For-loop is inside a Case-structure which at this point has nothing else inside.
Should I copy all the DAQ Assistants into that Case-structure and wire the Stop-inputs of them with False-constants?
now is the time to show your VI to provide neccessary information…
In your first message you were talking about one DAQAssistent in one FOR loop you need to conditionally exit.
Now your are talking about several DAQAssistents in a loop in a case structure "with nothing else in it"…
Getting rid of DAQAssistent and using "usual" DAQmx functions is not that hard and greatly improves overall VI documentation…
I guess you're right, here's a picture of the VI. All the DAQ Assistants use "One sample on demand" -aqcuisition mode. Hope the picture clarifies.
the first thing that came to my mind when looking at that image: use Ctrl-U…
Then: why not use a case structure with "i" wired to its selector input?
And: Can't you use just one DAQAssistent for signal inputs? Why do you use two of them?
I tried the Ctrl + U but it just made it worse I think. 😄 Anyhow, I am aware that I should clean it up...
I am using 2 input DAQ Assistants because one of them is reading analog signals and the other one is reading a digital (pulse) signal. I assume that it is not possible to use just one DAQ Assistant in that case.
Then, what do you mean in practice with the "Case structure with "i" wired to its selector input"?
How does that help me with the correct task stopping when exiting the For-loop conditionally?
the case structure would make your VI much more cleaned up: on the left I imagine your two DAQAssistent reading new values. In the middle could be that case structure analyzing your data and preparing the output value for your 3rd DAQAssistent. No more all those comparison and select functions…
Btw. all you need is to output a zero (or whatever is your "safe" value) to that output channel(s) once after the loop - as already said in the first answer…