05-15-2012 12:34 PM
05-15-2012 12:42 PM
This is my original main VI.
05-15-2012 12:50 PM
You could try setting up your subVI so that it only executes the while loop one time. You could put put the stop button onto the connector panel. Wire a true constant into the subVI on the main diagram. Now the subVI will be setup to stop after the while loop executes only one time.
It's a bit of a hack. And if you forget to wire in a true constant to when you use it as a subVI, then the subVI is going to run for ever with no way to stop it just like it is doing to you now.
A better idea would be to rebuild your subVI so that it behaves like a true subVI with no while loop. Abstract out the portions of the code into their own subVI's. (You could even set things up like an Action Engine so things like VISA references can be stored.) Use those subVI's in your new main program. If you want to use things stand alone, like you are now, then the original subVI will have the while loop and use the same subVI's for the different portions of code.
05-15-2012 01:21 PM
05-15-2012 01:28 PM
05-15-2012 01:54 PM
05-15-2012 02:21 PM
@Bombbooo wrote:
Setting a true contant to wire to the while in the sub vi is fine but i think it will acquire data only once from the DAQ which i don't prefer.
I want the data to keep flowing and being saved in the till the user stops.
Sorry I didn't really understand the second method. Could you make some adjustments in the sub vi?
But your new main VI has the while loop which will cause it to acquire data repeatedly.
I can't make adjustments to your code.
Your code will have essentially 3 critical parts. Initialize and open the port, write data to and/or read data from the port possibly doing some analysis on it, and close the port. Make 3 subVI's that do each of those things. (Or make one subVI that has an enum command going into it and each of those three things will be in different cases of a case structure.
In your original "subVI" that ran as a top level, replace the code in their with the appropriate subVI's. In you new main VI, call each of these 3 lower level subVI's at the appropriate place.
Don't try to force a square peg into a round whole by trying to use your original "subVI" in your new main VI.
05-15-2012 05:39 PM
@Bombbooo wrote:
According from what you have said, its impossible in this case?
FIX your main VI so that the acquisition VI is called in the main while loop. That's the loop that runs until you click the stop button.
05-16-2012 02:51 AM
Hi Bombbooo,
from my point of view, it would be the best solution to follow Dennis_Knutson advice.
In generally, it would be the best solution to think about a new application structur for your application and create every SubVI accordingt to the application structur. It is much more difficult to rework existing VIs for new requirements, instead of wirting the code for a planed application structur.
05-23-2012 05:03 AM
Here is what I have done to combine all VIs together. It should work because I modified the sub VI not to have a while loop. When i tried to connect my main VI to the test bench, it didn't acquire data from it. The error was shown "Property Node (arg 1) in VISA Configure Serial Port (Instr).vi-", even though it worked with my original sub VI. It shouldn't cause from any ports or any computer systems. Any ideas? Thank you