LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronizing Timed Loop across Applications

Hi All,
 
Please, could you suggest any better idea for solving the following problem of synchronization?
 
I have two distinct applications (which cannot be merged) which acquire data from two completely indipendent devices (ie device1 and device2). The first application (controlling device1) has to run continuously for weeks, normally acquiring every 15 minutes. The second applications (controlling device2) only runs for one day or two, every time the user chooses to do that. After some configuration input from the user, this application acquires data every minute. Both applications use Timed Loops for timing the data logging.
 
Every time it is needed, application2 is then programmatically called by application1 and the rate of acquisition from device1 dropped from 15 minutes to 1 minute for all the lap of time application2 is running. My problem now is synchronizing the Timed Loop of application2 with the one of application1 (which has never been interrupted).
 
How can I force the Timed Loop of application2 to start when the next available iteration of the Timed Loop of application1 starts?
 
Is there something like "Wait on Notification" which works across applications (on the same computer)?
 
PS
I noticed that some sort of synchronization already exists. I put a Timed Loop (period 3 seconds) in an empty VI and saved. I put another Timed Loop (period 5 seconds) in another empty VI and saved. I started the first VI and recorded the starting time of each iteration. I obtained something like:
 
iteration0 13h 05m 12.565
iteration1 13h 05m 15.566
iteration2 13h 05m 18.564
iteration3 13h 05m 21.565
iteration4 13h 05m 25.566
iteration5 13h 05m 27.564
...
 
While the first VI was running, I started the second one and recorded the starting time of each iteration. I obtained something like:

iteration0 13h 05m 20.565
iteration1 13h 05m 25.564
iteration2 13h 05m 30.567
...
 
Both Timed Loop use the conventional 1KHz time source. Even if the second VI is started at a time which is completely independent from the time the first VI is started, there seems to be a kind of synchronization across applications (the fractional part of the seconds is the same). What I need to do is to find a way of forcing iteration0 of the second VI to start at 13h 05m 21.565 as iteration3 of the first VI.
 
Have an awesome day,
 
LucaQ
0 Kudos
Message 1 of 4
(2,982 Views)

hi there

first of all: what resolution do you need? if you need < ms you should use some sort of hardware trigger. if > ms is ok, then try this:

create a DataSocket item on App1 and write the timed loop index on this item. on App2 read the items value with parameter "wait for updated value" set to TRUE. the read function won't time out when App1 writes the next loop index to this item. you'll need a network connection between system 1 and system 2.

to answer your remark "PS:I noticed that some sort of synchronization already exists...":

the timed loops of one instance of the LV runtime engine use the same ms timing source, so it's obvious that they run in sync. if you create two vis with a timed loop and built seperate executables you'll see that they aren't in sync anymore, because each loop now has its own instance of the runtime engine and so its own timing source.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 2 of 4
(2,976 Views)

Dear Chris,

 

Thank you for the suggestion!

 

Unfortunately I haven't fully understood how to code your explanation [I'm a newcomer of Labview (<3 months)] but I succeeded in synchronizing the two Timed Loops using some of your ideas J

 

At the beginning of every loop of the Timed Loop in Application1 I write with DataSocket the sum of the timestring obtained with "Get Date/Time in seconds" and the period (in seconds) of the Timed Loop structure (=the timestring of the start of the next loop).

When the second application is started, I read the timestring from DataSocket, simultaneously I obtain a timestring with "Get Date/Time in seconds" (=the start time of Application2), I calculate the difference in seconds and I feed this difference to the Express Vi "Time Delay". I then wire the ErrorOut of the "Time Dealy" to the ErrorIn of the Timed Structure in Application2.

 
In this way the Timed Loops in Application2 starts in synchrony with the Timed Loop in Application1!!!
 
Best Regards, LucaQ
0 Kudos
Message 3 of 4
(2,958 Views)

hi there

please take a look at the attachment.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 4 of 4
(2,954 Views)