LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing data between while loops

Hello guys, can anyone provide me a solution aside from producer/consumer loop?

 

I have two parallel while loops running, however the first loop has some deep code calculation(contains loops and case structure in it) before it process the data that will be on the next loop, is there a way to get the updated data without using the producer/consumer loop? 

 

By the way, both loop is being triggered by a single button and both loops run and read for 100ms interval for other process if there is no press of a button.

 

Here is the flow of my program:

 

Press the button

on the first loop, get and compute the value

on the second loop, fetch that value and use it.

 

Reason for having two loops is for modularity purpose.

 

Thank you.

 

 

 

 

0 Kudos
Message 1 of 4
(3,953 Views)

Hi Nino,

 

why do you have two parallel loops, when the 2nd one is waiting for a value delivered by the 1st one?

 

You can use queues (as before with producer-consumer) or local variables, notifiers, AEs aka FGVs, global variables, shared variables, property nodes, DVRs, … to transfer data between loops. Each item has it's advantages and disadvantages!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(3,939 Views)

@Nino58 wrote:

Hello guys, can anyone provide me a solution aside from producer/consumer loop?


What's wrong with using Producer/Consumer?  It seems to meet your needs.  Though, in this case, I'm thinking the Notifier is what you really need.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 4
(3,917 Views)

From your problem descriprion, you are producing values in one loop and using them in the other - this is by definition a 'Producer-Conbsumer' architecture, so what makes the producer-consumer design pattern unsuitable? If you described the problem you have with the producer-consumer pattern then we could understand your requirement better.

 

Are you passing a stream of values from one to the other, or do you just calculate one value in the first loop and, when that has finished, pass it to the second? What data types are your values? Do you have a problem using a queue for some reason? I did not really understand your explanation "the first loop has some deep code calculation(contains loops and case structure in it) before it process the data that will be on the next loop" or why that would be a probelm.

0 Kudos
Message 4 of 4
(3,914 Views)