LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing a terminal inside a for loop

Hi,

I've just started using LabVIEW recently and have run into a serious snag
that is confusing me. The problem is this:

I have built a subVI which traverses an array of Strings.
The input is the array and also the time delay on the traversal (how much
to pause after each iteration).
The output is the String being accessed in the array at the current iteration.

This output (String indicator) is left inside the for loop and has been
attached to a terminal.

Inside the larger VI, I pass in the array as well as the delay value. I have
an indicator which is attached to the String output. This indicator receives
nothing from the subVI.

Everything else is working perfectly and the String shows up perfectly in the
subVI String in
dicator as I watch what happens in the subVI. Using the
Highlight Execution tool, I see that the path from the subVI String indicator
output terminal to the main program String indicator is never travelled.

What is going on here?

TIA,
Watson

PS ... I should also mention that this was working perfectly fine when the
entire operation was handled under one VI (not broken down into a sub). I
need the subVI modularization however to make everything work cleanly.
0 Kudos
Message 1 of 4
(2,844 Views)
Hi R.Watson,

This is a normal behavior of LabVIEW.
It waits until your sub-vi is finished before running the remaining part of your main vi. You cannot get the updated value of your sub vi this way. The best way in this case is to use a global variable that you update in your subVI and read in your main vi.

Cheers.

Doc-Doc
Doc-Doc
http://www.machinevision.ch
http://visionindustrielle.ch
Please take time to rate this answer
0 Kudos
Message 2 of 4
(2,844 Views)
Hi,

The sub VI does not return anything until it is done (just like a C routine
will not return anything until it is done).

If you sub VI's to communicate, you can consider a LV2 global (buffer VI) or
even a global, although a global is not recommended. If possible, you can
also rewrite your code so this is not necessary.

Regards,

Wiebe.


"r. watson" wrote in message
news:bf5de6be.0409011846.3d2b6a7f@posting.google.com...
> Hi,
>
> I've just started using LabVIEW recently and have run into a serious snag
> that is confusing me. The problem is this:
>
> I have built a subVI which traverses an array of Strings.
> The input is the array and also the time delay on the traversal (how much
> to pause after each iteration).
> The output is the S
tring being accessed in the array at the current
iteration.
>
> This output (String indicator) is left inside the for loop and has been
> attached to a terminal.
>
> Inside the larger VI, I pass in the array as well as the delay value. I
have
> an indicator which is attached to the String output. This indicator
receives
> nothing from the subVI.
>
> Everything else is working perfectly and the String shows up perfectly in
the
> subVI String indicator as I watch what happens in the subVI. Using the
> Highlight Execution tool, I see that the path from the subVI String
indicator
> output terminal to the main program String indicator is never travelled.
>
> What is going on here?
>
> TIA,
> Watson
>
> PS ... I should also mention that this was working perfectly fine when the
> entire operation was handled under one VI (not broken down into a sub). I
> need the subVI modularization however to make everything work cleanly.
0 Kudos
Message 3 of 4
(2,844 Views)
As Doc-Doc and Wiebe have already indicated, all portions of the main vi which are dependent upon data from the subvi will wait for the subvi to complete before execution. Code within the main vi which is parallel to the subvi (thus has no dependency upon the subvi) will continue to run as normal during exectution of the subvi. In order to use global variables to achieve this task you will need to place the indicator in a parallel loop to that in which the subvi is operating. Also, as Wiebe suggested, a LV2 style global is preferred to a standard global.

Another approach to your problem is to pass a reference of your main vi indicator that you're trying to update to the subvi. You can then use a property node in the subvi to write directly to the indicat
or on the main vi.
0 Kudos
Message 4 of 4
(2,844 Views)