11-15-2016 04:08 PM
Hi there,
I was wondering how can I start and stop "Write to measurement file" in two parallel while loops at exactly the same time?
I know using time stamp is a method. But is there any easier way to do this?
Another quick question is if I run three parallel while loops and save the data at the same time, where there be any delay in the saved data? I've set the VI to reentrant mode.
Attachment is my code, thank you in advance!
11-15-2016 04:41 PM
If the code of thew two loops should always be synchronized, maybe put all code in a single loop instead. 😄
Else please define what "exactly the same time" means. What determines the loop rates?
Reentrant mode applies to multiple instances if the same subVIs, not to flat code on the main diagram. It makes no difference here.
11-15-2016 04:49 PM
There is a whole pallete of VIs dedicated to syncronization. Strangely, it's called Syncronization. Sorry for the snarky remark.
I use the Rendezvous VIs for this purpose. Set the size to 2 and put a Wait at Rendezvous in place of the timestamp. When 2 instances are waiting, the rendezvous is released and off it goes.
11-16-2016 12:05 PM
Hi altenbach,
If I have three parallel loops and want to save the data at the same time, can I simply put them in a single loop? Will it cause some problems?
11-16-2016 12:11 PM
You still have not explained what"at the same time" means. Within seconds? Within nanoseconds?
What determines the loop rate of each loop? Does each run at a different speed?
11-16-2016 01:03 PM
Actually each loop has a different speed, but I want to start and stop saving data at the same time.
11-16-2016 01:27 PM
You can't, because saving is quantized to each loop rate.
11-16-2016 03:18 PM
Yes I know the data saved in each loop is determined by loop rate, but I want to synchronize the start time and stop time. Previously, I realized it using time stamp, and I'm wondering is there any other easier methods to do it.
11-16-2016 03:20 PM
Hi aputman,
Thank you very much! So if I use "wait at rendezvous", two loops will start saving at the same time right?
11-16-2016 04:15 PM
In theory, yes. It's not as simple as the example I posted but that is how rendezvous works. But going back to what Altenbach says, what do you really mean "at the same time." You have other operations happening in the same loop that may happen before the write operation in one iteration of the loop and after the write operation in the next iteration.
Why do you worry about writing to the file at the same time. shouldn't you read from the microphone and the serial port at the same time, and send the data (via queue) to a consumer loop where the two values are written into the same file, together? Synchronizing the "write to file" operation doesn't not mean that the data is synchronized.