LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to pass a value from inside a while loop outside the loop

Hello to everybody, I have been searching through the forum but I have not found a certain answer for my problem. I would try to explain my problem as breefly as posible:

 

I have to send by a BNC2120 two signals and acquire an other one thats comes from a preassure sensor. That part is done by introducing simulating and acquiring DAQmx inside while loops.It is sycronized by my self, proving such diferent values (is not the optimum, but is only the first prototype) and works as I expected. Well, then I want to sample some of the values of these signals, that is done with relays and local variables to get the value in the instant I want to sample. Here begin my problems: I want to extract the sample values out of the while loops without restarting them, I mean: I do not want to stop the while loops because the acquisition and the generation of the signal must be continuous, but I do not know if it is posible to put the while loops in "standby" until I operate with the values I have sampled and then the signal generator and the acquiere continues from when it has stoped before. Particulary I want to obtain the value of the top while loop (inside a case) when the counter arrives at 15.

 

I have proved to do with local variables, global variables, making a state machine, with event cases, with flat secuences...I have been reading about and proving diferent posible solutions for this week and the whole past week and I have not found the solution.

 

If any of you know how I can do this thing, I would be loved to listen your opinions. My proyect is above: 

 

Thank you a lot in advance.

 

Sinceresly,

Miguel.

0 Kudos
Message 1 of 5
(4,225 Views)

it looks like you have problems with data flow....I do not think that you need multiple loops as this adds to your problems of controlling the information you need. i would try to make it all in 1 while (as you say, "continuous") loop state machine...this will be a very easy implementation to your code as events happen sequentially

 

 

if you can explain better in details what exactly you need to happen where and when and at what times, we can better understand what needs to be done in your code

0 Kudos
Message 2 of 5
(4,208 Views)

Use a producer/consumer architecture.  The producer is your measurement loop that runs continuously.  Pass data to the consumer loop by means of a QUEUE.

0 Kudos
Message 3 of 5
(4,201 Views)

It definately sounds like what you really want is a Producer/Consumer.  It is an architecture that uses Queues to pass data from a data generation loop (producter, your DAQ loop) and a data processor (consumer).


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 4 of 5
(4,181 Views)

Thank you a lot!!! It was actually the solution: Producer/consumer archytecture!!! It works as I have expected. Thank you a lot!!!

 

Best regards,

Miguel. 

0 Kudos
Message 5 of 5
(4,143 Views)