07-02-2018 07:00 AM
Hello Community,
I have a very simple VI which generates a signal and write it to one my Analog Outputs. I'd like to keep the signal generation going even if the VI is finished its execution, but with the current code it stops when the VI stops.
(Test case: I need to generate the DC + ripple voltage and then perform several measurements. I must use Teststand so it seems logical that I start the signal generation in step1 and then perform the measurments in step2, step3... etc. But currently it seems that once step1 is finished the signal generation finishes as well.)
Is there a way to keep the signal generation on after I have finished my VI? If yes, what would be that. If not what would be the proper approach to handle this problem?
Thanks.
07-02-2018 07:09 AM
Two changes will do it. First, put Start Task before the Write. Second, since you want to do multiple Writes until, say, you push a Stop button, put the Write inside a While Loop with a Stop Button wired to the Stop indicator. Note you might want to put a Stop Task and/or Clear Task after the While Loop exits.
Bob Schor
07-02-2018 07:18 AM - edited 07-02-2018 07:40 AM
Probably I was not that clear, so let me rephrase the problem:
So my real problem is that the signal generation finishes once this VI is completed and my question is if I can write a code which sets my PXI AO channel to keep generating the signal even if the VI is done. (My PXI environment is non RT)
thx.
07-02-2018 08:00 AM
LabVIEW's central "Principle of Data Flow" means that you can Talk and Chew Gum at the Same Time, i.e. you can do tasks in parallel. In particular, you could use the Producer/Consumer Design Pattern to have your main TestStand routine be the Producer, and a parallel Loop, acting as a Queued State Machine with states Setup (to initialize the DAQmx code), Start (to start the Task running), Stop (to, perhaps temporarily, stop the Task), and Quit (the final call, which clears the Task and stops the Consumer). The Producer calls Setup early, then when it wants the Stimulation to start, puts Start on the Queue. [I'm using an Enum with the four values Setup, Start, Stop, and Quit to make the code more mnemonic and self-documenting].
Bob Schor
07-02-2018 08:06 AM - edited 07-02-2018 08:09 AM
Yes, I am aware of the parallelism in LabVIEW. But as I have my test steps in teststand already, it does make sense to reuse them instead of compile them into one VI. So thanks for your thoughts, I certainly appreciate them, but the question remains the same: is it possible to keep the signal generation going after my VI above finished?
07-02-2018 09:04 AM
With the code as written, I think the answer's NO. Much like what would happen if you ran the code in the LV development environment or as an executable. The vi stops executing and once it leaves the run state, the LV runtime engine will start freeing up the resources the vi used, including DAQmx task resources.
You'll need some version of what Bob_Schor recommended. Some way to launch free-running code that keeps the AO generation vi in run state, and some further way to signal to that free-running code when it's time to quit.
-Kevin P
07-02-2018 10:56 AM
I'm no expert in TestStand, but I recall you can run a step as a parallel process. But you have to modify the current code you have to run in a loop, and to get some kind of signal to let it know it's time to quit.
It's probably a lot easier to modify the code to use the Consumer/Producer design pattern than to get two separate VIs to communicate with each other via TestStand.
07-03-2018 01:31 AM
Thanks folks. Yeah a producer-consumer or master-slave would be nice, but I probably have to go with TS + parallel sequences and using notifiers.