LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted

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
(1,923 Views)
Highlighted

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.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 2 of 12
(1,909 Views)
Highlighted

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
LabVIEW 2017
LabVIEW Programming
0 Kudos
Message 3 of 12
(1,894 Views)
Highlighted

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
(1,842 Views)
Highlighted

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?


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 12
(1,839 Views)
Highlighted

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
(1,818 Views)
Highlighted

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


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 7 of 12
(1,810 Views)
Highlighted

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
(1,795 Views)
Highlighted

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
(1,792 Views)
Highlighted

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
LabVIEW 2017
LabVIEW Programming
0 Kudos
Message 10 of 12
(1,784 Views)