LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting data from a while loop while running.

Hello,

I did a program that call a sub-VI which is doing experiment and have its own timer.
The sub-VI is a while loop and the stop condition of this loop is the elapsed time of my timer.

What I want to do is to be able to get the elapsed time in my main program during the execution of the sub-VI (every second of its execution).

First I assign the elapsed time in the sub-VI as an output of it. But of course the elapsed time is only updated in the main VI only when the while loop has finished. So I tried several solution: property nodes, local variable, global variable.

When I am using global variable, I can see the elapsed time being updated during the while loop when I open the global variable VI. But the result is always the same: in the main VI the elapsed time is only updated at the end of the while loop.
I think that is the global variable is updated every time, I could be able to get its data to my main VI?

Does anyone have an idea?

Thank you,

Meach
0 Kudos
Message 1 of 7
(3,119 Views)
Hello Meach,

I would recommend trying either a Shared Variable or using a queue.  Try doing a search or two for more info on these two topics and feel free to ask questions as they arise.

Regards
0 Kudos
Message 2 of 7
(3,108 Views)
Hi jmcbee,

What do you mean by Shared Variable? I search in the user manual and didn't find anything.

I will try to do something with queue operation and I will keep you in touch.

Thanks, Meach
0 Kudos
Message 3 of 7
(3,098 Views)
Or use a control reference. I suspect the reason that the globabl variable is not working is because in the main, it's in the same while loop as the subVI call. Are you using a single while loop without an event structure - just a case statement?
0 Kudos
Message 4 of 7
(3,097 Views)
I tried using shared variable and reference without succes.

I will keep searching.
I enclose my VI that I simplify the most but with still keeping the shape of my real program. If you can take a look I will really appreciate.
The goal is on the top-level VI to be able to see the updating data time in real time.

Thanks,

Meach


Message Edited by Meach on 07-23-2008 04:13 PM

Message Edited by Meach on 07-23-2008 04:14 PM
0 Kudos
Message 5 of 7
(3,064 Views)
In order for the indicators on the front panel of the top-level VI to be updated the sub-subVI needs a reference to these indicators so it can write to them. Otherwise, these indicators are not updated until the subVI "Multiple Timer Use" is done, and it only finishes when it goes through the entire sequence. You said you tried references, and I suspect you simply didn't use them properly. The "Multiple Timer Use" subVI would need inputs to accept control reference for the indicators to update. It just passes these along to the "Multiple Timer" VI. That VI writes to the "Value" property node.

If you open the Example Finder there's a VI called "Property Nodes" that shows you how to use references, and how to pass them to subVIs.

I'm not sure why you need to have the "Multiple Timer" VI set up with two timers. The way you're using it the timing check is sequential. In other words, you do the "Wanted Time", and then you do the "Wanted Relaxed Time". For this you just need one timer. Are you planning to run the VI in parallel to have two timers running in parallel?
Message 6 of 7
(3,053 Views)
Hi Smercurio,

Thank you for your answer. I tried it again with the reference and now it works. Before I did it using the "property node" example but I didn't understand it well. Now it's OK.
I have my time updating in real time in my front-panel of my top-level VI. Moreover I really understand how to use reference.

Concerning the timers I use, it was because it was more convenient for my application to have two timers like this. But I will take a look is there isn't an other solution easier.

Thanks,

Meach


0 Kudos
Message 7 of 7
(3,048 Views)