LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous output from one VI to another?

Hi all,

I have one VI which reads commands (one line at a time) from text file, puts
them into 1D array, then reads them from array to string one element at a
time with some delay. Second VI is supposed to take those values from string
(i.e. string in the first VI is the input to 2nd VI) and send them to
controller via command port.
First VI works fine - I can see commands appearing one after the other in
string output. The problem is when I am trying to see the value of the same
string in 2nd VI - it waits for all delays and then only outputs LAST
COMMAND from the file.
Could anyone point where I am making a mistake?

Thank you!

viperz (at) mail (dot) com
0 Kudos
Message 1 of 7
(3,717 Views)
VI 1
1. Read text file to array.
2. Peel off one command at a time.
3. Place peeled off command into a queue.

VI 2

1. Wait until queue has an element.
2. Remove element from queue and send to controller.
3. Repeat.

Your application is good for a queue. The two vis must reside side by
side on the calling vi, with no input-output dataflow dependency. So
really, they both share the queue reference input, and they both run
concurrently.

In your code, I suspect that VI 1 outputs a string to VI 2. This
establishes dataflow dependency and VI 1 will complete execution before
VI 2 runs. Imagine a tree structure where the top vi is at the root, and
lower nodes run because they have input data from parent nodes. I think
you have it set up such that the reader
vi is the parent of the
controller vi, but you want it set up so that the reader and controller
are at the same level in the tree. The queue allows them to communicate
(and also a global variable).



Eugen T wrote:
> Hi all,
>
> I have one VI which reads commands (one line at a time) from text file, puts
> them into 1D array, then reads them from array to string one element at a
> time with some delay. Second VI is supposed to take those values from string
> (i.e. string in the first VI is the input to 2nd VI) and send them to
> controller via command port.
> First VI works fine - I can see commands appearing one after the other in
> string output. The problem is when I am trying to see the value of the same
> string in 2nd VI - it waits for all delays and then only outputs LAST
> COMMAND from the file.
> Could anyone point where I am making a mistake?
>
> Thank you!
>
> viperz (at) mail (dot) com
>
>
0 Kudos
Message 2 of 7
(3,717 Views)
I'd really appreciate if you'd explain how to run two VIs concurrently as
you suggested, so that I wouldn't have input-output dataflow dependency.

Thank you very much.


"Cult of Nurse's" wrote in message
news:3FC0C6C3.8030401@health.com...
> VI 1
> 1. Read text file to array.
> 2. Peel off one command at a time.
> 3. Place peeled off command into a queue.
>
> VI 2
>
> 1. Wait until queue has an element.
> 2. Remove element from queue and send to controller.
> 3. Repeat.
>
> Your application is good for a queue. The two vis must reside side by
> side on the calling vi, with no input-output dataflow dependency. So
> really, they both share the queue reference input, and they both run
> concurrently.
>
> In your code, I suspect that VI 1 outputs a string to VI 2. This
> establishes dataflow dependency and VI 1 will complete execution before
> VI 2 runs. Imagine a tree structure where the top vi is at the root, and
> lower nodes run because they have input data from parent nodes. I think
> you have it set up such that the reader vi is the parent of the
> controller vi, but you want it set up so that the reader and controller
> are at the same level in the tree. The queue allows them to communicate
> (and also a global variable).
>
>
>
> Eugen T wrote:
> > Hi all,
> >
> > I have one VI which reads commands (one line at a time) from text file,
puts
> > them into 1D array, then reads them from array to string one element at
a
> > time with some delay. Second VI is supposed to take those values from
string
> > (i.e. string in the first VI is the input to 2nd VI) and send them to
> > controller via command port.
> > First VI works fine - I can see commands appearing one after the other
in
> > string output. The problem is when I am trying to see the value of the
same
> > string in 2nd VI - it waits for all delays and then only outputs LAST
> > COMMAND from the file.
> > Could anyone point where I am making a mistake?
> >
> > Thank you!
> >
> > viperz (at) mail (dot) com
> >
> >
>
0 Kudos
Message 3 of 7
(3,717 Views)
Just place one VI on the diagram of the other, outside any loops etc; or place them both on the diagram of a third VI. Remember how dataflow works in LabVIEW: each function, subVI or structure will only execute when the data has arrived at all its wired inputs and not before, and data only emerges on the output wires when it has finished (watch a VI running with execution highlighting turned on to see this in action). LabVIEW automatically shares the processor between the different tasks that are running at any moment.

Bear in mind that this means you can't control what order things happen in a LabVIEW program unless you make it explicit using dataflow - for example, by wiring an output from one VI to the input of another (file handles and error wire
s are a good example of this). In your case you need to make sure you have created the queue before either of your two loops tries to use it, which you can do by wiring the queue reference as an input to your subVI(s).
0 Kudos
Message 4 of 7
(3,717 Views)
Could anyone show me a VI example how to implement this type of queue? I put
both files in another VI; created queue in that VI and trying to write to
queue from one file and read to another, but getting same problem.
I found an example of implementing queue in NI developer's zone, but it is
really complicated 😞

"tmh" wrote in message
news:506500000005000000FA3C0100-1068850981000@exchange.ni.com...
> Just place one VI on the diagram of the other, outside any loops etc;
> or place them both on the diagram of a third VI. Remember how dataflow
> works in LabVIEW: each function, subVI or structure will only execute
> when the data has arrived at all its wired inputs and not before, and
> data only emerges on the output wires when
it has finished (watch a VI
> running with execution highlighting turned on to see this in action).
> LabVIEW automatically shares the processor between the different tasks
> that are running at any moment.
>
> Bear in mind that this means you can't control what order things
> happen in a LabVIEW program unless you make it explicit using dataflow
> - for example, by wiring an output from one VI to the input of another
> (file handles and error wires are a good example of this). In your
> case you need to make sure you have created the queue before either of
> your two loops tries to use it, which you can do by wiring the queue
> reference as an input to your subVI(s).
0 Kudos
Message 5 of 7
(3,717 Views)
Take a look at this queue example - it is less complicated and shows the relationship between the queue producer (your first VI) and the queue consumer (the second VI).
Queue to Pass Data example program:
http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E04F56A4E034080020E74861&p_node=DZ52071&p_submitted=N&p_rank=&p_answer=&p_source=External

Hope this helps-
Julie S.
0 Kudos
Message 6 of 7
(3,717 Views)
Yeah, that's the queue example that I was looking at. It looks overly
complicated (special files created for creating queue, queing element and
dequeing elements). Do I really need to get that complicated?


"Julie S" wrote in message
news:5065000000050000003C3D0100-1068850981000@exchange.ni.com...
> Take a look at this queue example - it is less complicated and shows
> the relationship between the queue producer (your first VI) and the
> queue consumer (the second VI).
> Queue to Pass Data example program:
>
http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E04F56A4E034080020E74861&p_node=DZ52071&p_submitted=N&p_rank=&p_answer=&p_source=External
>
> Hope this helps-
> Julie S.
0 Kudos
Message 7 of 7
(3,717 Views)