03-15-2013 11:32 AM
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)
03-15-2013 11:51 AM
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.
03-15-2013 12:10 PM
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.
03-15-2013 12:19 PM - edited 03-15-2013 12:27 PM
a simple loop control will do it.....any reason why you need to keep restarting the VI?
03-15-2013 12:30 PM
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.
03-15-2013 12:37 PM
@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.
03-15-2013 01:38 PM
@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
03-18-2013
09:05 AM
- last edited on
05-12-2025
09:13 AM
by
Content Cleaner
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
03-18-2013 09:14 AM
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.
04-03-2013 07:50 AM - edited 04-03-2013 07:50 AM
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.