LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to pass argument by pointer to a VI.

Hello experienced LabView user!
1) How to pass an array to a sub-VI without dupplicated all the array. (If I
look tha array input terminal of the subVI after executing it, I see all the
data in the array control.
2) If you have an indicator connected to an output terminal of your main VI,
is it possible to change this indicator connected to an input of sub VI in
the sub VI without connecting an output of the sub VI to a local variable of
this indicator.

Thanks!
0 Kudos
Message 1 of 4
(4,511 Views)
> Hello experienced LabView user!
> 1) How to pass an array to a sub-VI without dupplicated all the array. (If I
> look tha array input terminal of the subVI after executing it, I see all the
> data in the array control.

It doesn't work to treat these the same as C or other languages with pointers.
If you leave the subVI open, then a copy of the array will be made so that
you can see and manipulate it. If the subVI is closed, then it likely won't
need a copy depending on what happens on the diagram.

> 2) If you have an indicator connected to an output terminal of your main VI,
> is it possible to change this indicator connected to an input of sub VI in
> the sub VI without connecting an output of the sub VI to a local variable of
> this indicator.
>

Reading and wri
ting to the indicator for the side effect of what shows on
the panel, is pretty much what locals were invented for. They allow you
to read and write to the control. This isn't necessary in cases where
the interface isn't the main goal. I'm jumping to conclusions here, but
often this question indicates that the control or indicator is being used
for storage instead of for viewing the data. If this is the thinking,
then try to get used to using wires instead because it allows LV to
perform many more optimizations and also avoids race conditions and the
like.

Greg McKaskle
0 Kudos
Message 2 of 4
(4,511 Views)
Greg McKaskle a écrit dans le message <37A118A2.E7285E8E@austin.rr.com>...
>> Hello experienced LabView user!
>> 1) How to pass an array to a sub-VI without dupplicated all the array.
(If I
>> look tha array input terminal of the subVI after executing it, I see all
the
>> data in the array control.
>
>It doesn't work to treat these the same as C or other languages with
pointers.
>If you leave the subVI open, then a copy of the array will be made so that
>you can see and manipulate it. If the subVI is closed, then it likely
won't
>need a copy depending on what happens on the diagram.
>


But the subVI is not realy a subVI but a VI running in parallel.
My problem is to share a big array between 2 parallel VI with real time
constraints.
So I can't use global va
riable which are too slow.
Both VI are loaded at the same time and use notification to communicate
together. (Front panel of the second isn't visible)
The big array is build in the first VI and use by the seconds after
notification.
If the first VI sends the array to te second using "Set control" method,
data are dupplicated and I loose too much memory.
Perhaps can I developp a DLL to manage the shared array.
But is there a good method in LV to properly share the same array between VI
with my constraints.

Thanks to your help.
0 Kudos
Message 3 of 4
(4,511 Views)
> But the subVI is not realy a subVI but a VI running in parallel.
> My problem is to share a big array between 2 parallel VI with real time
> constraints.
> So I can't use global variable which are too slow.
> Both VI are loaded at the same time and use notification to communicate
> together. (Front panel of the second isn't visible)
> The big array is build in the first VI and use by the seconds after
> notification.
> If the first VI sends the array to te second using "Set control" method,
> data are dupplicated and I loose too much memory.
> Perhaps can I developp a DLL to manage the shared array.
> But is there a good method in LV to properly share the same array between VI
> with my constraints.
>

The long version of the response is in private email, because I read it first
and don't want to type it again. The short version of the response is ...

LV2 style globals. Functional globals that use a shift register to store
the information and an Operation input along with several other parameters
to select data to be returned. This speeds up execution when only a subset
of the global needs to be accessed, and it therefore reduces the memory being
used to what is needed. The most important usage, though, is to eliminate
race conditions, where both loops are trying to read, modify, write to the
global in parallel. By making each of these into a read left shift register,
modify the value, write to the right shift register, that is located
inside of
a non-reentrant VI, you protect that operation from interruption from another
operation on the same storage. I believe that the examples still
explain how
to make and use these functional globals.

If you do the same thing in a DLL, you will have slightly less overhead
per call,
but it will be more difficult to write. It should use the same amount
of memory,
and don't forget to make it non-reentrant or use a mutex or critical
section to
protect parallel accesses or you are just moving the race condition from the
diagram to the DLL.

Greg McKaskle
0 Kudos
Message 4 of 4
(4,511 Views)