03-30-2012 03:06 AM
Hello,
I made this counter, that counts from value x to value y.
This value I need in an other VI, so I made from this VI a subVI.
The counter value is needed in an other For loop to count with.
But the counter doesn't update his self every time, in that main VI.
How can I make the value frequently updated in that main VI without using a while loop.
If I put the global variable in a while loop it will update, but than the while loop will be executed constantly,
and the For loop won't be executed until the while loop is stopped.
Solved! Go to Solution.
03-30-2012 03:13 AM
Its tough to answer the question without seeing the while loop and the for loop without seeing the main vi you are talking about. Try to post that snapshots also.
03-30-2012 03:31 AM
If this is the main VI, than the value of x+1 doesn't update himself.
Inside the subVI the counter is counting, but the global variable and the "x+1" indicator don't show the counting,
only if I put them in a while loop. But I can't use a while loop it blocks other loops to run.
03-30-2012 03:33 AM
If the problem is to use the counter in several vi's, it might be easiest to simply use the global as a counter and read from that.
/Y
03-30-2012 04:20 AM
Hi Stef,
"Inside the subVI the counter is counting, but the global variable and the "x+1" indicator don't show the counting, only if I put them in a while loop."
If that's your problem: you have to obey the DATAFLOW paradigm. When you check the global only once, you will see no further updates. When you check the global frequently (in a loop) you will see updates.
"But I can't use a while loop it blocks other loops to run."
Why can't you? You should be able to use parallel running loops...
Hint:
- Go through the basics course offered by NI.
- Learn to think in DATAFLOW terms!
03-30-2012 11:04 AM
Reading/Writing with a global requires a loop in your top level VI. Using a reference and passing it to she subVI where you write to it's Value property does not.
03-30-2012 11:42 AM
So, what are you really triing to do with this?
03-30-2012 01:43 PM
@Stef_vl wrote:
If this is the main VI, than the value of x+1 doesn't update himself.
Inside the subVI the counter is counting, but the global variable and the "x+1" indicator don't show the counting,
only if I put them in a while loop. But I can't use a while loop it blocks other loops to run.
Have you tried turning on execution highlighting (the lightbulb on the BD menu bar). It will show when values are moving and give you an idea of how data flow is really working.
Ben
03-30-2012 02:14 PM
Here is how I would do it using an AE (action Engine)
03-31-2012 05:32 AM
Ofcourse they dont show anything. You have a loop in a sub vi, and the result you get out is the end result once it stops executing. That's basic dataflow.
Your counter2 reads the global variable once and shows the result, it doesn't automagically follow and update from the global variable. That's basic dataflow.
Your program does exactly what you told it to do. That it makes little sense is not basic dataflow. 🙂
Run the program in highlight mode and it should be quite obvious. But main and sub-vi.
/Y