04-16-2014 01:47 AM
Hi,
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.
04-16-2014 02:17 AM - edited 04-16-2014 02:17 AM
04-16-2014 03:34 AM - edited 04-16-2014 03:37 AM
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.
Thank you.
04-16-2014 03:50 AM
04-16-2014 03:58 AM
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?
04-16-2014 04:03 AM - edited 04-16-2014 04:03 AM
Hi Aleksi,
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…
04-16-2014 04:21 AM
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.
04-16-2014 04:25 AM
Hi Aleksi,
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?
04-16-2014 04:32 AM
Hi,
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?
04-16-2014 04:36 AM - edited 04-16-2014 04:37 AM
Hi Aleksi,
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…