11-05-2009 04:15 AM
This is my first week working with LabView so the answer might be very simple.
Here's my question:
How do I include a slow loop (event B) inside a fast loop (Event A)?
What I would like is for Event B to execute every 1000 milliseconds and Event A every 100 milliseconds.
Where Event A is a position control loop and Event B is a simple write to file of some measurement.
Any recommendation on how i should accomplish this?
Solved! Go to Solution.
11-05-2009 04:32 AM
Put the slow loop outside the fast loop.
They will run in parallel.
11-05-2009 04:38 AM
Generally I handle this kind of requirement with the producer-consumer architecture.
The Producer/Consumer pattern’s parallel loops are broken down into two categories; those that produce data, and those that consume the data produced. Data queues (which are covered more in-depth in the Queued Message Handler section) are used to communicate data between loops in the Producer/Consumer design pattern. These queues offer the advantage of data buffering between producer and consumer loops.
Source Link: http://zone.ni.com/devzone/cda/tut/p/id/3023
11-05-2009 07:07 AM
You can use an Elapsed Time Express VI inside the fast loop to see if it's time to execute the slow loop. I took the liberty of not using a loop for your "event B" because it sounded like you just want to pace it with event A. Put event B in the True case of the Case Structure. The producer/consumer design pattern is the way to go if you're developing a complex application. This'll do if your problem is relatively simple.
11-05-2009 09:39 AM
Thanks for the solution
I also found that passing data between parallel loops with local variable could do the trick
11-05-2009 12:00 PM
Saguenay wrote:I also found that passing data between parallel loops with local variable could do the trick
Local variables can lead to race contitions, when they are be used for that reason.
Search for "race contitions" on this forum for more info.
Better use "function globals"
Do a little search