LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exiting a while loop, then restarting the loop

I have a DAQ measuring a voltage from a vibration sensor.

 

I want to be able to exit the loop when either of two conditions are met. After exiting, I want to start a trigger which writes data to a spreadsheet, then restart the loop.

 

I think I want to have the additonal processing in a second loop which runs a maximum of one time when triggered by the first loop. I'm just not sure how to set this up.

 

If I'm missing something, or this is explained elsewhere and I just have not been able to find it, I'd appreciate any feedback you can give me.

 

The two conditions I want to check against are circled. (I have attached the full vi as well)

 

example.png

 

 

0 Kudos
Message 1 of 10
(3,450 Views)

One way this could be implemented is by using a "state machine" where the data is acquired in one state, a transistion occurs to writing the data when the trigger value is met, then it transistions back to data capture. Another is to have the data acquistion in one loop, and have another loop, waiting for a trigger, where the data is saved. This is called a producer/consumer configuration.

 

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 2 of 10
(3,445 Views)

I agree with the Producer/Consumer thought.  You have the one loop acquiring data and when the condition is met, you send the data to save into a queue.  This can be done in a case structure, so "restarting" of the loop isn't necessary.  Then you have another loop sitting there waiting for data to come down the queue and save it when it gets it.


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 10
(3,437 Views)

a simple loop control will do it.....any reason why you need to keep restarting the VI?

simple_VI_BD.png

0 Kudos
Message 4 of 10
(3,429 Views)

Not particularly. Guess it would make sense to have the data gathering loop running continually, then have it hand off the request to the consumer loop whenever a trigger condition was met.

 

0 Kudos
Message 5 of 10
(3,421 Views)

@sdzafovic wrote:

Not particularly. Guess it would make sense to have the data gathering loop running continually, then have it hand off the request to the consumer loop whenever a trigger condition was met.

 


you can just stick the code into your VI loop or as mentioned...or do a consumer loop if you understand the concept. Smiley Wink
0 Kudos
Message 6 of 10
(3,414 Views)

@sdzafovic wrote:

Not particularly. Guess it would make sense to have the data gathering loop running continually, then have it hand off the request to the consumer loop whenever a trigger condition was met.

 


This depend on the amount of data you're gathering. If you run this vi continuously it will cause a use of memory build up as the arrray grows bigger and bigger. Producer/Consumer is a better approach.

 

Ben64

0 Kudos
Message 7 of 10
(3,396 Views)

Hi sdzafovic,

 

I agree that a state machine or producer/consumer loop setup would be a good idea to implement.  For your reference, here are links to our documentation on how to implement these strategies.  After reading through the documentation, you can decide which architecture (if either) might best support your needs and we can give you support to get it working.  Check back in and give us an update when you can!

 

Application Design Patterns: Producer/Consumer

 

Application Design Patterns: State Machines

| Zach J. | Systems Engineer, HIL and Test Cells | National Instruments |
0 Kudos
Message 8 of 10
(3,370 Views)

I am currently looking over Application Design Patterns: Producer/Consumer as well as the presentation on Application Design Patterns. Think I will be going that route.

0 Kudos
Message 9 of 10
(3,362 Views)

OK, the first step required stopping the loop when the fault threshold was detected. Now we are going on to the next stage of testing and we will be implementing a multiple loop architecture. Have not decided on a producer/comsumer loop or a state machine at this point. I'm sure I'll be back to figure out eactly how to implement that.

 

Thanks for the replies.

0 Kudos
Message 10 of 10
(3,308 Views)