LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exchanging data between parallel runnig vi's

Hi,

for my work with DAQ cards i wants to implement the GUI and data
acquisation in two seperated vi's. Both vi's will be started at the
beginning of the program. My first question was, how i could exchange
the data between these. Meanwhile i looked inside the examples help
pages and found one which uses notifications. I just tried this way and
all worked fine. My question now: Is this a good and fast way or are
other possibilities in LabVIEW which works more efficient?
0 Kudos
Message 1 of 11
(5,051 Views)
Datasockets work very well to excahnge data between VIs running on different
networked computers. You should be able to transfer data between two VIs
on the same computer in the same fashion, using 'localhost' in the address
for both. You would also have to run the Datasocket Server on the computer.
Later on, if you want to run your GUI and data acquisition programs on different
networked computers, the address change would be minor. Look at the datasocket
example VIs.

Mark wrote:
>Hi,>>for my work with DAQ cards i wants to implement the GUI and data>acquisation
in two seperated vi's. Both vi's will be started at the>beginning of the
program. My first question was, how i could exchange>the data between these.
Meanwhile i looked inside the exa
mples help>pages and found one which uses
notifications. I just tried this way and>all worked fine. My question now:
Is this a good and fast way or are>other possibilities in LabVIEW which works
more efficient?
0 Kudos
Message 2 of 11
(5,051 Views)
you could try using queues.
"Mark" wrote in message
news:3A0A7614.1ED5E15C@hotmail.com...
> Hi,
>
> for my work with DAQ cards i wants to implement the GUI and data
> acquisation in two seperated vi's. Both vi's will be started at the
> beginning of the program. My first question was, how i could exchange
> the data between these. Meanwhile i looked inside the examples help
> pages and found one which uses notifications. I just tried this way and
> all worked fine. My question now: Is this a good and fast way or are
> other possibilities in LabVIEW which works more efficient?
0 Kudos
Message 3 of 11
(5,051 Views)
Hallo,

you can try this:

pass data over a global variable and control your application via
occurences.

Good Luck
chris

Mark wrote:
>
> Hi,
>
> for my work with DAQ cards i wants to implement the GUI and data
> acquisation in two seperated vi's. Both vi's will be started at the
> beginning of the program. My first question was, how i could exchange
> the data between these. Meanwhile i looked inside the examples help
> pages and found one which uses notifications. I just tried this way and
> all worked fine. My question now: Is this a good and fast way or are
> other possibilities in LabVIEW which works more efficient?

--

( o o )
( O )

#
# mailto: harboeck@in.tum.de
# www: www.in.tum.de/~harboeck
# phone: (089) 323 21 21
#
0 Kudos
Message 4 of 11
(5,051 Views)
Hi,

that sounds better but with global variables i have the next problem! If
i acquire the data and store it in the first vi and the second wants to
read at the same time i would get mixed data. That could be fatal
results! I have to take care only one vi has access to the global data.
Can i use semaphores or something else that this will work?

regards
Mark


Christian Harböck wrote:
>
> Hallo,
>
> you can try this:
>
> pass data over a global variable and control your application via
> occurences.
>
> Good Luck
> chris
>
> Mark wrote:
> >
> > Hi,
> >
> > for my work with DAQ cards i wants to implement the GUI and data
> > acquisation in two seperated vi's. Both vi's will be started at the
> > beginning of the program. My first question was, how i
could exchange
> > the data between these. Meanwhile i looked inside the examples help
> > pages and found one which uses notifications. I just tried this way and
> > all worked fine. My question now: Is this a good and fast way or are
> > other possibilities in LabVIEW which works more efficient?
>
> --
>
> ( o o )
> ( O )
>
> #
> # mailto: harboeck@in.tum.de
> # www: www.in.tum.de/~harboeck
> # phone: (089) 323 21 21
> #
0 Kudos
Message 5 of 11
(5,051 Views)
> that sounds better but with global variables i have the next problem! If
> i acquire the data and store it in the first vi and the second wants to
> read at the same time i would get mixed data. That could be fatal
> results! I have to take care only one vi has access to the global data.
> Can i use semaphores or something else that this will work?
>

This is a good thing to be aware of, but LV makes this much
easier than most languages. Reads and writes of global,
local variables, and all other nodes that access data are
atomic operations. You will never have problems with them
overwriting one another. However, many times what people
are doing is appending to a array. This means that you will
be reading, modifying, and writing for the write operation,
and this definitely isn't atomic. The read operation is
also commonly a read and clear, and it also isn't atomic.

There are two easy ways to deal with this. You can use the
semaphores in the advanced palette to lock around the
compound read and compound writes. An even easier, and
more common solution is to use what is normally referred
to as a LaVIEW 2 style global. The name is historical and
due to the fact that there weren't globals built into LV
before version 3, so people built their own.

What is really built is a functional global, or a
functional interface or accessor function for static
data. It's a subVI that has an operation or mode
selector, one or more data inputs, and one or more
data outputs. On the subVI's diagram is usually a loop
with an uninitialized shift register to store the data
in. Inside the loop, place a case statement with a
mode selector wired to it. In the write frame, place
the write control and wire it out and into the right
shift register. Wire the left shift register into the
case statement, through a tunnel. Wire it through the
write frame, and in the read frame, wire the left data
to the indicator that will return the data. Assuming
that your are clearing the data, wire an empty array or
string to the right shift register.

There are lots of other things that you can do with this,
make other operations or modes, have optional inputs, more
outputs, etc. The reason this works nicely is that each
VI acts as a critical section. As long as it isn't
reentrant, only one call can execute at a time. There
is overhead for the function overhead, but it is quite
small.

Greg McKaskle
0 Kudos
Message 8 of 11
(5,051 Views)
Hi Greg,

thats sound wonderful. I will give it a try!
Could you give me also an answer to my question which lays 2 entries
lower and has to do with control references? It's really necessary for
me to know!

Thnx,
Henrik
0 Kudos
Message 9 of 11
(5,051 Views)
For all of you who use LV 6, you can use a control reference. You would
make a referece to a control in your GUI vi, and pass that reference to
the DAQ vi. So when your DAQ vi runs, it will send its values to the
control reference, and the GUI vi will automatically update. You can do
the same thing with a stop button, if you want to stop both vi's at
once.

What you can do:

1. Put something at the beginning to set everything up if you need to.

2. In your "main loop" of your GUI, make two SEPERATE loops. One holds
the GUI updating code, and the other just runs the DAQ vi. That way,
the GUI loop can still run while data is being taken.

I used this method with global variables, and it works very well. But,
if you use global variables, be VERY careful t
hat you avoid race
conditions.


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 6 of 11
(5,051 Views)
ok, but how to do that, when i have more then one GUI window?

When i start the program the DAQ-vi should be started and run till the
program is closed. At the same time my main GUI window will appear where
the user can see the DAQ-inputs and can edit some preferences for
running the sequence. When you press the start button a new window will
be open which process the sequence. There i haven't indicators but have
to use it for calculations. This window should be an modal dialog with
the reason that nobody has access to the main vi. In this case i would
prefer to use global variables with semaphores.

Additionally is it possible to update the DAQ-data inside the main GUI
during the sequence is running? Could i make this with control refernces
from my seque
nce vi? For that way i could pass the needed control
references to the sequence vi and update the controls from there. Or
won't the controls will be updated cause the sequence is a modal dialog?

Help would be nice
REgards
HEnrik
0 Kudos
Message 7 of 11
(5,051 Views)
....
> Additionally is it possible to update the DAQ-data inside the main GUI
> during the sequence is running? Could i make this with control refernces
> from my sequence vi? For that way i could pass the needed control
> references to the sequence vi and update the controls from there. Or
> won't the controls will be updated cause the sequence is a modal dialog?
>

There are a couple ways to keep the modal dialog from blocking the main
GUI. One way is to have your DAQ subVI or parallel loop updating the
indicators through control references. Beware that too much indicator
updating through references can really complicate your application in
terms of debugging. To get the references to the DAQ loop, bundle the
references and pass them in first.


The other way to keep the GUI alive while the modal dialog up is to call
it in parallel and not wait for the dialog to complete. One way is to
have a parallel loop that waits for an occurrence or semaphore, when set
it puts up the modal window, and goes back to sleep on the occurrence or
semaphore when it returns. The GUI loop is independent of that and
doesn't directly call the subVI, instead it sets the occurrence or
semaphore. Same thing goes for the DAQ loop, make it independent. Now
you can use LV2 style globals for anything that needs to be shared
between the loops. Obviously there are lots of inbetween areas where
you can use some references, some LV2 style globals, some GOOP objects.
The communication between parallel loops is pretty much independent of
how you make them independent or what runs in parallel.

Greg McKaskle
0 Kudos
Message 10 of 11
(5,051 Views)