LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I transfer data between two while loops in parallel

Hello,

I have two while loops in parallel and I want to transfer data from the first to the second loop. The problem isthat data are transfered only when the first loop ends. I tried with queue but it doesn't work. How can I do, preferentially without global variable ?

Thanks.
0 Kudos
Message 1 of 9
(8,991 Views)

Hi

The queue is one way to go. Post the code you made using this technology. Maybe we can show you where there was a mistake.

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 2 of 9
(8,983 Views)
What is your second loop (the one that will consume the data) doing while the first loop is running? Can you post your VI or a screenshot of your code?  I would suggest using a queue or an event structure (with a user-defined event).  However, I think it depends on what kind of data it is and what your second loop is doing.

J

Jason King
LabVIEW R&D
National Instruments
0 Kudos
Message 3 of 9
(8,983 Views)
Hi Lounche,

Queues or Notifiers should do what you need. When you open LabVIEW, click on NEW this will open the templates dialog, and choose either the Producer/Consumer or Master/Slave design patterns.

These let you transfer data between loops. If you can get your head around the concept, it might be worth your while doing a LabVIEW Basics II at your local NI office as this deals with multiple loop architectures and problems you might encounter, such as race conditions.

Regards
JamesC
NIUK and Ireland

0 Kudos
Message 4 of 9
(8,982 Views)
I join a very simplified VI's because the real works with PXI, RT, ...
When you run the "secondVI.vi", no data comes in array from the "firstVI.vi".
As I said in my first message, I tried with queue too but it doesn't work, because when the terminal go out from the while loop, while loop have to be ended to send data.


0 Kudos
Message 6 of 9
(8,966 Views)
You do not have two while loops in parallel. The 'secondVI' is calling 'firstVI' as a subVI and your program doesn't make any sense. For one thing, you have not way to stop 'firstVI' once it starts because it will never get a stop condition from 'secondVI'. The subVI would have to be open and your main program does not open the front panel of the subVI. The only way to stop the main VI is with the abort button. You can simply put all of the code in thw subVI in an actual parallel while loop in your main and pass data in a queue as others mention when they assumed you were doing parallel loops. With the code that you hand in the subVI, though that doesn't make much sense either. Why don't you just put the Sine function in the while loop of your main VI?
0 Kudos
Message 7 of 9
(8,959 Views)

I'm sorry, I didn't see the difference, but after trying, I understand !

But the example was just an example, if I use 2 VI, it is because each of them are really complex and I wanted that my block diagram stay clear ! Now I understand that I have to put the 2 together in the same VI if I want that it works.

Thanks everybody for your help.

0 Kudos
Message 8 of 9
(8,937 Views)
No, you can still use subVIs but you wouldn't want to have a subVI where it has a while loop and a stop button. Or if you did have a while loop with a stop button, you would want to make that front panel visible so it could be clicked and stopped. Say you had your main VI with the existing while loop. In a completely separate while loop, you could call a subVI that passes data to the other while loop with a queue. There are many other methods for running subVIs in parallel with a main.
0 Kudos
Message 9 of 9
(8,931 Views)