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!
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.
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.
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?
Actually each loop has a different speed, but I want to start and stop saving data at the same time.
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.
Thank you very much! So if I use "wait at rendezvous", two loops will start saving at the same time right?
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.