From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to synchronize "Write to Measurement File" in parallel while loop?

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!

Synchronize.PNG

0 Kudos
Message 1 of 12
(3,970 Views)

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.

0 Kudos
Message 2 of 12
(3,956 Views)

There is a whole pallete of VIs dedicated to syncronization.  Strangely, it's called Syncronization.  Smiley Very Happy  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. 

Capture.PNG

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 3 of 12
(3,941 Views)

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?

0 Kudos
Message 4 of 12
(3,889 Views)

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?

0 Kudos
Message 5 of 12
(3,886 Views)

Actually each loop has a different speed, but I want to start and stop saving data at the same time.

0 Kudos
Message 6 of 12
(3,865 Views)

You can't, because saving is quantized to each loop rate.

0 Kudos
Message 7 of 12
(3,857 Views)

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.

0 Kudos
Message 8 of 12
(3,842 Views)

Hi aputman,

 

Thank you very much! So if I use "wait at rendezvous", two loops will start saving at the same time right? 

0 Kudos
Message 9 of 12
(3,839 Views)

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.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 10 of 12
(3,831 Views)